diff --git a/src/lib.rs b/src/lib.rs index 422620c..4cb9d61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -516,17 +516,17 @@ impl NonEmpty { /// /// // Guaranteed to have the last element and the elements /// // preceding it. - /// assert_eq!(non_empty.split(), (&1, &[2, 3, 4][..], &5)); + /// assert_eq!(non_empty.split(), (&1, &[2, 3, 4][..], Some(&5))); /// /// let non_empty = NonEmpty::new(1); /// /// // Guaranteed to have the last element. - /// assert_eq!(non_empty.split(), (&1, &[][..], &1)); + /// assert_eq!(non_empty.split(), (&1, &[][..], None)); /// ``` - pub fn split(&self) -> (&T, &[T], &T) { + pub fn split(&self) -> (&T, &[T], Option<&T>) { match self.tail.split_last() { - None => (&self.head, &[], &self.head), - Some((last, middle)) => (&self.head, middle, last), + None => (&self.head, &[], None), + Some((last, middle)) => (&self.head, middle, Some(last)), } }