Is it possible to disable Rust lifetime elision?

Is it possible to disable Rust lifetime elision for each file, possibly with #[attribute]?

I learn about life, and I think it can help.

+4
source share
1 answer

Is it possible to disable Rust lifetime elision for each file.

No.

The best alternative I can offer is to request the Clippy function opposite needless_lifetimes, then turn it on. I do not know if such a request will be wanted by other people.

At the same time, you can enable this line and manually verify that it works for each function.


For reference, there are only 3 rules :

  • .

  • , , .

  • , - &self &mut self, self .

, :

, . , , Rust :

  • , lifetime, . , : fn foo<'a>(x: &'a i32), : fn foo<'a, 'b>(x: &'a i32, y: &'b i32) ..

, :

  1. , : fn foo<'a>(x: &'a i32) -> &'a i32.
  2. , &self &mut self, self - . .

, .


, Rust 1.0, , . - 87% , , , . Lifetime elision - .

+5

Source: https://habr.com/ru/post/1664342/


All Articles