pub trait PatternTypes {
type Ref: ?Sized;
type Own: Copy + 'static;
// Required methods
fn pairs<'b>(
item: RefOwn<'b, Self::Ref, Self::Own>,
) -> Option<Box<dyn Iterator<Item = KVPair<'b, Self>> + 'b>>;
fn get<'a, 'b>(
item: RefOwn<'b, Self::Ref, Self::Own>,
key: RefOwn<'a, Self::Ref, Self::Own>,
) -> Option<Option<KVPair<'b, Self>>>;
fn matches(
left: RefOwn<'_, Self::Ref, Self::Own>,
right: RefOwn<'_, Self::Ref, Self::Own>,
) -> bool;
fn as_str<'b>(value: RefOwn<'b, Self::Ref, Self::Own>) -> Option<&'b str>;
}Expand description
Defines the types and operations used for matching.
Required Associated Types§
Required Methods§
Sourcefn pairs<'b>(
item: RefOwn<'b, Self::Ref, Self::Own>,
) -> Option<Box<dyn Iterator<Item = KVPair<'b, Self>> + 'b>>
fn pairs<'b>( item: RefOwn<'b, Self::Ref, Self::Own>, ) -> Option<Box<dyn Iterator<Item = KVPair<'b, Self>> + 'b>>
Returns an iterator over key-value pairs contained within an item, or None if this operation is unsupported for the given value.
Sourcefn get<'a, 'b>(
item: RefOwn<'b, Self::Ref, Self::Own>,
key: RefOwn<'a, Self::Ref, Self::Own>,
) -> Option<Option<KVPair<'b, Self>>>
fn get<'a, 'b>( item: RefOwn<'b, Self::Ref, Self::Own>, key: RefOwn<'a, Self::Ref, Self::Own>, ) -> Option<Option<KVPair<'b, Self>>>
Returns an optional key-value pair keyed by the given key, or None if this operation is unsupported for the given value.
Sourcefn matches(
left: RefOwn<'_, Self::Ref, Self::Own>,
right: RefOwn<'_, Self::Ref, Self::Own>,
) -> bool
fn matches( left: RefOwn<'_, Self::Ref, Self::Own>, right: RefOwn<'_, Self::Ref, Self::Own>, ) -> bool
Returns whether two keys/values are the same/equivalent. This must provide the same guarantees as PartialEq. In fact, this is a replacement for PartialEq for cases where it’s not possible to just use PartialEq.
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.