Struct memtable::list::FixedList [−][src]
Expand description
Represents a fixed list that can grow up to a specific capacity N
Methods from Deref<Target = [T; N]>
🔬 This is a nightly-only experimental API. (array_methods
)
array_methods
)Returns a slice containing the entire array. Equivalent to &s[..]
.
🔬 This is a nightly-only experimental API. (array_methods
)
array_methods
)Returns a mutable slice containing the entire array. Equivalent to
&mut s[..]
.
🔬 This is a nightly-only experimental API. (array_methods
)
array_methods
)Borrows each element and returns an array of references with the same
size as self
.
Example
#![feature(array_methods)] let floats = [3.1, 2.7, -1.0]; let float_refs: [&f64; 3] = floats.each_ref(); assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);
This method is particularly useful if combined with other methods, like
map
. This way, you can avoid moving the original
array if its elements are not Copy
.
#![feature(array_methods, array_map)] let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()]; let is_ascii = strings.each_ref().map(|s| s.is_ascii()); assert_eq!(is_ascii, [true, false, true]); // We can still access the original array: it has not been moved. assert_eq!(strings.len(), 3);
🔬 This is a nightly-only experimental API. (array_methods
)
array_methods
)Borrows each element mutably and returns an array of mutable references
with the same size as self
.
Example
#![feature(array_methods)] let mut floats = [3.1, 2.7, -1.0]; let float_refs: [&mut f64; 3] = floats.each_mut(); *float_refs[0] = 0.0; assert_eq!(float_refs, [&mut 0.0, &mut 2.7, &mut -1.0]); assert_eq!(floats, [0.0, 2.7, -1.0]);
Trait Implementations
impl<'de, T, const N: usize> Deserialize<'de> for FixedList<T, N> where
T: Default + Deserialize<'de>,
impl<'de, T, const N: usize> Deserialize<'de> for FixedList<T, N> where
T: Default + Deserialize<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<FixedList<T, N>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<FixedList<T, N>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Will make a list that fills up to N, and any additional elements not filled in using the function will be completed with the default value; when the function returns None, the default value will also be used
type Item = T
type Item = T
Represents the type of item within the list
Returns the maximum capacity of the list
Returns the actual length of the list, which may be less than the actual capacity Read more
Returns a reference to an element found at the given index, or None if no element found Read more
Returns a mutable reference to an element found at the given index, or None if no element found Read more
Inserts an element at position index
within the vector, shifting all
elements after it to the right Read more
Removes and returns the element at position index
within the vector,
shifting all elements after it to the left. Read more
impl<T, const N: usize> PartialOrd<[T; N]> for FixedList<T, N> where
T: PartialOrd<T> + Default,
impl<T, const N: usize> PartialOrd<[T; N]> for FixedList<T, N> where
T: PartialOrd<T> + Default,
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
impl<T, const N: usize> PartialOrd<FixedList<T, N>> for FixedList<T, N> where
T: PartialOrd<T> + Default,
impl<T, const N: usize> PartialOrd<FixedList<T, N>> for FixedList<T, N> where
T: PartialOrd<T> + Default,
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub 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
Auto Trait Implementations
impl<T, const N: usize> RefUnwindSafe for FixedList<T, N> where
T: RefUnwindSafe,
impl<T, const N: usize> UnwindSafe for FixedList<T, N> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more