2018-08-23 07:53:04 -07:00
|
|
|
/* types/src/preds.rs
|
2017-04-22 09:29:11 -07:00
|
|
|
* Eryn Wells <eryn@erynwells.me>
|
|
|
|
|
*/
|
|
|
|
|
|
2018-08-23 07:53:04 -07:00
|
|
|
//! This module defines several important predicates for determing what kind of
|
|
|
|
|
//! a thing this Object is.
|
|
|
|
|
|
2017-04-22 09:29:11 -07:00
|
|
|
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() }
|
2018-08-20 16:31:10 -07:00
|
|
|
|
2017-04-22 09:29:11 -07:00
|
|
|
/// Should return `true` if this Value is a complex number type.
|
|
|
|
|
fn is_complex(&self) -> bool { self.is_real() }
|
2018-08-20 16:31:10 -07:00
|
|
|
|
2017-04-22 09:29:11 -07:00
|
|
|
/// Should return `true` if this Value is a real number type.
|
|
|
|
|
fn is_real(&self) -> bool { self.is_rational() }
|
2018-08-20 16:31:10 -07:00
|
|
|
|
2017-04-22 09:29:11 -07:00
|
|
|
/// Should return `true` if this Value is a rational number type.
|
|
|
|
|
fn is_rational(&self) -> bool { self.is_integer() }
|
2018-08-20 16:31:10 -07:00
|
|
|
|
2017-04-22 09:29:11 -07:00
|
|
|
/// Should return `true` if this Value is a integer number type.
|
|
|
|
|
fn is_integer(&self) -> bool { false }
|
|
|
|
|
}
|
2018-08-23 07:53:04 -07:00
|
|
|
|
|
|
|
|
pub trait IsPair {
|
|
|
|
|
/// Should return `true` if this Value is a pair.
|
|
|
|
|
fn is_pair(&self) -> bool { false }
|
|
|
|
|
}
|