error[E0515]: cannot return value referencing local variable `cmd` --> src/main.rs:31:1 | 24 | codeV = re.captures(cmd.as_str()); | --- `cmd` is borrowed here ... 31 | V //Error | ^ returns a value referencing data owned by the current function Playground use regex::Regex...
出现错误: error[E0515]: cannotreturnvalue referencing local variable `parent` --> src/main.rs:19:9 | 17 | let child = Child { parent: &parent }; | --- `parent` is borrowed here 18 | 19 | Combined { parent, child } | ^^^ returns a value referencing data owned by the current ...
return (book, title);}error[E0515]: cannot return value referencing local data `book.title` --> src/main.rs:23:12 |21 | let title = &book.title; | --- `book.title` is borrowed here22 |23 | return (book, title); | ^^^ returns a value referencing data owned by the current ...
struct Thing { count: u32, } struct Combined<'a>(&'a Thing, &'a u32); fn make_combined<'a>() -> Combined<'a> { let thing = &Thing { count: 42 }; // error[E0515]: cannot return value referencing local data `thing.count` // error[E0382]: borrow of moved value: `thing...
// sig.1 = Some(port.as_str());// cannot return value referencing local variable `port` sig.1 = Some(unsafe { extend_string_lifetime(port) }); // sig.1 = Some(unsafe { extend_string_lifetime_1(&port) }); // sig.1 = Some(unsafe { extend_string_lifetime_2(&port) }); ...
get_value()函数是外部代码,所以我无法更改它。 我得到的错误: error[E0515]: cannot return value referencing local variable `v2` --> src\main.rs:517:5 | 517 | foo(&v1, &v2) | ^^^---^ | | | | | `v2` is borrowed here | returns a value referencing data owned by the current...
usestd::Future; asyncfnwith_timeout_and_return() ->implFuture {letf = async {1u32}; pin!(f);// f is now a `Pin<&mut impl Future>`.lets = asyncmove{let_ = timeout(Duration::from_secs(1), &mutf).await; };// error[E0515]: cannot return value referencing local variable `f...
error[E0515]: cannot return value referencing local variable `delim` --> src/lib.rs:41:5|41 | StrSplit::new(s, &delim)| ^ --- `delim` is borrowed here| ___|| |42 | | .next()43 | | .expect("StrSplit should have at least one result")| |___^ returns a value referencing...
在Rust中,函数是一等公民,这意味着函数可以像其他数据类型一样被传递、作为参数传递给其他函数,也可以...
reader.read(3, 4); } } pub fn for_stdin<'a>() -> Container<'dropping_copy_types> { let mut r = io::stdin(); Container::wrap(&mut r as &mut dyn io::Read) //~^ ERROR cannot return value referencing local variable } fn main() { let mut c = for_stdin(); let (Ok(_x...