Enum valuable::Slice[][src]

#[non_exhaustive]
pub enum Slice<'a> {
Show 19 variants Bool(&'a [bool]), Char(&'a [char]), F32(&'a [f32]), F64(&'a [f64]), I8(&'a [i8]), I16(&'a [i16]), I32(&'a [i32]), I64(&'a [i64]), I128(&'a [i128]), Isize(&'a [isize]), Str(&'a [&'a str]), String(&'a [String]), U8(&'a [u8]), U16(&'a [u16]), U32(&'a [u32]), U64(&'a [u64]), U128(&'a [u128]), Usize(&'a [usize]), Unit(&'a [()]),
}
Expand description

A slice containing primitive values.

The Slice enum is used to pass multiple primitive-values to the visitor. This is used as an optimization when visiting Listable types to avoid a dynamic dispatch call to Visit for each element in the collection.

Slice instances are usually not created explicitly. Instead, they are created when calling Valuable::visit_slice().

Variants (Non-exhaustive)

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

Bool(&'a [bool])

Tuple Fields

A slice containing bool values.

Examples

use valuable::Slice;

let v = Slice::Bool(&[true, true, false]);

Char(&'a [char])

Tuple Fields

A slice containing char values.

Examples

use valuable::Slice;

let v = Slice::Char(&['a', 'b', 'c']);

F32(&'a [f32])

Tuple Fields

A slice containing f32 values.

Examples

use valuable::Slice;

let v = Slice::F32(&[3.1415, 2.71828]);

F64(&'a [f64])

Tuple Fields

A slice containing f64 values.

Examples

use valuable::Slice;

let v = Slice::F64(&[3.1415, 2.71828]);

I8(&'a [i8])

Tuple Fields

A slice containing i8 values.

Examples

use valuable::Slice;

let v = Slice::I8(&[1, 1, 2, 3, 5]);

I16(&'a [i16])

Tuple Fields

A slice containing i16 values.

Examples

use valuable::Slice;

let v = Slice::I16(&[1, 1, 2, 3, 5]);

I32(&'a [i32])

Tuple Fields

A slice containing I32 values.

Examples

use valuable::Slice;

let v = Slice::I32(&[1, 1, 2, 3, 5]);

I64(&'a [i64])

Tuple Fields

A slice containing I64 values.

Examples

use valuable::Slice;

let v = Slice::I64(&[1, 1, 2, 3, 5]);

I128(&'a [i128])

Tuple Fields

A slice containing I128 values.

Examples

use valuable::Slice;

let v = Slice::I128(&[1, 1, 2, 3, 5]);

Isize(&'a [isize])

Tuple Fields

A slice containing isize values.

Examples

use valuable::Slice;

let v = Slice::Isize(&[1, 1, 2, 3, 5]);

Str(&'a [&'a str])

Tuple Fields

0: &'a [&'a str]

A slice containing str values.

Examples

use valuable::Slice;

let v = Slice::Str(&["foo", "bar", "baz"]);

String(&'a [String])

Tuple Fields

This is supported on crate feature alloc only.

A slice containing String values.

Examples

use valuable::Slice;

let v = Slice::String(&["foo".to_string(), "bar".to_string()]);

U8(&'a [u8])

Tuple Fields

A slice containing u8 values.

Examples

use valuable::Slice;

let v = Slice::U8(&[1, 1, 2, 3, 5]);

U16(&'a [u16])

Tuple Fields

A slice containing u16 values.

Examples

use valuable::Slice;

let v = Slice::U16(&[1, 1, 2, 3, 5]);

U32(&'a [u32])

Tuple Fields

A slice containing u32 values.

Examples

use valuable::Slice;

let v = Slice::U32(&[1, 1, 2, 3, 5]);

U64(&'a [u64])

Tuple Fields

A slice containing u64 values.

Examples

use valuable::Slice;

let v = Slice::U64(&[1, 1, 2, 3, 5]);

U128(&'a [u128])

Tuple Fields

A slice containing u128 values.

Examples

use valuable::Slice;

let v = Slice::U128(&[1, 1, 2, 3, 5]);

Usize(&'a [usize])

Tuple Fields

A slice containing usize values.

Examples

use valuable::Slice;

let v = Slice::Usize(&[1, 1, 2, 3, 5]);

Unit(&'a [()])

Tuple Fields

A slice containing () values.

Examples

use valuable::Slice;

let v = Slice::Unit(&[(), (), ()]);

Implementations

Returns the number of elements in the slice

Examples
use valuable::Slice;

let slice = Slice::U32(&[1, 1, 2, 3, 5]);
assert_eq!(5, slice.len());

Returns true if the slice is not empty.

Examples
use valuable::Slice;

let slice = Slice::U32(&[1, 1, 2, 3, 5]);
assert!(!slice.is_empty());
let slice = Slice::U32(&[]);
assert!(slice.is_empty());

Returns an iterator over the slice.

Examples
use valuable::Slice;

let slice = Slice::U32(&[1, 1, 2, 3, 5]);

for value in slice.iter() {
    println!("{:?}", value);
}

Trait Implementations

Formats the value using the given formatter. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.