chiark / gitweb /
better
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 14 Nov 2024 20:41:50 +0000 (20:41 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 14 Nov 2024 21:49:40 +0000 (21:49 +0000)
src/lib.rs

index c651a810db9be719a3aaa8fb19f16e84d3fd5251..444317a0775c37705e668d4d262f2d4b1e0fd409 100644 (file)
@@ -31,8 +31,8 @@ pub unsafe trait IsRefToken<'a>: Sized {
 pub unsafe trait IsMutToken<'a>: IsRefToken<'a> + Sized {
     /// Obtain a new ZST token from something that might be a real object.
     #[inline]
-    fn mut_token<'r, 's>(mut self) -> MutToken<'r>
-    where 's: 'r, 'a: 'r,
+    fn mut_token<'r>(mut self) -> MutToken<'r>
+    where 'a: 'r,
     {
         MutToken(PhantomData)
     }
@@ -451,6 +451,7 @@ mod tests {
     #[test]
     fn demo() {
         use list::{List, HeadAndTail};
+        use HeadAndTail as H;
 
         let s = |s: &str| format!("{s}");
 
@@ -460,10 +461,13 @@ mod tests {
         drop(l);
 
         let mut l = List::new();     l.check_consistency();
-        assert_eq!(l.head_and_tail_mut(), HeadAndTail::None);
+        assert_eq!(l.head_and_tail_mut(), H::None);
 
         l.append(s("hi"));           l.check_consistency();
+        assert_eq!(l.head_and_tail_mut(), H::One(&mut s("hi")));
+
         l.append(s("ho"));           l.check_consistency();
+        assert_eq!(l.head_and_tail_mut(), H::Both(&mut s("hi"), &mut s("ho")));
 
         write!(l.front_mut().unwrap(), "!").unwrap();
         assert_eq!(l.pop_front(), Some(s("hi!")));  l.check_consistency();