From 5b6461d0f0327e313f8d15fd14783c48d6173ff4 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Sat, 11 Jan 2025 13:56:10 +1300 Subject: [PATCH 1/4] Update dependency versions. --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b70bb19..d1aca03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,11 +12,11 @@ license = "MIT OR Apache-2.0" [dependencies] nom = { version = "7.1.3", default-features = false, features = ["alloc"] } -serde = { version = "1.0.196", optional = true, features = ["derive"] } +serde = { version = "1.0.217", optional = true, features = ["derive"] } [dev-dependencies] -pretty_assertions = "1.4.0" -serde_yaml = "0.9.31" +pretty_assertions = "1.4.1" +serde_yaml = "0.9.34" [features] default = [] From 879b51f07cba8e55ffd4c8355ea00c2002b288b2 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Sat, 11 Jan 2025 13:56:21 +1300 Subject: [PATCH 2/4] Update `rustfmt.toml`. --- rustfmt.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rustfmt.toml b/rustfmt.toml index e15e953..3e939f4 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,7 @@ +edition = "2021" format_code_in_doc_comments = true -merge_imports = true +imports_granularity = "crate" +reorder_impl_items = true +style_edition = "2021" +use_field_init_shorthand = true +wrap_comments = true From 7b14abcf82cc4ea6d657f6a10837d1623f4cbe84 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Sat, 11 Jan 2025 13:56:39 +1300 Subject: [PATCH 3/4] Run `cargo fmt --all`. --- src/lib.rs | 43 +++++---- src/parser.rs | 24 ++--- src/type_name_info.rs | 3 +- src/types.rs | 216 ++++++++++++++++++++++++++---------------- 4 files changed, 175 insertions(+), 111 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d88ca6f..7c4a902 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,8 @@ #![no_std] // #![deny(missing_docs, missing_debug_implementations)] -//! Returns type names with a specifiable number of module segments as a `String`. +//! Returns type names with a specifiable number of module segments as a +//! `String`. //! //! # Usage //! @@ -42,12 +43,12 @@ //! //! # Motivation //! -//! The [`core::any::type_name`] function stabilized in Rust 1.38 returns the fully qualified type -//! name with all module segments. This can be difficult to read in error messages, especially for -//! type-parameterized types. +//! The [`core::any::type_name`] function stabilized in Rust 1.38 returns the +//! fully qualified type name with all module segments. This can be difficult to +//! read in error messages, especially for type-parameterized types. //! -//! Often, the simple type name is more readable, and enough to distinguish the type referenced in -//! an error. +//! Often, the simple type name is more readable, and enough to distinguish the +//! type referenced in an error. //! //! [`core::any::type_name`]: https://doc.rust-lang.org/std/any/fn.type_name.html @@ -92,7 +93,8 @@ where /// /// # Parameters /// -/// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. +/// * `type_params_fmt_opts`: How to format type parameters, see the type +/// documentation for details. /// /// # Type Parameters /// @@ -126,7 +128,8 @@ where type_namemn_opts::(0, 0, type_params_fmt_opts) } -/// Returns the type name with at most `m` most significant module path segments. +/// Returns the type name with at most `m` most significant module path +/// segments. /// /// # Parameters /// @@ -151,12 +154,14 @@ where type_namemn::(m, 0) } -/// Returns the type name with at most `m` most significant module path segments. +/// Returns the type name with at most `m` most significant module path +/// segments. /// /// # Parameters /// /// * `m`: Number of most significant module path segments to include. -/// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. +/// * `type_params_fmt_opts`: How to format type parameters, see the type +/// documentation for details. /// /// # Type Parameters /// @@ -193,7 +198,8 @@ where type_namemn_opts::(m, 0, type_params_fmt_opts) } -/// Returns the type name with at most `n` least significant module path segments. +/// Returns the type name with at most `n` least significant module path +/// segments. /// /// # Parameters /// @@ -218,12 +224,14 @@ where type_namemn::(0, n) } -/// Returns the type name with at most `n` least significant module path segments. +/// Returns the type name with at most `n` least significant module path +/// segments. /// /// # Parameters /// /// * `n`: Number of least significant module path segments to include. -/// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. +/// * `type_params_fmt_opts`: How to format type parameters, see the type +/// documentation for details. /// /// # Type Parameters /// @@ -256,7 +264,8 @@ where type_namemn_opts::(0, n, type_params_fmt_opts) } -/// Returns the type name with `m` most significant, and `n` least significant module path segments. +/// Returns the type name with `m` most significant, and `n` least significant +/// module path segments. /// /// # Parameters /// @@ -282,13 +291,15 @@ where type_namemn_opts::(m, n, TypeParamsFmtOpts::All) } -/// Returns the type name with `m` most significant, and `n` least significant module path segments. +/// Returns the type name with `m` most significant, and `n` least significant +/// module path segments. /// /// # Parameters /// /// * `m`: Number of most significant module path segments to include. /// * `n`: Number of least significant module path segments to include. -/// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. +/// * `type_params_fmt_opts`: How to format type parameters, see the type +/// documentation for details. /// /// # Type Parameters /// diff --git a/src/parser.rs b/src/parser.rs index e35810f..7dd6131 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -208,11 +208,12 @@ pub fn struct_type(input: &str) -> IResult<&str, TypeNameStruct> { } pub fn named_primitive_or_struct(input: &str) -> IResult<&str, TypeName> { - // Check for primitive types first, otherwise we cannot distinguish the `std::u32` module from - // `u32` (type). + // Check for primitive types first, otherwise we cannot distinguish the + // `std::u32` module from `u32` (type). // - // We shouldn't have to worry about `use crate::u32; u32::SomeType` as the type name input - // should be the fully qualified crate name as determined by Rust. + // We shouldn't have to worry about `use crate::u32; u32::SomeType` as the type + // name input should be the fully qualified crate name as determined by + // Rust. if let Some(result) = named_primitive(input) { result } else { @@ -234,12 +235,12 @@ pub fn trait_type(input: &str) -> IResult<&str, TypeName> { /// Parses a type name. pub fn type_name(input: &str) -> IResult<&str, TypeName> { - // Primitive types begin with lowercase letters, but we have to detect them at this level, as - // lower parsers (`module_name`, `type_simple_name`) cannot tell if `"std::"` precedes the input - // it is given. + // Primitive types begin with lowercase letters, but we have to detect them at + // this level, as lower parsers (`module_name`, `type_simple_name`) cannot + // tell if `"std::"` precedes the input it is given. // - // In addition, types may begin with symbols, and we should detect them here and branch to the - // relevant parsing functions. + // In addition, types may begin with symbols, and we should detect them here and + // branch to the relevant parsing functions. let mut chars = input.chars(); if let Some(first_char) = chars.next() { match first_char { @@ -255,8 +256,9 @@ pub fn type_name(input: &str) -> IResult<&str, TypeName> { if let Some(remainder) = split.next() { trait_type(remainder) } else { - // We only have "dyn" as a token. User may have specified r#dyn as a struct name or function - // name, but this is unusual. For now, we treat it as a struct. + // We only have "dyn" as a token. User may have specified r#dyn as a struct + // name or function name, but this is unusual. For + // now, we treat it as a struct. Ok(( "", TypeName::Struct(TypeNameStruct { diff --git a/src/type_name_info.rs b/src/type_name_info.rs index 01af1ee..fbba1fa 100644 --- a/src/type_name_info.rs +++ b/src/type_name_info.rs @@ -6,7 +6,8 @@ use alloc::string::String; pub struct TypeNameInfo { /// The short type name, e.g. `"Option"`. pub short_name: String, - /// The full type name, e.g. `"core::option::Option"`. + /// The full type name, e.g. + /// `"core::option::Option"`. pub full_name: String, } diff --git a/src/types.rs b/src/types.rs index 858f1d5..19e5ced 100644 --- a/src/types.rs +++ b/src/types.rs @@ -66,42 +66,51 @@ impl<'s> TypeName<'s> { /// Returns the type name string without any module paths. /// - /// This is equivalent to calling `TypeName::as_str_mn_opts(0, 0, TypeParamsFmtOpts::All);` + /// This is equivalent to calling `TypeName::as_str_mn_opts(0, 0, + /// TypeParamsFmtOpts::All);` pub fn as_str(&self) -> String { self.as_str_mn(0, 0) } /// Returns the type name string without any module paths. /// - /// This is equivalent to calling `TypeName::as_str_mn_opts(0, 0, type_params_fmt_opts);` + /// This is equivalent to calling `TypeName::as_str_mn_opts(0, 0, + /// type_params_fmt_opts);` pub fn as_str_opts(&self, type_params_fmt_opts: TypeParamsFmtOpts) -> String { self.as_str_mn_opts(0, 0, type_params_fmt_opts) } /// Returns the type name string with the given number of module segments. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// printed once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed printed once. /// - /// This is equivalent to calling `TypeName::as_str_mn_opts(m, n, TypeParamsFmtOpts::All);` + /// This is equivalent to calling `TypeName::as_str_mn_opts(m, n, + /// TypeParamsFmtOpts::All);` /// /// # Parameters /// - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). pub fn as_str_mn(&self, m: usize, n: usize) -> String { self.as_str_mn_opts(m, n, TypeParamsFmtOpts::All) } + /// Returns the type name string with the given number of module segments. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// printed once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed printed once. /// /// # Parameters /// - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. pub fn as_str_mn_opts( &self, m: usize, @@ -165,14 +174,16 @@ impl<'s> TypeName<'s> { /// When using this type name in a `format!` or similar it is more efficient /// to use this display instead of first creating a string. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). /// /// # Example /// @@ -193,15 +204,18 @@ impl<'s> TypeName<'s> { /// When using this type name in a `format!` or similar it is more efficient /// to use this display instead of first creating a string. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. /// /// # Example /// @@ -228,14 +242,16 @@ impl<'s> TypeName<'s> { /// Writes the type name string to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). pub fn write_str(&self, buffer: &mut W, m: usize, n: usize) -> Result<(), Error> where W: Write, @@ -245,15 +261,18 @@ impl<'s> TypeName<'s> { /// Writes the type name string to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. pub fn write_str_opts( &self, buffer: &mut W, @@ -315,15 +334,18 @@ impl<'s> TypeNameArray<'s> { /// Writes the type name string to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. pub fn write_str( &self, buffer: &mut W, @@ -365,15 +387,18 @@ impl<'s> TypeNamePointer<'s> { /// Writes the type name string to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. pub fn write_str( &self, buffer: &mut W, @@ -414,15 +439,18 @@ impl<'s> TypeNameReference<'s> { /// Writes the type name string to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. pub fn write_str( &self, buffer: &mut W, @@ -457,15 +485,18 @@ impl<'s> TypeNameSlice<'s> { /// Writes the type name string to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. pub fn write_str( &self, buffer: &mut W, @@ -476,7 +507,8 @@ impl<'s> TypeNameSlice<'s> { where W: Write, { - // Don't need to prepend with `"&"` because slices are always passed in as references. + // Don't need to prepend with `"&"` because slices are always passed in as + // references. buffer.write_str("[")?; self.type_param .write_str_opts(buffer, m, n, type_params_fmt_opts)?; @@ -513,15 +545,18 @@ impl<'s> TypeNameStruct<'s> { /// Writes the type name string to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. pub fn write_str( &self, buffer: &mut W, @@ -554,14 +589,16 @@ impl<'s> TypeNameStruct<'s> { /// Writes the module path to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). pub fn write_module_path(&self, buffer: &mut W, m: usize, n: usize) -> Result<(), Error> where W: Write, @@ -613,14 +650,16 @@ impl<'s> TypeNameStruct<'s> { /// Writes type parameters to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). pub fn write_type_params( &self, buffer: &mut W, @@ -665,15 +704,18 @@ impl<'s> TypeNameTuple<'s> { /// Writes the type name string to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. pub fn write_str( &self, buffer: &mut W, @@ -691,7 +733,8 @@ impl<'s> TypeNameTuple<'s> { first.write_str_opts(buffer, m, n, type_params_fmt_opts)?; if self.type_params.len() == 1 { - buffer.write_str(",")?; // Always write `,` after first type. + buffer.write_str(",")?; // Always write `,` after first + // type. } else { rest.iter().try_for_each(|type_param| { buffer.write_str(", ").and_then(|_| { @@ -733,15 +776,18 @@ impl<'s> TypeNameTrait<'s> { /// Writes the type name string to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). - /// * `type_params_fmt_opts`: How to format type parameters, see the type documentation for details. + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). + /// * `type_params_fmt_opts`: How to format type parameters, see the type + /// documentation for details. pub fn write_str( &self, buffer: &mut W, @@ -758,14 +804,16 @@ impl<'s> TypeNameTrait<'s> { /// Writes the module path to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). pub fn write_module_path(&self, buffer: &mut W, m: usize, n: usize) -> Result<(), Error> where W: Write, @@ -787,14 +835,16 @@ impl<'s> TypeNameTrait<'s> { /// Writes type parameters to the given buffer. /// - /// If the left and right module segments overlap, the overlapping segments will only be printed - /// once. + /// If the left and right module segments overlap, the overlapping segments + /// will only be printed once. /// /// # Parameters /// /// * `buffer`: Buffer to write to. - /// * `m`: Number of module segments to include, beginning from the left (most significant). - /// * `n`: Number of module segments to include, beginning from the right (least significant). + /// * `m`: Number of module segments to include, beginning from the left + /// (most significant). + /// * `n`: Number of module segments to include, beginning from the right + /// (least significant). pub fn write_type_params( &self, buffer: &mut W, From ea7df6e97d9b84ad8502e9f664d1956fe9cb6566 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Sat, 11 Jan 2025 13:57:28 +1300 Subject: [PATCH 4/4] Address clippy lints. --- src/lib.rs | 4 ++-- src/types.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7c4a902..c99a659 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -472,9 +472,9 @@ mod tests { #[test] fn type_name_usize_mn() { - assert_eq!(tynm::type_namem::(core::usize::MAX), "::usize"); + assert_eq!(tynm::type_namem::(usize::MAX), "::usize"); assert_eq!( - tynm::type_namemn::(core::usize::MAX, core::usize::MAX), + tynm::type_namemn::(usize::MAX, usize::MAX), "::usize" ); } diff --git a/src/types.rs b/src/types.rs index 19e5ced..1142dbf 100644 --- a/src/types.rs +++ b/src/types.rs @@ -29,7 +29,7 @@ pub struct TypeNameDisplay<'s> { type_params_fmt_opts: TypeParamsFmtOpts, } -impl<'s> fmt::Display for TypeNameDisplay<'s> { +impl fmt::Display for TypeNameDisplay<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.write_str_opts( f, @@ -56,7 +56,7 @@ pub enum TypeName<'s> { Unit, } -impl<'s> TypeName<'s> { +impl TypeName<'_> { /// Constructs a new TypeName with the name of `T`. /// /// This is equivalent to calling `core::any::type_name::().into()`