Struct Map

Source
pub struct Map<'a, K = u32, V = u32>(/* private fields */);
Expand description

Map objects are integer-to-integer hash-maps.

The map can be specialized to work over other integer-like types, like chars.

Implementations§

Source§

impl<K, V> Map<'static, K, V>

Source

pub fn new() -> Result<Self, AllocationError>

Creates a new, initially empty map.

Source§

impl<'a, K, V> Map<'a, K, V>

Source

pub fn is_empty(&self) -> bool

Tests whether map is empty i.e. contains no elements.

Source

pub fn len(&self) -> usize

Returns the number of key-value pairs in the set.

Source

pub fn clear(&mut self)

Clears out the contents of a map.

Source

pub fn clone_static(&self) -> Map<'static, K, V>

Constructs a copy of the map with 'static lifetime.

Source

pub fn update(&mut self, other: &Self)

Adds the contents of other to map.

Source

pub fn keys(&self) -> Result<Set<'static, K>, AllocationError>

Gets the set of keys that have been defined.

Source

pub fn values(&self) -> Result<Set<'static, V>, AllocationError>

Gets the set of values that are associated with a key.

Source§

impl<'a, K, V> Map<'a, K, V>
where K: Into<u32>, V: Into<u32>,

Source

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

Tests whether the map contains a key.

Source

pub fn remove(&mut self, key: K)

Removes key and its associated value from map.

Source

pub fn insert(&mut self, key: K, value: V)

Inserts a key-value pair to map.

Source§

impl<'a, K, V> Map<'a, K, V>
where K: Into<u32>, V: TryFrom<u32>,

Source

pub fn get(&self, key: K) -> Option<V>

Gets a value based on a key.

Source§

impl<'a, K, V> Map<'a, K, V>
where K: TryFrom<u32>, V: TryFrom<u32>,

Source

pub fn iter(&self) -> MapIter<'_, 'a, K, V>

Gets an iterator over key-value pairs stored in the map.

Source§

impl<'a, K, V> Map<'a, K, V>

Source

pub fn into_raw(self) -> *mut hb_map_t

Converts the map into raw sys::hb_map_t pointer.

This method transfers the ownership of the map to the caller. It is up to the caller to call sys::hb_map_destroy to free the object, or call Self::from_raw to convert it back into Map.

Source

pub fn as_raw(&self) -> *mut hb_map_t

Exposes the raw inner pointer without transferring the ownership.

Unlike Self::into_raw, this method does not transfer the ownership of the pointer to the caller.

Source

pub unsafe fn from_raw(map: *mut hb_map_t) -> Self

Constructs a map from raw sys::hb_map_t object.

§Safety

The given map pointer must either be constructed by some Harfbuzz function, or be returned from Self::into_raw.

Trait Implementations§

Source§

impl<'a, K, V> Clone for Map<'a, K, V>

Source§

fn clone(&self) -> Self

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<'a, K, V> Debug for Map<'a, K, V>
where K: TryFrom<u32> + Debug, V: TryFrom<u32> + Debug,

Source§

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

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

impl<'a, K, V> FromIterator<(K, V)> for Map<'a, K, V>
where K: Into<u32>, V: Into<u32>,

Source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a, K, V> Hash for Map<'a, K, V>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'m, 'a, K, V> IntoIterator for &'m Map<'a, K, V>
where K: TryFrom<u32>, V: TryFrom<u32>,

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = MapIter<'m, 'a, K, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, K, V> PartialEq for Map<'a, K, V>

Source§

fn eq(&self, other: &Self) -> 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<'a, K, V> Eq for Map<'a, K, V>
where K: Eq, V: Eq,

Auto Trait Implementations§

§

impl<'a, K, V> Freeze for Map<'a, K, V>

§

impl<'a, K, V> RefUnwindSafe for Map<'a, K, V>

§

impl<'a, K = u32, V = u32> !Send for Map<'a, K, V>

§

impl<'a, K = u32, V = u32> !Sync for Map<'a, K, V>

§

impl<'a, K, V> Unpin for Map<'a, K, V>
where K: Unpin, V: Unpin,

§

impl<'a, K, V> UnwindSafe for Map<'a, K, V>
where K: UnwindSafe, V: UnwindSafe,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.