Trait ToKeyString

Source
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§

Source

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Formats the given value as a key string.

Provided Methods§

Source

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", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ToKeyString for IpAddr

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for SocketAddr

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TokenTree

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TokenTree

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Meta

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Expr

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for GenericParam

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypeParamBound

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for WherePredicate

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for FnArg

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for UseTree

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Lit

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for BinOp

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for UnOp

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Pat

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Visibility

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Type

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for char

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for f32

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for f64

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for i8

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for i16

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for i32

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for i64

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for i128

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for isize

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for u16

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for u32

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for u64

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for u128

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ()

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R

Source§

impl ToKeyString for usize

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for String

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R

Source§

impl ToKeyString for Ipv4Addr

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Ipv6Addr

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for SocketAddrV4

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for SocketAddrV6

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Group

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Ident

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Literal

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Punct

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TokenStream

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for OsString

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R

Source§

impl ToKeyString for PathBuf

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R

Source§

impl ToKeyString for Ident

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Literal

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Punct

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TokenStream

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for MetaList

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for MetaNameValue

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprArray

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprAssign

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprCall

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprCast

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprField

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprIndex

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprLit

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprMethodCall

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprParen

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprPath

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprRange

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprRepeat

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ExprTuple

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for BoundLifetimes

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for LifetimeParam

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TraitBound

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Receiver

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Signature

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Lifetime

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for LitBool

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for LitByte

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for LitByteStr

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for LitChar

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for LitFloat

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for LitInt

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for LitStr

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for AngleBracketedGenericArguments

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for ParenthesizedGenericArguments

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for Path

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for PathSegment

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for BareFnArg

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypeArray

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypeBareFn

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypeImplTrait

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypePath

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypePtr

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypeReference

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypeSlice

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypeTraitObject

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for TypeTuple

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroI8

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroI16

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroI32

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroI64

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroI128

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroIsize

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroU8

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroU16

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroU32

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroU64

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroU128

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl ToKeyString for NonZeroUsize

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<'t, T: ToKeyString + Clone> ToKeyString for Cow<'t, T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R

Source§

impl<K, V> ToKeyString for BTreeMap<K, V>
where K: ToKeyString + Ord, V: ToKeyString,

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<K, V> ToKeyString for HashMap<K, V>
where K: ToKeyString + Hash + Eq, V: ToKeyString,

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString> ToKeyString for (T0,)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString> ToKeyString for (T0, T1)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString> ToKeyString for (T0, T1, T2)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString> ToKeyString for (T0, T1, T2, T3)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString, T7: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6, T7)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString, T7: ToKeyString, T8: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6, T7, T8)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString, T7: ToKeyString, T8: ToKeyString, T9: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString, T7: ToKeyString, T8: ToKeyString, T9: ToKeyString, T10: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString, T7: ToKeyString, T8: ToKeyString, T9: ToKeyString, T10: ToKeyString, T11: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString, T7: ToKeyString, T8: ToKeyString, T9: ToKeyString, T10: ToKeyString, T11: ToKeyString, T12: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString, T7: ToKeyString, T8: ToKeyString, T9: ToKeyString, T10: ToKeyString, T11: ToKeyString, T12: ToKeyString, T13: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString, T7: ToKeyString, T8: ToKeyString, T9: ToKeyString, T10: ToKeyString, T11: ToKeyString, T12: ToKeyString, T13: ToKeyString, T14: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T0: ToKeyString, T1: ToKeyString, T2: ToKeyString, T3: ToKeyString, T4: ToKeyString, T5: ToKeyString, T6: ToKeyString, T7: ToKeyString, T8: ToKeyString, T9: ToKeyString, T10: ToKeyString, T11: ToKeyString, T12: ToKeyString, T13: ToKeyString, T14: ToKeyString, T15: ToKeyString> ToKeyString for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T: ToKeyString + Ord> ToKeyString for BinaryHeap<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T: ToKeyString + Ord> ToKeyString for BTreeSet<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T: ToKeyString + Hash + Eq> ToKeyString for HashSet<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T: ToKeyString + Copy> ToKeyString for Cell<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R

Source§

impl<T: ToKeyString> ToKeyString for Option<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T: ToKeyString> ToKeyString for Box<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R

Source§

impl<T: ToKeyString> ToKeyString for LinkedList<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T: ToKeyString> ToKeyString for VecDeque<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T: ToKeyString> ToKeyString for Rc<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R

Source§

impl<T: ToKeyString> ToKeyString for Vec<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T: ToKeyString> ToKeyString for RefCell<T>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

fn with_key_string<R>(&self, f: impl FnOnce(&str) -> R) -> R

Source§

impl<T: ToKeyString, P: ToTokens> ToKeyString for Punctuated<T, P>

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Source§

impl<T: ToKeyString, const N: usize> ToKeyString for [T; N]

Source§

fn fmt_key_string(&self, f: &mut Formatter<'_>) -> Result

Implementors§