Compare commits
1 Commits
with-lifet
...
c3f1b7b230
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3f1b7b230 |
11
Readme.md
11
Readme.md
@@ -1,11 +0,0 @@
|
|||||||
# Small project to somewhat better understand lifetimes.
|
|
||||||
|
|
||||||
This small project aims to help understanding how lifetimes work in rust a little better.
|
|
||||||
|
|
||||||
Swap branches to see difference without specifying lifetimes, with lifetimes and then a simplified version.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# youtube
|
|
||||||
|
|
||||||
Heavily inspired by the following video: https://www.youtube.com/watch?v=gRAVZv7V91Q
|
|
||||||
@@ -6,11 +6,7 @@ fn main() {
|
|||||||
println!("The longest string is {result}");
|
println!("The longest string is {result}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn longest<'a, 'b, 'out>(a: &'a str, b: &'b str) -> &'out str
|
fn longest<'a>(a: &'a str, b: &'a str) -> &'a str {
|
||||||
where
|
|
||||||
'a: 'out,
|
|
||||||
'b: 'out,
|
|
||||||
{
|
|
||||||
if a.len() > b.len() {
|
if a.len() > b.len() {
|
||||||
a
|
a
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user