Skip to content
Discussion options

You must be logged in to vote

You can do that like this:

pub struct XXService {
    receiver: std::sync::Mutex<Option<Receiver<Result<TailResponse, Status>>>>,
}

impl XXService {
    fn take_receiver(&self) -> Option<Receiver<Result<TailResponse, Status>>> {
        self.receiver.lock().unwrap().take()
    }
}

This method will return the receiver on the first call, and None on any future calls.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@sasakiyori
Comment options

@Darksonn
Comment options

@sasakiyori
Comment options

@Darksonn
Comment options

Answer selected by sasakiyori
@Darksonn
Comment options

@sasakiyori
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants