pub trait ListValue: RuntimeObject {
// Required methods
fn is_empty(&self, cx: &mut Cx) -> Result<bool>;
fn car(&self, cx: &mut Cx) -> Result<Option<Value>>;
fn cdr(&self, cx: &mut Cx) -> Result<Option<Value>>;
fn len(&self, cx: &mut Cx) -> Result<LengthResult>;
// Provided methods
fn len_cmp(&self, cx: &mut Cx, n: usize) -> Result<Ordering> { ... }
fn get(&self, cx: &mut Cx, index: usize) -> Result<Option<Value>> { ... }
fn for_each(
&self,
cx: &mut Cx,
limit: Option<usize>,
visit: &mut dyn FnMut(&Value),
) -> Result<()> { ... }
fn to_vec(&self, cx: &mut Cx, limit: Option<usize>) -> Result<Vec<Value>> { ... }
fn cdr_self(&self, _cx: &mut Cx) -> Result<Option<Value>> { ... }
fn as_self_value(&self) -> Option<Value> { ... }
}Expand description
Shared behaviour for every list backend.
Required Methods§
Sourcefn cdr(&self, cx: &mut Cx) -> Result<Option<Value>>
fn cdr(&self, cx: &mut Cx) -> Result<Option<Value>>
The tail list after the first element, or Ok(None) when empty.
Sourcefn len(&self, cx: &mut Cx) -> Result<LengthResult>
fn len(&self, cx: &mut Cx) -> Result<LengthResult>
The length, finite or LengthResult::Unknown for endless lists.
Provided Methods§
Sourcefn len_cmp(&self, cx: &mut Cx, n: usize) -> Result<Ordering>
fn len_cmp(&self, cx: &mut Cx, n: usize) -> Result<Ordering>
Compares the spine length against n without fully forcing the list.
Sourcefn get(&self, cx: &mut Cx, index: usize) -> Result<Option<Value>>
fn get(&self, cx: &mut Cx, index: usize) -> Result<Option<Value>>
The element at index, or Ok(None) when out of range.
Sourcefn for_each(
&self,
cx: &mut Cx,
limit: Option<usize>,
visit: &mut dyn FnMut(&Value),
) -> Result<()>
fn for_each( &self, cx: &mut Cx, limit: Option<usize>, visit: &mut dyn FnMut(&Value), ) -> Result<()>
Visits up to limit elements in order, walking the list spine.
Sourcefn to_vec(&self, cx: &mut Cx, limit: Option<usize>) -> Result<Vec<Value>>
fn to_vec(&self, cx: &mut Cx, limit: Option<usize>) -> Result<Vec<Value>>
Collects up to limit elements into a vector.
Sourcefn cdr_self(&self, _cx: &mut Cx) -> Result<Option<Value>>
fn cdr_self(&self, _cx: &mut Cx) -> Result<Option<Value>>
The value to start spine walks from; the receiver itself by default.
Sourcefn as_self_value(&self) -> Option<Value>
fn as_self_value(&self) -> Option<Value>
The receiver re-wrapped as a Value, when it can produce one.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".