Add must_use attribute to Coroutine trait
This commit is contained in:
parent
db5704ffca
commit
1e445f48d4
@ -69,6 +69,7 @@ pub enum CoroutineState<Y, R> {
|
||||
#[lang = "coroutine"]
|
||||
#[unstable(feature = "coroutine_trait", issue = "43122")]
|
||||
#[fundamental]
|
||||
#[must_use = "coroutines are lazy and do nothing unless resumed"]
|
||||
pub trait Coroutine<R = ()> {
|
||||
/// The type of value this coroutine yields.
|
||||
///
|
||||
|
@ -13,7 +13,8 @@ fn get_connection(&self) -> impl Iterator<Item = ()> {
|
||||
}
|
||||
|
||||
fn check_connection(&self) -> impl Coroutine<Yield = (), Return = ()> + '_ {
|
||||
#[coroutine] move || {
|
||||
#[coroutine]
|
||||
move || {
|
||||
let iter = self.get_connection();
|
||||
for i in iter {
|
||||
yield i
|
||||
@ -23,5 +24,5 @@ fn check_connection(&self) -> impl Coroutine<Yield = (), Return = ()> + '_ {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Database.check_connection();
|
||||
let _ = Database.check_connection();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user