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

Dangling lifetimes #11

Merged
merged 2 commits into from
Aug 13, 2024
Merged

Conversation

kornelski
Copy link
Contributor

Functions like fn as_bytes<'a>(&self) -> &'a [u8] are dangerous, because Rust can implicitly give 'a any lifetime, including 'static.

For this reason, where it's necessary, I gave it scarier name. In other cases I've used '_ instead, which has a safer default (borrows from the reference arg), and can't become a footgun by forgetting 'a in &'a self.

I've also used less powerful casts where possible.

@ObsidianMinor ObsidianMinor merged commit b567b9d into cloudflare:main Aug 13, 2024
1 check passed
@kornelski kornelski deleted the dangling_lifetimes branch August 15, 2024 14:37
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.

2 participants