Add a new trait to ContextElement for Truthiness.
Before I was relying on Loopable to both determine truthiness and get a list of elements to loop over. This will no longer work since I need to only set $idx and $len when iterating over actual arrays, as opposed to all truthy values, so I've finally made truthiness explicit.
This commit is contained in:
@@ -5,10 +5,20 @@ use std::any::Any;
|
||||
use std::{cmp::Ordering, fmt::Debug};
|
||||
|
||||
pub trait ContextElement:
|
||||
Debug + Walkable + Renderable + Loopable + CloneIntoBoxedContextElement + CompareContextElement
|
||||
Debug
|
||||
+ Truthiness
|
||||
+ Walkable
|
||||
+ Renderable
|
||||
+ Loopable
|
||||
+ CloneIntoBoxedContextElement
|
||||
+ CompareContextElement
|
||||
{
|
||||
}
|
||||
|
||||
pub trait Truthiness {
|
||||
fn is_truthy(&self) -> bool;
|
||||
}
|
||||
|
||||
pub trait Walkable {
|
||||
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user