Created
August 25, 2019 17:04
-
-
Save rust-play/4de7a49deb3214c9f3249847bbe0f281 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unreachable_code)] | |
fn main() { | |
println!("{:?}", { | |
fn breed_cow<'a, 'b>(a: std::borrow::Cow<'a, str>) -> std::borrow::Cow<'b, str> { a.clone() } | |
}); | |
} | |
/* ~~~~=== stderr ===~~~~ | |
Compiling playground v0.0.1 (/playground) | |
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements | |
--> src/main.rs:6:93 | |
| | |
6 | fn breed_cow<'a, 'b>(a: std::borrow::Cow<'a, str>) -> std::borrow::Cow<'b, str> { a.clone() } | |
| ^^^^^ | |
| | |
note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 6:22... | |
--> src/main.rs:6:22 | |
| | |
6 | fn breed_cow<'a, 'b>(a: std::borrow::Cow<'a, str>) -> std::borrow::Cow<'b, str> { a.clone() } | |
| ^^ | |
= note: ...so that the types are compatible: | |
expected &std::borrow::Cow<'_, str> | |
found &std::borrow::Cow<'a, str> | |
note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 6:26... | |
--> src/main.rs:6:26 | |
| | |
6 | fn breed_cow<'a, 'b>(a: std::borrow::Cow<'a, str>) -> std::borrow::Cow<'b, str> { a.clone() } | |
| ^^ | |
= note: ...so that the expression is assignable: | |
expected std::borrow::Cow<'b, _> | |
found std::borrow::Cow<'_, _> | |
error: aborting due to previous error | |
error: Could not compile `playground`. | |
To learn more, run the command again with --verbose. | |
*/ | |
/* ~~~~=== stdout ===~~~~ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment