Comments (2)
Ah, here's an example:
fn foo(s: &str) -> &str {
let bar = |_| { s };
bar(&String::new())
}
The elision rules assign the same lifetime to the input and output of foo
, but if they were to do the same for bar
then the code would fail to compile, because the input to bar
and the output of bar
have different lifetimes.
from rust-blog.
Related Issues (20)
- Is it worth to mention about "Polonious"? HOT 1
- Remove static mut example HOT 8
- subjective issue, idk what title to give HOT 3
- Confuse: lifetime with struct and self. HOT 2
- A potential tweak to common-rust-lifetime-misconceptions HOT 1
- Sized is not an auto trait HOT 1
- PartialEq example isn't right HOT 2
- Paragraph about `T: 'static` is not right HOT 8
- Mention that Read & Write aren't in the prelude when talking about Generic blanket impls HOT 4
- My benchmark results HOT 5
- (nit) Update description of example provided to explain the Clone trait. HOT 1
- Not PostgreSQL but PostgresQL on purpose? HOT 1
- `asymmetry` requirements in `PartialOrd`
- Customer review for Rust on the eve of 2022
- Misconception discussion: T is a superset of both &T and &mut T
- Struct methods can also NOT have elided lifetimes right?
- Request to add extra info: cannot implement both From and TryFrom
- More iteration trait wisdom
- tnanks the series high quality Rust article
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-blog.