[types] Clean up Object a little, add default implementations
This commit is contained in:
parent
31081ba5a9
commit
1a3b7adc5a
3 changed files with 5 additions and 4 deletions
|
@ -28,9 +28,12 @@ pub trait Object:
|
|||
fmt::Debug +
|
||||
fmt::Display
|
||||
{
|
||||
/// Cast this Object to an Any.
|
||||
fn as_any(&self) -> &Any;
|
||||
fn as_pair(&self) -> Option<&Pair>;
|
||||
fn as_sym(&self) -> Option<&Sym>;
|
||||
/// Cast this Object to a Pair if possible.
|
||||
fn as_pair(&self) -> Option<&Pair> { None }
|
||||
/// Cast this Object to a Sym if possible.
|
||||
fn as_sym(&self) -> Option<&Sym> { None }
|
||||
}
|
||||
|
||||
impl Obj {
|
||||
|
|
|
@ -43,7 +43,6 @@ impl Pair {
|
|||
impl Object for Pair {
|
||||
fn as_any(&self) -> &Any { self }
|
||||
fn as_pair(&self) -> Option<&Pair> { Some(self) }
|
||||
fn as_sym(&self) -> Option<&Sym> { None }
|
||||
}
|
||||
|
||||
impl fmt::Display for Pair {
|
||||
|
|
|
@ -24,7 +24,6 @@ impl Sym {
|
|||
|
||||
impl Object for Sym {
|
||||
fn as_any(&self) -> &Any { self }
|
||||
fn as_pair(&self) -> Option<&Pair> { None }
|
||||
fn as_sym(&self) -> Option<&Sym> { Some(self) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue