Trait LanguageChildren

Source
pub trait LanguageChildren {
    // Required methods
    fn len(&self) -> usize;
    fn can_be_length(n: usize) -> bool;
    fn from_vec(v: Vec<Id>) -> Self;
    fn as_slice(&self) -> &[Id];
    fn as_mut_slice(&mut self) -> &mut [Id];

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A marker that defines acceptable children types for define_language!.

See define_language! for more details. You should not have to implement this trait.

Required Methods§

Source

fn len(&self) -> usize

Returns the number of children.

Source

fn can_be_length(n: usize) -> bool

Checks if n is an acceptable number of children for this type.

Source

fn from_vec(v: Vec<Id>) -> Self

Create an instance of this type from a Vec<Id>, with the guarantee that can_be_length is already true on the Vec.

Source

fn as_slice(&self) -> &[Id]

Returns a slice of the children Ids.

Source

fn as_mut_slice(&mut self) -> &mut [Id]

Returns a mutable slice of the children Ids.

Provided Methods§

Source

fn is_empty(&self) -> bool

Checks if there are no children.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl LanguageChildren for Box<[Id]>

Source§

fn len(&self) -> usize

Source§

fn can_be_length(_: usize) -> bool

Source§

fn from_vec(v: Vec<Id>) -> Self

Source§

fn as_slice(&self) -> &[Id]

Source§

fn as_mut_slice(&mut self) -> &mut [Id]

Source§

impl LanguageChildren for Vec<Id>

Source§

fn len(&self) -> usize

Source§

fn can_be_length(_: usize) -> bool

Source§

fn from_vec(v: Vec<Id>) -> Self

Source§

fn as_slice(&self) -> &[Id]

Source§

fn as_mut_slice(&mut self) -> &mut [Id]

Source§

impl<const N: usize> LanguageChildren for [Id; N]

Source§

fn len(&self) -> usize

Source§

fn can_be_length(n: usize) -> bool

Source§

fn from_vec(v: Vec<Id>) -> Self

Source§

fn as_slice(&self) -> &[Id]

Source§

fn as_mut_slice(&mut self) -> &mut [Id]

Implementors§