Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use idiomatic method for writing Option and accessing inner T #1034

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions async-nats/src/jetstream/consumer/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ impl<'a> futures::Stream for Sequence<'a> {
let request = self.request.clone();
let pending_messages = self.pending_messages;

self.next = Some(Box::pin(async move {
let next = self.next.insert(Box::pin(async move {
let inbox = context.client.new_inbox();
let subscriber = context
.client
Expand All @@ -484,7 +484,7 @@ impl<'a> futures::Stream for Sequence<'a> {
})
}));

match self.next.as_mut().unwrap().as_mut().poll(cx) {
match next.as_mut().poll(cx) {
Poll::Ready(result) => {
self.next = None;
Poll::Ready(Some(result.map_err(|err| {
Expand Down
21 changes: 11 additions & 10 deletions async-nats/src/jetstream/consumer/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,16 +578,17 @@ impl<'a> futures::Stream for Ordered<'a> {
let sequence = self.stream_sequence.clone();
let config = self.consumer.config.clone();
let stream_name = self.consumer.info.stream_name.clone();
self.subscriber_future = Some(Box::pin(async move {
recreate_consumer_and_subscription(
context,
config,
stream_name,
sequence.load(Ordering::Relaxed),
)
.await
}));
match self.subscriber_future.as_mut().unwrap().as_mut().poll(cx) {
let subscriber_future =
self.subscriber_future.insert(Box::pin(async move {
recreate_consumer_and_subscription(
context,
config,
stream_name,
sequence.load(Ordering::Relaxed),
)
.await
}));
match subscriber_future.as_mut().poll(cx) {
Poll::Ready(subscriber) => {
self.subscriber_future = None;
self.subscriber = Some(subscriber.map_err(|err| {
Expand Down
Loading