On Mon, Oct 20, 2014 at 3:57 PM, Jake Scott wrote:
> fn clean<'a>(number: &'a str) -> &'a str {
> if ALPHA_REGEX.is_match(number) {
> "00";
> }
> let clean_number: String = NUMBER_REGEX.replace(number, "");
> return clean_number.as_slice();
> }
FYI, this doesn't do
`clean_number` inside the function `clean` is destructed, and a slice into the
destructed String is returned. You’re probably looking for the `MaybeOwned`
enum in the standard library to do what you want:
http://is.gd/QvkESn
Regards,
- Clark
On Mon, Oct 20, 2014 at 12:57 PM, Jake Sco
Can someone give me a hand, I'm getting the following lifetime error:
error: clean_number does not live long enough
Short url: http://is.gd/VIzHMS
This is the code:
#![feature(phase)]
#[phase(plugin)]
extern crate regex_macros;
extern crate regex;
use regex::Regex;
static ALPHA_REGEX: Regex