Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unreachable_code)]
- fn main() {
- println!("{:?}", {
- struct Config<'a> { host: &'a str } fn foo<'a>(config: &'a mut Config<'a>) { let value = serde_json::Value::String("bar.example.".to_owned()); if let Some(string) = value.as_str() { config.host = string; } }
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (/playground)
- error[E0597]: `value` does not live long enough
- --> src/main.rs:6:174
- |
- 6 | struct Config<'a> { host: &'a str } fn foo<'a>(config: &'a mut Config<'a>) { let value = serde_json::Value::String("bar.example.".to_owned()); if let Some(string) = value.as_str() { config.host = string; } }
- | -- ^^^^^ -------------------- - `value` dropped here while still borrowed
- | | | |
- | | | assignment requires that `value` is borrowed for `'a`
- | lifetime `'a` defined here borrowed value does not live long enough
- error: aborting due to previous error
- For more information about this error, try `rustc --explain E0597`.
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement