Add must_use attribute to Coroutine trait · rust-lang/rust@1e445f4 (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit 1e445f4
Add must_use attribute to Coroutine trait
File tree
2 files changed
lines changed
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -69,6 +69,7 @@ pub enum CoroutineState<Y, R> { | ||
69 | 69 | #[lang = "coroutine"] |
70 | 70 | #[unstable(feature = "coroutine_trait", issue = "43122")] |
71 | 71 | #[fundamental] |
72 | +#[must_use = "coroutines are lazy and do nothing unless resumed"] | |
72 | 73 | pub trait Coroutine<R = ()> { |
73 | 74 | /// The type of value this coroutine yields. |
74 | 75 | /// |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -13,7 +13,8 @@ impl Database { | ||
13 | 13 | } |
14 | 14 | |
15 | 15 | fn check_connection(&self) -> impl Coroutine<Yield = (), Return = ()> + '_ { |
16 | -#[coroutine] move | | |
16 | +#[coroutine] | |
17 | +move | | |
17 | 18 | let iter = self.get_connection(); |
18 | 19 | for i in iter { |
19 | 20 | yield i |
@@ -23,5 +24,5 @@ impl Database { | ||
23 | 24 | } |
24 | 25 | |
25 | 26 | fn main() { |
26 | -Database.check_connection(); | |
27 | +let _ = Database.check_connection(); | |
27 | 28 | } |