[][src]Trait lexpr::number::Visitor

pub trait Visitor {
    type Value;
    type Error;
    fn error<T: Into<String>>(msg: T) -> Self::Error;
fn visit_u64(self, n: u64) -> Result<Self::Value, Self::Error>;
fn visit_i64(self, n: i64) -> Result<Self::Value, Self::Error>;
fn visit_f64(self, n: f64) -> Result<Self::Value, Self::Error>; }

Trait to access the value stored in Number.

The Number type does not directly expose its internal structure to allow future changes without breaking the API.

Instead, you can implement this trait and pass your implementation to Number::visit.

Associated Types

type Value

The return type of the visitor methods.

type Error

The error type of the visitor methods.

Loading content...

Required methods

fn error<T: Into<String>>(msg: T) -> Self::Error

Construct an error given a message.

This method is used by trait default implementations.

fn visit_u64(self, n: u64) -> Result<Self::Value, Self::Error>

The stored value is a u64.

fn visit_i64(self, n: i64) -> Result<Self::Value, Self::Error>

The stored value is an i64.

fn visit_f64(self, n: f64) -> Result<Self::Value, Self::Error>

The stored value is f64.

Loading content...

Implementors

Loading content...