Trait valuable::Tuplable[][src]

pub trait Tuplable: Valuable {
    fn definition(&self) -> TupleDef;
}
Expand description

A tuple-like Valuable sub-type.

Implemented by Valuable types that have a tuple-like shape. Fields are always unnamed. Values that implement Tuplable must return Value::Tuplable from their Valuable::as_value implementation.

It is uncommon for users to implement this type as the crate provides implementations of Tuplable for Rust tuples.

Inspecting

Inspecting fields contained by a Tuplable instance is done by visiting the tuple. When visiting a Tuple, the visit_unnamed_fields() method is called. When the tuple is statically defined, visit_unnamed_fields() is called once with the values of all the fields. A dynamic tuple implementation may call visit_unnamed_fields() multiple times.

Required methods

Returns the tuple’s definition.

See TupleDef documentation for more details.

Examples
use valuable::{Tuplable, TupleDef};

let tuple = (123, "hello");

if let TupleDef::Static { fields, .. } = tuple.definition() {
    assert_eq!(2, fields);
}

Trait Implementations

Formats the value using the given formatter. Read more

A tuple value

Examples

use valuable::{Value, Valuable};

let my_tuple = (123, 456);
let v = Value::Tuplable(&my_tuple);

Performs the conversion.

Implementations on Foreign Types

Implementors