diff --git a/solutions/delete_prefix/src/lib.rs b/solutions/delete_prefix/src/lib.rs index 0a23af41..432c6e83 100644 --- a/solutions/delete_prefix/src/lib.rs +++ b/solutions/delete_prefix/src/lib.rs @@ -8,17 +8,7 @@ // delete_prefix("not", "win"); pub fn delete_prefix<'a, 'b>(prefix: &'b str, s: &'a str) -> Option<&'a str> { - if prefix.len() > s.len() { - return None; - } - let mut char_s = s.chars(); - - for char_prefix in prefix.chars() { - if char_prefix != char_s.next()? { - return None; - } - } - Some(&s[prefix.len()..]) + s.strip_prefix(prefix) } #[cfg(test)]