From d9fadbc04f5bbd520e4ce8665ac128288e9846c0 Mon Sep 17 00:00:00 2001 From: Nathaniel Herman Date: Sun, 26 Jan 2014 11:24:34 -0500 Subject: Make mut_last return Option instead of failing on empty vector (and add a test for mut_last) --- src/libsyntax/opt_vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index ce3042cb9cd..c575e170bef 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -62,10 +62,10 @@ impl OptVec { } } - pub fn mut_last<'a>(&'a mut self) -> &'a mut T { + pub fn mut_last<'a>(&'a mut self) -> Option<&'a mut T> { match *self { Vec(ref mut v) => v.mut_last(), - Empty => fail!("mut_last on empty opt_vec") + Empty => None } } -- cgit 1.4.1-3-g733a5