Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new example - immutable_borrow_lifetime & Correct wrong example #45

Merged
merged 3 commits into from
Nov 29, 2022

Conversation

c0wjay
Copy link
Contributor

@c0wjay c0wjay commented Nov 12, 2022

This example illustrate examples below - from The Rust Programming Language Book

fn main() {
    let string1 = String::from("abcd");
    let string2 = String::from("xyz");

    let result = longest(&string1, &string2);
    println!("The longest string is {}", result);
}

fn longest<'a>(x: &'a String, y: &'a String) -> &'a String {
    if x.len() > y.len() {
        x
    } else {
        y
    }
}

@c0wjay c0wjay changed the title Add new example - immutable_borrow_lifetime Add new example - immutable_borrow_lifetime & Correct wrong example Nov 13, 2022
@c0wjay
Copy link
Contributor Author

c0wjay commented Nov 13, 2022

This PR also includes correction of wrong example in struct_lifetime

@Serenali-1108 Serenali-1108 merged commit 5b2a8b2 into rustviz:master Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants