PatternTypes

Trait PatternTypes 

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

Source

type Ref: ?Sized

The borrowed type.

Source

type Own: Copy + 'static

The owned type.

Required Methods§

Source

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.

Source

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.

Source

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.

Source

fn as_str<'b>(value: RefOwn<'b, Self::Ref, Self::Own>) -> Option<&'b str>

Returns the value as an &str.

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.

Implementors§