Struct Attrs

Source
pub struct Attrs {
    pub attrs: GenericHashMap<String, Value, RandomState, ArcK>,
}

Fields§

§attrs: GenericHashMap<String, Value, RandomState, ArcK>

Implementations§

Source§

impl Attrs

Source

pub fn from( new_values: GenericHashMap<String, Value, RandomState, ArcK>, ) -> Attrs

Source

pub fn get_value<T>(&self, key: &str) -> Option<T>

Source

pub fn update( &self, new_values: GenericHashMap<String, Value, RandomState, ArcK>, ) -> Attrs

Source

pub fn get_safe(&self, key: &str) -> Option<&Value>

Methods from Deref<Target = GenericHashMap<String, Value, RandomState, ArcK>>§

Source

pub fn is_empty(&self) -> bool

Test whether a hash map is empty.

Time: O(1)

§Examples
assert!(
  !hashmap!{1 => 2}.is_empty()
);
assert!(
  HashMap::<i32, i32>::new().is_empty()
);
Source

pub fn len(&self) -> usize

Get the size of a hash map.

Time: O(1)

§Examples
assert_eq!(3, hashmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.len());
Source

pub fn ptr_eq(&self, other: &GenericHashMap<K, V, S, P>) -> bool

Test whether two maps refer to the same content in memory.

This is true if the two sides are references to the same map, or if the two maps refer to the same root node.

This would return true if you’re comparing a map to itself, or if you’re comparing a map to a fresh clone of itself.

Time: O(1)

Source

pub fn hasher(&self) -> &S

Get a reference to the map’s BuildHasher.

Source

pub fn new_from<K1, V1>(&self) -> GenericHashMap<K1, V1, S, P>
where K1: Hash + Eq + Clone, V1: Clone, S: Clone,

Construct an empty hash map using the same hasher as the current hash map.

Source

pub fn iter(&self) -> Iter<'_, K, V, P>

Get an iterator over the key/value pairs of a hash map.

Please note that the order is consistent between maps using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same map.

Source

pub fn keys(&self) -> Keys<'_, K, V, P>

Get an iterator over a hash map’s keys.

Please note that the order is consistent between maps using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same map.

Source

pub fn values(&self) -> Values<'_, K, V, P>

Get an iterator over a hash map’s values.

Please note that the order is consistent between maps using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same map.

Source

pub fn clear(&mut self)

Discard all elements from the map.

This leaves you with an empty map, and all elements that were previously inside it are dropped.

Time: O(n)

§Examples
let mut map = hashmap![1=>1, 2=>2, 3=>3];
map.clear();
assert!(map.is_empty());
Source

pub fn get<BK>(&self, key: &BK) -> Option<&V>
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Get the value for a key from a hash map.

Time: O(log n)

§Examples
let map = hashmap!{123 => "lol"};
assert_eq!(
  map.get(&123),
  Some(&"lol")
);
Source

pub fn get_key_value<BK>(&self, key: &BK) -> Option<(&K, &V)>
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Get the key/value pair for a key from a hash map.

Time: O(log n)

§Examples
let map = hashmap!{123 => "lol"};
assert_eq!(
  map.get_key_value(&123),
  Some((&123, &"lol"))
);
Source

pub fn contains_key<BK>(&self, k: &BK) -> bool
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Test for the presence of a key in a hash map.

Time: O(log n)

§Examples
let map = hashmap!{123 => "lol"};
assert!(
  map.contains_key(&123)
);
assert!(
  !map.contains_key(&321)
);
Source

pub fn is_submap_by<B, RM, F, P2>(&self, other: RM, cmp: F) -> bool
where P2: SharedPointerKind, F: FnMut(&V, &B) -> bool, RM: Borrow<GenericHashMap<K, B, S, P2>>,

Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.

Use the provided function to decide whether values are equal.

Time: O(n log n)

Source

pub fn is_proper_submap_by<B, RM, F, P2>(&self, other: RM, cmp: F) -> bool
where P2: SharedPointerKind, F: FnMut(&V, &B) -> bool, RM: Borrow<GenericHashMap<K, B, S, P2>>,

Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.

Use the provided function to decide whether values are equal.

Time: O(n log n)

Source

pub fn is_submap<RM>(&self, other: RM) -> bool
where V: PartialEq, RM: Borrow<GenericHashMap<K, V, S, P>>,

Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.

Time: O(n log n)

§Examples
let map1 = hashmap!{1 => 1, 2 => 2};
let map2 = hashmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_submap(map2));
Source

pub fn is_proper_submap<RM>(&self, other: RM) -> bool
where V: PartialEq, RM: Borrow<GenericHashMap<K, V, S, P>>,

Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.

Time: O(n log n)

§Examples
let map1 = hashmap!{1 => 1, 2 => 2};
let map2 = hashmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_proper_submap(map2));

let map3 = hashmap!{1 => 1, 2 => 2};
let map4 = hashmap!{1 => 1, 2 => 2};
assert!(!map3.is_proper_submap(map4));
Source

pub fn iter_mut(&mut self) -> IterMut<'_, K, V, P>

Get a mutable iterator over the values of a hash map.

Please note that the order is consistent between maps using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same map.

Source

pub fn get_mut<BK>(&mut self, key: &BK) -> Option<&mut V>
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Get a mutable reference to the value for a key from a hash map.

Time: O(log n)

§Examples
let mut map = hashmap!{123 => "lol"};
if let Some(value) = map.get_mut(&123) {
    *value = "omg";
}
assert_eq!(
  map.get(&123),
  Some(&"omg")
);
Source

pub fn get_key_value_mut<BK>(&mut self, key: &BK) -> Option<(&K, &mut V)>
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Get the key/value pair for a key from a hash map, returning a mutable reference to the value.

Time: O(log n)

§Examples
let mut map = hashmap!{123 => "lol"};
assert_eq!(
  map.get_key_value_mut(&123),
  Some((&123, &mut "lol"))
);
Source

pub fn insert(&mut self, k: K, v: V) -> Option<V>

Insert a key/value mapping into a map.

If the map already has a mapping for the given key, the previous value is overwritten.

Time: O(log n)

§Examples
let mut map = hashmap!{};
map.insert(123, "123");
map.insert(456, "456");
assert_eq!(
  map,
  hashmap!{123 => "123", 456 => "456"}
);
Source

pub fn remove<BK>(&mut self, k: &BK) -> Option<V>
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed value.

This is a copy-on-write operation, so that the parts of the set’s structure which are shared with other sets will be safely copied before mutating.

Time: O(log n)

§Examples
let mut map = hashmap!{123 => "123", 456 => "456"};
assert_eq!(Some("123"), map.remove(&123));
assert_eq!(Some("456"), map.remove(&456));
assert_eq!(None, map.remove(&789));
assert!(map.is_empty());
Source

pub fn remove_with_key<BK>(&mut self, k: &BK) -> Option<(K, V)>
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed key and value.

Time: O(log n)

§Examples
let mut map = hashmap!{123 => "123", 456 => "456"};
assert_eq!(Some((123, "123")), map.remove_with_key(&123));
assert_eq!(Some((456, "456")), map.remove_with_key(&456));
assert_eq!(None, map.remove_with_key(&789));
assert!(map.is_empty());
Source

pub fn entry(&mut self, key: K) -> Entry<'_, K, V, S, P>

Get the Entry for a key in the map for in-place manipulation.

Time: O(log n)

Source

pub fn update(&self, k: K, v: V) -> GenericHashMap<K, V, S, P>

Construct a new hash map by inserting a key/value mapping into a map.

If the map already has a mapping for the given key, the previous value is overwritten.

Time: O(log n)

§Examples
let map = hashmap!{};
assert_eq!(
  map.update(123, "123"),
  hashmap!{123 => "123"}
);
Source

pub fn update_with<F>(&self, k: K, v: V, f: F) -> GenericHashMap<K, V, S, P>
where F: FnOnce(V, V) -> V,

Construct a new hash map by inserting a key/value mapping into a map.

If the map already has a mapping for the given key, we call the provided function with the old value and the new value, and insert the result as the new value.

Time: O(log n)

Source

pub fn update_with_key<F>(&self, k: K, v: V, f: F) -> GenericHashMap<K, V, S, P>
where F: FnOnce(&K, V, V) -> V,

Construct a new map by inserting a key/value mapping into a map.

If the map already has a mapping for the given key, we call the provided function with the key, the old value and the new value, and insert the result as the new value.

Time: O(log n)

Source

pub fn update_lookup_with_key<F>( &self, k: K, v: V, f: F, ) -> (Option<V>, GenericHashMap<K, V, S, P>)
where F: FnOnce(&K, &V, V) -> V,

Construct a new map by inserting a key/value mapping into a map, returning the old value for the key as well as the new map.

If the map already has a mapping for the given key, we call the provided function with the key, the old value and the new value, and insert the result as the new value.

Time: O(log n)

Source

pub fn alter<F>(&self, f: F, k: K) -> GenericHashMap<K, V, S, P>
where F: FnOnce(Option<V>) -> Option<V>,

Update the value for a given key by calling a function with the current value and overwriting it with the function’s return value.

The function gets an Option<V> and returns the same, so that it can decide to delete a mapping instead of updating the value, and decide what to do if the key isn’t in the map.

Time: O(log n)

Source

pub fn without<BK>(&self, k: &BK) -> GenericHashMap<K, V, S, P>
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Construct a new map without the given key.

Construct a map that’s a copy of the current map, absent the mapping for key if it’s present.

Time: O(log n)

Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&K, &V) -> bool,

Filter out values from a map which don’t satisfy a predicate.

This is slightly more efficient than filtering using an iterator, in that it doesn’t need to rehash the retained values, but it still needs to reconstruct the entire tree structure of the map.

Time: O(n log n)

§Examples
let mut map = hashmap!{1 => 1, 2 => 2, 3 => 3};
map.retain(|k, v| *k > 1);
let expected = hashmap!{2 => 2, 3 => 3};
assert_eq!(expected, map);
Source

pub fn extract<BK>(&self, k: &BK) -> Option<(V, GenericHashMap<K, V, S, P>)>
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed value as well as the updated map.

Time: O(log n)

Source

pub fn extract_with_key<BK>( &self, k: &BK, ) -> Option<(K, V, GenericHashMap<K, V, S, P>)>
where BK: Hash + Eq + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed key and value as well as the updated list.

Time: O(log n)

Trait Implementations§

Source§

impl<'a> Add<Attrs> for AttrsRef<'a>

为 AttrsRef 实现自定义的 + 运算符,用于添加属性 当使用 + 运算符时,会更新当前节点的属性

Source§

type Output = Result<AttrsRef<'a>, Error>

The resulting type after applying the + operator.
Source§

fn add(self, attrs: Attrs) -> <AttrsRef<'a> as Add<Attrs>>::Output

Performs the + operation. Read more
Source§

impl Clone for Attrs

Source§

fn clone(&self) -> Attrs

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Attrs

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Attrs

Source§

fn default() -> Attrs

Returns the “default value” for a type. Read more
Source§

impl Deref for Attrs

Source§

type Target = GenericHashMap<String, Value, RandomState, ArcK>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<Attrs as Deref>::Target

Dereferences the value.
Source§

impl DerefMut for Attrs

Source§

fn deref_mut(&mut self) -> &mut <Attrs as Deref>::Target

Mutably dereferences the value.
Source§

impl<'de> Deserialize<'de> for Attrs

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Attrs, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Index<&str> for Attrs

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: &str) -> &<Attrs as Index<&str>>::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<&str> for Attrs

Source§

fn index_mut(&mut self, key: &str) -> &mut <Attrs as Index<&str>>::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl PartialEq for Attrs

Source§

fn eq(&self, other: &Attrs) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Attrs

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Attrs

Source§

impl StructuralPartialEq for Attrs

Auto Trait Implementations§

§

impl Freeze for Attrs

§

impl RefUnwindSafe for Attrs

§

impl Send for Attrs

§

impl Sync for Attrs

§

impl Unpin for Attrs

§

impl UnwindSafe for Attrs

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,