Skip to content

Commit

Permalink
zb, zm: Don't require an owned header for property accesses.
Browse files Browse the repository at this point in the history
This avoids a useless clone, see also #1179.
  • Loading branch information
emilio committed Dec 26, 2024
1 parent 2181232 commit 31021a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions zbus/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl MyIface {
#[zbus(property)]
fn test_header_prop(
&self,
#[zbus(header)] header: Option<Header<'_>>,
#[zbus(header)] header: Option<&Header<'_>>,
#[zbus(connection)] connection: &Connection,
#[zbus(object_server)] object_server: &ObjectServer,
#[zbus(signal_emitter)] emitter: SignalEmitter<'_>,
Expand All @@ -283,7 +283,7 @@ impl MyIface {
fn set_test_header_prop(
&self,
value: bool,
#[zbus(header)] header: Option<Header<'_>>,
#[zbus(header)] header: Option<&Header<'_>>,
#[zbus(connection)] connection: &Connection,
#[zbus(object_server)] object_server: &ObjectServer,
#[zbus(signal_emitter)] emitter: SignalEmitter<'_>,
Expand Down
4 changes: 1 addition & 3 deletions zbus_macros/src/iface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,7 @@ fn get_args_from_inputs(
let header_arg = &input.pat;

header_arg_decl = match method_type {
MethodType::Property(_) => Some(quote! {
let #header_arg = ::std::option::Option::<&#zbus::message::Header<'_>>::cloned(header);
}),
MethodType::Property(_) => Some(quote! { let #header_arg = header; }),
_ => Some(quote! { let #header_arg = message.header(); }),
};
} else if signal_context || signal_emitter {
Expand Down

0 comments on commit 31021a8

Please sign in to comment.