Trait tau_engine::Array [−][src]
Expand description
A data type that can be represented as an Array.
This allows more complex array-like data types to be represented in a generic way for use as a
Value.
Implementations
As long as the data type is considered array-like then Array can be implemented on that
type. Below is a contrived example:
use tau_engine::{Array, Value}; // NOTE: Implements Iterator #[derive(Clone)] struct Counter { count: usize, } impl Array for Counter { fn iter(&self) -> Box<dyn Iterator<Item = Value<'_>> + '_> { Box::new(self.clone().map(|v| Value::UInt(v as u64))) } fn len(&self) -> usize { self.clone().count() } }
Required methods
Returns a boxed iterator of Value items.
Example
use std::collections::HashSet; use tau_engine::{Array, Value}; let mut set = HashSet::new(); set.insert(1); let mut value = Array::iter(&set); assert_eq!(value.next().is_some(), true);