[−][src]Enum lexpr::Atom
A Lisp atom.
Atoms represent non-compound data types.
Variants
Nil
The special "nil" value.
This value is used in many Lisp dialects to represent the
empty list. It is different from the empty list in lexpr
;
the latter is represented as a Value::List
with zero
elements.
Bool(bool)
A boolean value.
Number(Number)
A number.
String(String)
A string.
Symbol(String)
A symbol.
Keyword(String)
A keyword.
Methods
impl Atom
[src]
pub fn symbol(name: impl Into<String>) -> Self
[src]
Create an atom representing a symbol.
pub fn keyword(name: impl Into<String>) -> Self
[src]
Create an atom representing a keyword.
pub fn is_nil(&self) -> bool
[src]
Check whether the atom is the special nil value.
pub fn as_nil(&self) -> Option<()>
[src]
If the atom is nil, returns ()
. Returns None
otherwise.
pub fn is_string(&self) -> bool
[src]
Check wether the atom represents a string.
pub fn as_str(&self) -> Option<&str>
[src]
If the atom represents a string, return it as str
reference. Returns None
otherwise.
pub fn is_symbol(&self) -> bool
[src]
Check wether the atom represents a symbol.
pub fn as_symbol(&self) -> Option<&str>
[src]
If the atom represents a symbol, return it as str
reference. Returns None
otherwise.
pub fn is_keyword(&self) -> bool
[src]
Check wether the atom represents a keyword.
pub fn as_keyword(&self) -> Option<&str>
[src]
If the atom represents a keyword, return it as str
reference. Returns None
otherwise.
pub fn is_boolean(&self) -> bool
[src]
Check wether the atom represents a boolean value.
pub fn as_bool(&self) -> Option<bool>
[src]
If the atom is a boolean, return its value.
pub fn as_name(&self) -> Option<&str>
[src]
Get the name of a symbol or keyword, or the value of a string.
pub fn is_i64(&self) -> bool
[src]
Check whether the atom is an integer and can be represented as an i64
.
pub fn as_i64(&self) -> Option<i64>
[src]
If the atom is an integer, represent it as an i64
, if possible.
pub fn is_u64(&self) -> bool
[src]
Check whether the atom is an integer and can be represented as an u64
.
pub fn as_u64(&self) -> Option<u64>
[src]
If the atom is an integer, represent it as an u64
, if possible.
pub fn is_f64(&self) -> bool
[src]
Check whether the atom is a floating point number and can be
represented as an f64
.
Currently this function returns true if and only if both
is_i64
and is_u64
return false but this is not a guarantee
in the future.
pub fn as_f64(&self) -> Option<f64>
[src]
If the atom is a number, represent it as an f64
, if possible.
pub fn as_number(&self) -> Option<&Number>
[src]
If the atom is a number, return a reference to the underlying
Number
instance.
Trait Implementations
impl PartialEq<Atom> for Atom
[src]
impl Clone for Atom
[src]
fn clone(&self) -> Atom
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl From<Atom> for Value
[src]
impl From<u8> for Atom
[src]
impl From<u16> for Atom
[src]
impl From<u32> for Atom
[src]
impl From<u64> for Atom
[src]
impl From<i8> for Atom
[src]
impl From<i16> for Atom
[src]
impl From<i32> for Atom
[src]
impl From<i64> for Atom
[src]
impl From<f32> for Atom
[src]
impl From<f64> for Atom
[src]
impl<'_> From<&'_ str> for Atom
[src]
impl<'a> From<Cow<'a, str>> for Atom
[src]
impl From<String> for Atom
[src]
impl From<bool> for Atom
[src]
impl From<Number> for Atom
[src]
impl Debug for Atom
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,