Finished creating WalkError.
This commit is contained in:
parent
f2f6404017
commit
05b56e83a9
@ -291,52 +291,43 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<I: ContextElement> Walkable for HashMap<&str, I> {
|
impl<I: ContextElement> Walkable for HashMap<&str, I> {
|
||||||
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, RenderError> {
|
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError> {
|
||||||
let child = self.get(segment).ok_or(RenderError::CantWalk {
|
let child = self.get(segment).ok_or(WalkError::CantWalk)?;
|
||||||
segment: segment.to_string(),
|
|
||||||
elem: self,
|
|
||||||
})?;
|
|
||||||
Ok(child)
|
Ok(child)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Walkable for &str {
|
impl Walkable for &str {
|
||||||
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, RenderError> {
|
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError> {
|
||||||
Err(RenderError::CantWalk {
|
Err(WalkError::CantWalk)
|
||||||
segment: segment.to_string(),
|
|
||||||
elem: self,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Walkable for u32 {
|
impl Walkable for u32 {
|
||||||
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, RenderError> {
|
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError> {
|
||||||
Err(RenderError::CantWalk {
|
Err(WalkError::CantWalk)
|
||||||
segment: segment.to_string(),
|
|
||||||
elem: self,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Loopable for &str {
|
impl Loopable for &str {
|
||||||
fn get_loop_elements(&self) -> Result<Vec<&dyn ContextElement>, RenderError> {
|
fn get_loop_elements(&self) -> Vec<&dyn ContextElement> {
|
||||||
if self.is_empty() {
|
if self.is_empty() {
|
||||||
Ok(Vec::new())
|
Vec::new()
|
||||||
} else {
|
} else {
|
||||||
Ok(vec![self])
|
vec![self]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Loopable for u32 {
|
impl Loopable for u32 {
|
||||||
fn get_loop_elements(&self) -> Result<Vec<&dyn ContextElement>, RenderError> {
|
fn get_loop_elements(&self) -> Vec<&dyn ContextElement> {
|
||||||
Ok(vec![self])
|
vec![self]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: ContextElement> Loopable for HashMap<&str, I> {
|
impl<I: ContextElement> Loopable for HashMap<&str, I> {
|
||||||
fn get_loop_elements(&self) -> Result<Vec<&dyn ContextElement>, RenderError> {
|
fn get_loop_elements(&self) -> Vec<&dyn ContextElement> {
|
||||||
Ok(vec![self])
|
vec![self]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user