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

Remove clone in message split method #1172

Merged
merged 1 commit into from
Dec 7, 2023
Merged
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
6 changes: 3 additions & 3 deletions async-nats/src/jetstream/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::Error;
use bytes::Bytes;
use futures::future::TryFutureExt;
use futures::StreamExt;
use std::time::Duration;
use std::{mem, time::Duration};
use time::OffsetDateTime;

#[derive(Clone, Debug)]
Expand All @@ -45,8 +45,8 @@ impl Message {
/// Splits [Message] into [Acker] and [crate::Message].
/// This can help reduce memory footprint if [Message] can be dropped before acking,
/// for example when it's transformed into another structure and acked later
pub fn split(self) -> (crate::Message, Acker) {
let reply = self.message.reply.clone();
pub fn split(mut self) -> (crate::Message, Acker) {
let reply = mem::take(&mut self.message.reply);
(
self.message,
Acker {
Expand Down