mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-10 06:34:18 +00:00
Use #[must_use] pub const fn new(...)
whenever possible
This commit is contained in:
parent
f73783aa8a
commit
dca773401d
9 changed files with 37 additions and 19 deletions
|
@ -21,7 +21,13 @@ pub struct PageHeader {
|
|||
|
||||
impl PageHeader {
|
||||
/// Creates a new `PageHeader`
|
||||
pub fn new(header_type_flag: u8, abgp: u64, stream_serial: u32, sequence_number: u32) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(
|
||||
header_type_flag: u8,
|
||||
abgp: u64,
|
||||
stream_serial: u32,
|
||||
sequence_number: u32,
|
||||
) -> Self {
|
||||
Self {
|
||||
start: 0,
|
||||
header_type_flag,
|
||||
|
|
12
src/error.rs
12
src/error.rs
|
@ -122,7 +122,8 @@ pub struct ID3v2Error {
|
|||
|
||||
impl ID3v2Error {
|
||||
/// Create a new `ID3v2Error` from an [`ID3v2ErrorKind`]
|
||||
pub fn new(kind: ID3v2ErrorKind) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(kind: ID3v2ErrorKind) -> Self {
|
||||
Self { kind }
|
||||
}
|
||||
|
||||
|
@ -152,7 +153,8 @@ pub struct FileDecodingError {
|
|||
|
||||
impl FileDecodingError {
|
||||
/// Create a `FileDecodingError` from a [`FileType`] and description
|
||||
pub fn new(format: FileType, description: &'static str) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(format: FileType, description: &'static str) -> Self {
|
||||
Self {
|
||||
format: Some(format),
|
||||
description,
|
||||
|
@ -206,7 +208,8 @@ pub struct FileEncodingError {
|
|||
|
||||
impl FileEncodingError {
|
||||
/// Create a `FileEncodingError` from a [`FileType`] and description
|
||||
pub fn new(format: FileType, description: &'static str) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(format: FileType, description: &'static str) -> Self {
|
||||
Self {
|
||||
format: Some(format),
|
||||
description,
|
||||
|
@ -259,7 +262,8 @@ pub struct LoftyError {
|
|||
|
||||
impl LoftyError {
|
||||
/// Create a `LoftyError` from an [`ErrorKind`]
|
||||
pub fn new(kind: ErrorKind) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(kind: ErrorKind) -> Self {
|
||||
Self { kind }
|
||||
}
|
||||
|
||||
|
|
|
@ -380,7 +380,8 @@ pub struct TaggedFile {
|
|||
impl TaggedFile {
|
||||
#[doc(hidden)]
|
||||
/// This exists for use in `lofty_attr`, there's no real use for this externally
|
||||
pub fn new(ty: FileType, properties: FileProperties, tags: Vec<Tag>) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(ty: FileType, properties: FileProperties, tags: Vec<Tag>) -> Self {
|
||||
Self {
|
||||
ty,
|
||||
properties,
|
||||
|
|
|
@ -18,7 +18,8 @@ where
|
|||
}
|
||||
|
||||
impl<B: ByteOrder> Chunks<B> {
|
||||
pub fn new(file_size: u64) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(file_size: u64) -> Self {
|
||||
Self {
|
||||
fourcc: [0; 4],
|
||||
size: 0,
|
||||
|
|
|
@ -87,7 +87,8 @@ pub struct Atom<'a> {
|
|||
|
||||
impl<'a> Atom<'a> {
|
||||
/// Create a new [`Atom`]
|
||||
pub fn new(ident: AtomIdent<'a>, data: AtomData) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(ident: AtomIdent<'a>, data: AtomData) -> Self {
|
||||
Self {
|
||||
ident,
|
||||
data: AtomDataStorage::Single(data),
|
||||
|
|
18
src/probe.rs
18
src/probe.rs
|
@ -41,11 +41,7 @@ impl Default for ParseOptions {
|
|||
/// }
|
||||
/// ```
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
read_properties: true,
|
||||
use_custom_resolvers: true,
|
||||
parsing_mode: ParsingMode::Strict,
|
||||
}
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +57,13 @@ impl ParseOptions {
|
|||
///
|
||||
/// let parsing_options = ParseOptions::new();
|
||||
/// ```
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
#[must_use]
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
read_properties: true,
|
||||
use_custom_resolvers: true,
|
||||
parsing_mode: ParsingMode::Strict,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether or not to read the audio properties
|
||||
|
@ -206,7 +207,8 @@ impl<R: Read> Probe<R> {
|
|||
/// let probe = Probe::new(reader);
|
||||
/// # Ok(()) }
|
||||
/// ```
|
||||
pub fn new(reader: R) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(reader: R) -> Self {
|
||||
Self {
|
||||
inner: reader,
|
||||
options: None,
|
||||
|
|
|
@ -27,7 +27,8 @@ impl Default for FileProperties {
|
|||
|
||||
impl FileProperties {
|
||||
/// Create a new `FileProperties`
|
||||
pub fn new(
|
||||
#[must_use]
|
||||
pub const fn new(
|
||||
duration: Duration,
|
||||
overall_bitrate: Option<u32>,
|
||||
audio_bitrate: Option<u32>,
|
||||
|
|
|
@ -660,7 +660,8 @@ impl TagItem {
|
|||
}
|
||||
|
||||
/// Create a new [`TagItem`]
|
||||
pub fn new(item_key: ItemKey, item_value: ItemValue) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(item_key: ItemKey, item_value: ItemValue) -> Self {
|
||||
Self {
|
||||
item_key,
|
||||
item_value,
|
||||
|
|
|
@ -225,7 +225,8 @@ impl Accessor for Tag {
|
|||
|
||||
impl Tag {
|
||||
/// Initialize a new tag with a certain [`TagType`]
|
||||
pub fn new(tag_type: TagType) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new(tag_type: TagType) -> Self {
|
||||
Self {
|
||||
tag_type,
|
||||
pictures: Vec::new(),
|
||||
|
|
Loading…
Reference in a new issue