Compare commits
1 Commits
c3f1b7b230
...
no-lifetim
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3dd76c0dfd |
11
Readme.md
Normal file
11
Readme.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# 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,7 +6,7 @@ fn main() {
|
||||
println!("The longest string is {result}");
|
||||
}
|
||||
|
||||
fn longest<'a>(a: &'a str, b: &'a str) -> &'a str {
|
||||
fn longest(a: &str, b: &str) -> &str {
|
||||
if a.len() > b.len() {
|
||||
a
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user