# Struct hashbrown::raw::RawTable [−] [src]

    pub struct RawTable<T> { /* fields omitted */ }

A raw hash table with an unsafe API.

## Implementations

### `impl<T> RawTable<T>` [src]

#### `pub const fn new() -> Self` [src]

Creates a new empty hash table without allocating any memory.

In effect this returns a table with exactly 1 bucket. However we can leave the data pointer dangling since that bucket is never written to due to our load factor forcing us to always have at least 1 free bucket.

#### `pub fn try_with_capacity(capacity: usize) -> Result<Self, TryReserveError>` [src]

Attempts to allocate a new hash table with at least enough capacity for inserting the given number of elements without reallocating.

#### `pub fn with_capacity(capacity: usize) -> Self` [src]

Allocates a new hash table with at least enough capacity for inserting the given number of elements without reallocating.

#### `pub unsafe fn data_end(&self) -> NonNull<T>` [src]

Returns pointer to one past last element of data table.

#### `pub unsafe fn bucket_index(&self, bucket: &Bucket<T>) -> usize` [src]

Returns the index of a bucket from a `Bucket`.

#### `pub unsafe fn bucket(&self, index: usize) -> Bucket<T>` [src]

Returns a pointer to an element in the table.

#### `pub unsafe fn erase_no_drop(&mut self, item: &Bucket<T>)` [src]

👎 Deprecated since 0.8.1:

use erase or remove instead

Erases an element from the table without dropping it.

#### `pub unsafe fn erase(&mut self, item: Bucket<T>)` [src]

Erases an element from the table, dropping it in place.

#### `pub fn erase_entry(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> bool` [src]

Finds and erases an element from the table, dropping it in place. Returns true if an element was found.

#### `pub unsafe fn remove(&mut self, item: Bucket<T>) -> T` [src]

Removes an element from the table, returning it.

#### `pub fn remove_entry(
&mut self,
hash: u64,
eq: impl FnMut(&T) -> bool
) -> Option<T>` [src]

Finds and removes an element from the table, returning it.

#### `pub fn clear_no_drop(&mut self)` [src]

Marks all table buckets as empty without dropping their contents.

#### `pub fn clear(&mut self)` [src]

Removes all elements from the table without freeing the backing memory.

#### `pub fn shrink_to(&mut self, min_size: usize, hasher: impl Fn(&T) -> u64)` [src]

Shrinks the table to fit `max(self.len(), min_size)` elements.

#### `pub fn reserve(&mut self, additional: usize, hasher: impl Fn(&T) -> u64)` [src]

Ensures that at least `additional` items can be inserted into the table without reallocation.

#### `pub fn try_reserve(
&mut self,
additional: usize,
hasher: impl Fn(&T) -> u64
) -> Result<(), TryReserveError>` [src]

Tries to ensure that at least `additional` items can be inserted into the table without reallocation.

#### `pub fn insert(
&mut self,
hash: u64,
value: T,
hasher: impl Fn(&T) -> u64
) -> Bucket<T>` [src]

Inserts a new element into the table, and returns its raw bucket.

This does not check if the given element already exists in the table.

#### `pub fn insert_entry(
&mut self,
hash: u64,
value: T,
hasher: impl Fn(&T) -> u64
) -> &mut T` [src]

Inserts a new element into the table, and returns a mutable reference to it.

This does not check if the given element already exists in the table.

#### `pub fn insert_no_grow(&mut self, hash: u64, value: T) -> Bucket<T>` [src]

Inserts a new element into the table, without growing the table.

There must be enough space in the table to insert the new element.

This does not check if the given element already exists in the table.

#### `pub unsafe fn replace_bucket_with<F>(&mut self, bucket: Bucket<T>, f: F) -> bool where
F: FnOnce(T) -> Option<T>,` [src]

Temporary removes a bucket, applying the given function to the removed element and optionally put back the returned value in the same bucket.

Returns `true` if the bucket still contains an element

This does not check if the given bucket is actually occupied.

#### `pub fn find(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<Bucket<T>>` [src]

Searches for an element in the table.

#### `pub fn get(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&T>` [src]

Gets a reference to an element in the table.

#### `pub fn get_mut(
&mut self,
hash: u64,
eq: impl FnMut(&T) -> bool
) -> Option<&mut T>` [src]

Gets a mutable reference to an element in the table.

#### `pub fn capacity(&self) -> usize` [src]

Returns the number of elements the map can hold without reallocating.

This number is a lower bound; the table might be able to hold more, but is guaranteed to be able to hold at least this many.

#### `pub fn len(&self) -> usize` [src]

Returns the number of elements in the table.

#### `pub fn buckets(&self) -> usize` [src]

Returns the number of buckets in the table.

#### `pub unsafe fn iter(&self) -> RawIter<T>ⓘ

### Notable traits for RawIter<T>

`impl<T> Iterator for RawIter<T> type Item = Bucket<T>;`
` [src]

Returns an iterator over every element in the table. It is up to the caller to ensure that the `RawTable` outlives the `RawIter`. Because we cannot make the `next` method unsafe on the `RawIter` struct, we have to make the `iter` method unsafe.

#### `pub unsafe fn iter_hash(&self, hash: u64) -> RawIterHash<'_, T>ⓘ

### Notable traits for RawIterHash<'a, T>

`impl<'a, T> Iterator for RawIterHash<'a, T> type Item = Bucket<T>;`
` [src]

Returns an iterator over occupied buckets that could match a given hash.

In rare cases, the iterator may return a bucket with a different hash.

It is up to the caller to ensure that the `RawTable` outlives the `RawIterHash`. Because we cannot make the `next` method unsafe on the `RawIterHash` struct, we have to make the `iter_hash` method unsafe.

#### `pub fn drain(&mut self) -> RawDrain<'_, T>ⓘ

### Notable traits for RawDrain<'_, T>

`impl<T> Iterator for RawDrain<'_, T> type Item = T;`
` [src]

Returns an iterator which removes all elements from the table without freeing the memory.

#### `pub unsafe fn drain_iter_from(&mut self, iter: RawIter<T>) -> RawDrain<'_, T>ⓘ

### Notable traits for RawDrain<'_, T>

`impl<T> Iterator for RawDrain<'_, T> type Item = T;`
` [src]

Returns an iterator which removes all elements from the table without freeing the memory.

Iteration starts at the provided iterator’s current location.

It is up to the caller to ensure that the iterator is valid for this `RawTable` and covers all items that remain in the table.

#### `pub unsafe fn into_iter_from(self, iter: RawIter<T>) -> RawIntoIter<T>ⓘ

### Notable traits for RawIntoIter<T>

`impl<T> Iterator for RawIntoIter<T> type Item = T;`
` [src]

Returns an iterator which consumes all elements from the table.

Iteration starts at the provided iterator’s current location.

It is up to the caller to ensure that the iterator is valid for this `RawTable` and covers all items that remain in the table.

### `impl<T: Clone> RawTable<T>` [src]

#### `pub fn clone_from_with_hasher(
&mut self,
source: &Self,
hasher: impl Fn(&T) -> u64
)` [src]

Variant of `clone_from` to use when a hasher is available.

## Trait Implementations

### `impl<T: Clone> Clone for RawTable<T>` [src]

#### `fn clone(&self) -> Self` [src]

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)` [src]

Performs copy-assignment from `source`. Read more

### `impl<T> Drop for RawTable<T>` [src]

#### `fn drop(&mut self)` [src]

Executes the destructor for this type. Read more

### `impl<T> IntoIterator for RawTable<T>` [src]

#### `type Item = T`

The type of the elements being iterated over.

#### `type IntoIter = RawIntoIter<T>`

Which kind of iterator are we turning this into?

#### `fn into_iter(self) -> RawIntoIter<T>ⓘ

### Notable traits for RawIntoIter<T>

`impl<T> Iterator for RawIntoIter<T> type Item = T;`
` [src]

Creates an iterator from a value. Read more

### `impl<T> Send for RawTable<T> where
T: Send,` [src]

### `impl<T> Sync for RawTable<T> where
T: Sync,` [src]

## Auto Trait Implementations

### `impl<T> Unpin for RawTable<T> where
T: Unpin,`

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `pub fn to_owned(&self) -> T` [src]

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

#### `pub fn clone_into(&self, target: &mut T)` [src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

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

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

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

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.