summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 162c30c..db88a69 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -522,24 +522,6 @@ Now with explicit outputs:
522 } 522 }
523 } 523 }
524 524
525 impl<'a> MappedList<'a> for Vec<Item> {
526 fn get_index(&'a self, id: usize) -> Option<MappedValue<'a>> {
527 if let Some(x) = self.get(id) {
528 Some(MappedValue::<'a>::Struct(x))
529 } else {
530 None
531 }
532 }
533
534 fn for_each(&'a self, func: &dyn Fn(&MappedValue<'a>, &mut String) -> CrimResult<()>) -> CrimResult<String> {
535 let mut buf = String::new();
536 for i in self {
537 func( &MappedValue::Struct(i), &mut buf )?;
538 }
539 Ok(buf)
540 }
541 }
542
543 #[test] 525 #[test]
544 fn custom() -> Result<(), CrimError> { 526 fn custom() -> Result<(), CrimError> {
545 let page = Page::new(); 527 let page = Page::new();
@@ -552,9 +534,10 @@ Now with explicit outputs:
552 l.for_each(&|x: &MappedValue, buf: &mut String| { 534 l.for_each(&|x: &MappedValue, buf: &mut String| {
553 if let MappedValue::Struct(s) = x { 535 if let MappedValue::Struct(s) = x {
554 println!(" - {:?}", s.get_value(&"title")); 536 println!(" - {:?}", s.get_value(&"title"));
537 buf.push_str(&format!("{:?}",s.get_value(&"title")));
555 } 538 }
556 Ok(()) 539 Ok(())
557 }); 540 }).expect("loop");
558 } 541 }
559 Ok(()) 542 Ok(())
560 } 543 }