43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
/* types/src/preds.rs
|
|
* Eryn Wells <eryn@erynwells.me>
|
|
*/
|
|
|
|
//! This module defines several important predicates for determing what kind of
|
|
//! a thing this Object is.
|
|
|
|
pub trait IsNull {
|
|
/// Is this thing null?
|
|
fn is_null(&self) -> bool { false }
|
|
}
|
|
|
|
pub trait IsBool {
|
|
/// Is this thing a boolean?
|
|
fn is_bool(&self) -> bool { false }
|
|
}
|
|
|
|
pub trait IsChar {
|
|
/// Is this thing a char?
|
|
fn is_char(&self) -> bool { false }
|
|
}
|
|
|
|
pub trait IsNumber {
|
|
/// Is this thing a number?
|
|
fn is_number(&self) -> bool { self.is_complex() || self.is_real() || self.is_rational() || self.is_integer() }
|
|
|
|
/// Should return `true` if this Value is a complex number type.
|
|
fn is_complex(&self) -> bool { self.is_real() }
|
|
|
|
/// Should return `true` if this Value is a real number type.
|
|
fn is_real(&self) -> bool { self.is_rational() }
|
|
|
|
/// Should return `true` if this Value is a rational number type.
|
|
fn is_rational(&self) -> bool { self.is_integer() }
|
|
|
|
/// Should return `true` if this Value is a integer number type.
|
|
fn is_integer(&self) -> bool { false }
|
|
}
|
|
|
|
pub trait IsPair {
|
|
/// Should return `true` if this Value is a pair.
|
|
fn is_pair(&self) -> bool { false }
|
|
}
|