Trait lexpr::number::Visitor

source ·
pub trait Visitor {
    type Value;
    type Error;

    // Required methods
    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>;
}
Expand description

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.

Required Associated Types§

source

type Value

The return type of the visitor methods.

source

type Error

The error type of the visitor methods.

Required Methods§

source

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

Construct an error given a message.

This method is used by trait default implementations.

source

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

The stored value is a u64.

source

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

The stored value is an i64.

source

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

The stored value is f64.

Implementors§