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

Error handling slides (3) shows 'static lifetime and lifetimes have not been talked about #57

Open
amanjeev opened this issue Jun 8, 2023 · 2 comments

Comments

@amanjeev
Copy link
Member

amanjeev commented Jun 8, 2023

Where

Slide 3 of Error handling

What

Error handling slides (3) shows 'static lifetime and lifetimes have not been talked about yet in the course. It makes it harder to introduce this? Which is basically "ignore this". Maybe it is ok but still worth this ticket.

fn literals() -> Result<(), &'static str> { // <-- lifetime here
    Err("oh no")
}
fn strings() -> Result<(), String> {
    Err(String::from("oh no"))
}
fn enums() -> Result<(), Error> {
    Err(Error::BadThing)
}

enum Error { BadThing, OtherThing }

Fix

Maybe use something that does not have a lifetime.

@jonathanpallant
Copy link
Member

Yeah but at some point they're going to try and use string literals, and they need to know it's painful.

We covered this with an apology and said "don't worry about the details, this is unfortunately how you have to specify string literal in Rust as a type"

@jonathanpallant
Copy link
Member

Dupe of #53?

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

No branches or pull requests

2 participants