pub trait ToKeyString: Sized {
// Required method
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result;
// Provided method
fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R { ... }
}Expand description
A trait for converting an attribute key to a string.
Used for performing path comparisons and for constructing error messages when using arbitrary
types as attribute keys. Currently only used by the ParseMetaItem implementations for
BTreeMap and HashMap.
Required Methods§
Sourcefn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Formats the given value as a key string.
Provided Methods§
Sourcefn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R
fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R
Runs function f with the key converted to a &str.
Can be specialized by values that can pass a cheaply borrowed &str. The default
implementation calls f with the result from key_to_string.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ToKeyString for ()
impl ToKeyString for ()
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R
Source§impl ToKeyString for AngleBracketedGenericArguments
impl ToKeyString for AngleBracketedGenericArguments
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for BareFnArg
impl ToKeyString for BareFnArg
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for BinOp
impl ToKeyString for BinOp
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for BoundLifetimes
impl ToKeyString for BoundLifetimes
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Expr
Available on crate feature full only.
impl ToKeyString for Expr
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprArray
Available on crate feature full only.
impl ToKeyString for ExprArray
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprAssign
Available on crate feature full only.
impl ToKeyString for ExprAssign
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprCall
Available on crate feature full only.
impl ToKeyString for ExprCall
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprCast
Available on crate feature full only.
impl ToKeyString for ExprCast
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprField
Available on crate feature full only.
impl ToKeyString for ExprField
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprIndex
Available on crate feature full only.
impl ToKeyString for ExprIndex
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprLit
Available on crate feature full only.
impl ToKeyString for ExprLit
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprMethodCall
Available on crate feature full only.
impl ToKeyString for ExprMethodCall
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprParen
Available on crate feature full only.
impl ToKeyString for ExprParen
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprPath
Available on crate feature full only.
impl ToKeyString for ExprPath
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprRange
Available on crate feature full only.
impl ToKeyString for ExprRange
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprRepeat
Available on crate feature full only.
impl ToKeyString for ExprRepeat
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for ExprTuple
Available on crate feature full only.
impl ToKeyString for ExprTuple
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for FnArg
Available on crate feature full only.
impl ToKeyString for FnArg
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for GenericParam
impl ToKeyString for GenericParam
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Group
Available on crate feature proc-macro only.
impl ToKeyString for Group
Available on crate feature
proc-macro only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Ident
Available on crate feature proc-macro only.
impl ToKeyString for Ident
Available on crate feature
proc-macro only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Ident
impl ToKeyString for Ident
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for IpAddr
impl ToKeyString for IpAddr
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Ipv4Addr
impl ToKeyString for Ipv4Addr
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Ipv6Addr
impl ToKeyString for Ipv6Addr
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Lifetime
impl ToKeyString for Lifetime
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for LifetimeParam
impl ToKeyString for LifetimeParam
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Lit
impl ToKeyString for Lit
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for LitBool
impl ToKeyString for LitBool
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for LitByte
impl ToKeyString for LitByte
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for LitByteStr
impl ToKeyString for LitByteStr
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for LitChar
impl ToKeyString for LitChar
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for LitFloat
impl ToKeyString for LitFloat
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for LitInt
impl ToKeyString for LitInt
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for LitStr
impl ToKeyString for LitStr
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Literal
impl ToKeyString for Literal
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Literal
Available on crate feature proc-macro only.
impl ToKeyString for Literal
Available on crate feature
proc-macro only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Meta
impl ToKeyString for Meta
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for MetaList
impl ToKeyString for MetaList
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for MetaNameValue
impl ToKeyString for MetaNameValue
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroI8
impl ToKeyString for NonZeroI8
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroI16
impl ToKeyString for NonZeroI16
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroI32
impl ToKeyString for NonZeroI32
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroI64
impl ToKeyString for NonZeroI64
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroI128
impl ToKeyString for NonZeroI128
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroIsize
impl ToKeyString for NonZeroIsize
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroU8
impl ToKeyString for NonZeroU8
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroU16
impl ToKeyString for NonZeroU16
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroU32
impl ToKeyString for NonZeroU32
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroU64
impl ToKeyString for NonZeroU64
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroU128
impl ToKeyString for NonZeroU128
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for NonZeroUsize
impl ToKeyString for NonZeroUsize
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for OsString
impl ToKeyString for OsString
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R
Source§impl ToKeyString for ParenthesizedGenericArguments
impl ToKeyString for ParenthesizedGenericArguments
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Pat
Available on crate feature full only.
impl ToKeyString for Pat
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Path
impl ToKeyString for Path
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for PathBuf
impl ToKeyString for PathBuf
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R
Source§impl ToKeyString for PathSegment
impl ToKeyString for PathSegment
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Punct
impl ToKeyString for Punct
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Punct
Available on crate feature proc-macro only.
impl ToKeyString for Punct
Available on crate feature
proc-macro only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Receiver
Available on crate feature full only.
impl ToKeyString for Receiver
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Signature
Available on crate feature full only.
impl ToKeyString for Signature
Available on crate feature
full only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for SocketAddr
impl ToKeyString for SocketAddr
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for SocketAddrV4
impl ToKeyString for SocketAddrV4
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for SocketAddrV6
impl ToKeyString for SocketAddrV6
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for String
impl ToKeyString for String
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R
Source§impl ToKeyString for TokenStream
impl ToKeyString for TokenStream
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TokenStream
Available on crate feature proc-macro only.
impl ToKeyString for TokenStream
Available on crate feature
proc-macro only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TokenTree
impl ToKeyString for TokenTree
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TokenTree
Available on crate feature proc-macro only.
impl ToKeyString for TokenTree
Available on crate feature
proc-macro only.fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TraitBound
impl ToKeyString for TraitBound
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for Type
impl ToKeyString for Type
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypeArray
impl ToKeyString for TypeArray
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypeBareFn
impl ToKeyString for TypeBareFn
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypeImplTrait
impl ToKeyString for TypeImplTrait
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypeParamBound
impl ToKeyString for TypeParamBound
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypePath
impl ToKeyString for TypePath
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypePtr
impl ToKeyString for TypePtr
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypeReference
impl ToKeyString for TypeReference
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypeSlice
impl ToKeyString for TypeSlice
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypeTraitObject
impl ToKeyString for TypeTraitObject
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for TypeTuple
impl ToKeyString for TypeTuple
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for UnOp
impl ToKeyString for UnOp
fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result
Source§impl ToKeyString for UseTree
Available on crate feature full only.
impl ToKeyString for UseTree
Available on crate feature
full only.