Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::str::Chars;
- fn main() {
- let foo = Foo::new();
- }
- struct Foo<'a> {
- chars: Chars<'a>
- }
- impl<'a> Foo<'a> {
- pub fn new() -> Self {
- let s = "value".to_string();
- Foo { chars: s.chars() }
- }
- }
- error: `s` does not live long enough
- --> <anon>:13:22
- 13 |> Foo { chars: s.chars() }
- |> ^
- note: reference must be valid for the lifetime 'a as defined on the block at 11:25...
- --> <anon>:11:26
- 11 |> pub fn new() -> Self {
- |> ^
- note: ...but borrowed value is only valid for the block suffix following statement 0 at 12:36
- --> <anon>:12:37
- 12 |> let s = "value".to_string();
- |>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement