Struct valuable::NamedValues[][src]

pub struct NamedValues<'a> { /* fields omitted */ }
Expand description

Set of values from a Structable or Enumerable with named fields.

Implementations

Create a new NamedValues instance.

Both fields and values must be the same length.

Panics

The method panics if fields and values are different lengths.

Examples
use valuable::{NamedField, NamedValues, Value};

let fields = [
    NamedField::new("foo"),
    NamedField::new("bar")
];
let values = [
    Value::U32(123),
    Value::U32(456),
];

let named_values = NamedValues::new(&fields, &values);

assert_eq!(
    named_values.get(&fields[0]).unwrap().as_u32(),
    Some(123));

Get a value using a NamedField reference.

Examples
use valuable::{NamedField, NamedValues, Value};

let fields = [
    NamedField::new("foo"),
    NamedField::new("bar")
];
let values = [
    Value::U32(123),
    Value::U32(456),
];

let named_values = NamedValues::new(&fields, &values);

assert_eq!(
    named_values.get(&fields[0]).unwrap().as_u32(),
    Some(123));

Get a value using string.

Examples
use valuable::{NamedField, NamedValues, Value};

let fields = [
    NamedField::new("foo"),
    NamedField::new("bar")
];
let values = [
    Value::U32(123),
    Value::U32(456),
];

let named_values = NamedValues::new(&fields, &values);

assert_eq!(
    named_values.get_by_name("foo").unwrap().as_u32(),
    Some(123));

Iterate all name-value pairs.

Examples
use valuable::{NamedField, NamedValues, Value};

let fields = [
    NamedField::new("foo"),
    NamedField::new("bar")
];
let values = [
    Value::U32(123),
    Value::U32(456),
];

let named_values = NamedValues::new(&fields, &values);

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

Returns the length of fields.

Returns true if fields have a length of 0.

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

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.