delegate
Method delegation with less boilerplate
0.13.5
37M downloads/mo
#1472 most downloaded on crates.io
kobzol/rust-delegate
What this package is like to depend on
Last release 9 months ago
17 Nov 2025
Ships fairly regularly
a new release about every 4 months
Most releases are documented
notes for 17 of 27 stable releases
1 version withdrawn
withdrawn after publishing
8 years old
28 releases · first in 2018
1 release in the last 12 months
see the full history below
Release timeline
28 releases · May 2018 to Nov 2025Releases
latest 28-
0.13.517 Nov 2025Release notes
Open source →New features
- Implement support for delegating to fields (#88 from JRRudy1).
Internal
- Start using release-plz for releases, together with crates.io Trusted Publishing.
-
0.13.414 Jul 2025Release notes
Open source →- Do not explicitly forward lifetime arguments when calling delegated functions (https://github.com/Kobzol/rust-delegate/issues/85).
-
0.13.325 Mar 2025Release notes
Open source →- Add
#[const(path::to::Trait::CONST)]attribute to delegate associated constants via a getter (implemented by @vic1707). - Add
#[expr(<$ template>)]attribute to modify delegated call using custom code (implemented by @vic1707).
- Add
-
0.13.214 Jan 2025Release notes
Open source →- Correctly parse attributes with segmented paths (e.g.
#[a::b::c]) (https://github.com/Kobzol/rust-delegate/issues/77).
- Correctly parse attributes with segmented paths (e.g.
-
0.13.109 Oct 2024Release notes
Open source →- Correctly pass generic method type and lifetime arguments to the delegated method.
-
0.13.002 Sep 2024Release notes
Open source →- Generalize match arms handling. You can now combine a match expression target with annotations like
#[into]and others:
struct A; impl A { pub fn callable(self) -> Self { self } } struct B; impl B { pub fn callable(self) -> Self { self } } enum Common { A(A), B(B), } impl From<A> for Common { fn from(inner: A) -> Self { Self::A(inner) } } impl From<B> for Common { fn from(inner: B) -> Self { Self::B(inner) } } impl Common { delegate! { to match self { // ---------- `match` arms have incompatible types Common::A(inner) => inner; Common::B(inner) => inner; } { #[into] pub fn callable(self) -> Self; } } // Generates // pub fn callable(self) -> Self { // match self { // Common::A(inner) => inner.callable().into(), // Common::B(inner) => inner.callable().into(), // } // } }- The crate should be
#[no_std]compatible again (https://github.com/Kobzol/rust-delegate/pull/74).
- Generalize match arms handling. You can now combine a match expression target with annotations like
-
0.12.022 Dec 2023Release notes
Open source →-
Add new
#[newtype]function parameter modifier (#64). Implemented by Techassi -
Allow passing arbitrary attributes to delegation segments:
impl Foo { delegate! { #[inline(always)] to self.0 { ... } } }- Change the default inlining mode from
#[inline(always)]to#[inline](https://github.com/Kobzol/rust-delegate/issues/61).
-
-
0.11.004 Dec 2023Release notes
Open source →- Allow delegating an associated function (not just a method).
struct A {} impl A { fn foo(a: u32) -> u32 { a + 1 } } struct B; impl B { delegate! { to A { fn foo(a: u32) -> u32; } } } -
0.10.029 Jun 2023Release notes
Open source →- Allow specifying certain attributes (e.g.
#[into]or#[unwrap]) on delegated segments. The attribute will then be applied to all methods in that segment (unless it is overwritten on the method itself).
delegate! { #[unwrap] to self.inner { fn foo(&self) -> u32; // calls self.inner.foo().unwrap() fn bar(&self) -> u32; // calls self.inner.bar().unwrap() } }- Add new
#[unwrap]method modifier. Adding it on top of a delegated method will cause the generated code to.unwrap()the result.
#[unwrap] fn foo(&self) -> u32; // foo().unwrap()- Add new
#[through(<trait>)]method modifier. Adding it on top of a delegated method will cause the generated code to call the method through the provided trait using UFCS.
#[through(MyTrait)] delegate! { to &self.inner { #[through(MyTrait)] fn foo(&self) -> u32; // MyTrait::foo(&self.inner) } }- Removed
#[try_into(unwrap)]. It can now be replaced with the combination of#[try_into]and#[unwrap]:
#[try_into] #[unwrap] fn foo(&self) -> u32; // TryInto::try_into(foo()).unwrap()- Add the option to specify explicit type path to the
#[into]expression modifier:
#[into(u64)] fn foo(&self) -> u64; // Into::<u64>::into(foo())- Expression modifiers
#[into],#[try_into]and#[unwrap]can now be used multiple times. The order of their usage dictates in what order they will be applied:
#[into] #[unwrap] fn foo(&self) -> u32; // Into::into(foo()).unwrap() #[unwrap] #[into] fn foo(&self) -> u32; // Into::into(foo().unwrap()) - Allow specifying certain attributes (e.g.
-
0.9.016 Jan 2023Release notes
Open source →- Add new
#[as_ref]function parameter modifier (#47). Implemented by trueegorletov.
- Add new
-
0.8.007 Sep 2022 -
0.7.006 Jun 2022Release notes
Open source →- Add new
#[into]attribute for delegated function parameters. If specified, the parameter will be converted using theFromtrait before being passed as an argument to the called function. - Add new
#[try_from]attribute to delegated functions. You can use it to convert the delegated expression using theTryFromtrait. You can also use#[try_from(unwrap)]to unwrap the result of the conversion.
- Add new
-
0.6.231 Jan 2022Release notes
Open source →- Add new
#[await(true/false)]attribute to delegated functions. You can use it to control whether.awaitwill be appended to the delegated expression. It will be generated by default if the delegation method signature isasync.
- Add new
-
0.6.125 Jul 2021Release notes
Open source →- add support for
asyncfunctions. The delegated call will now use.await.
- add support for
-
0.6.007 Jul 2021Release notes
Open source →- add the option to specify inline expressions that will be used as arguments for the delegated call (https://github.com/kobzol/rust-delegate/pull/34)
- removed
append_argsattribute, which is superseded by the mentioned expression in signature support
-
0.5.215 Jun 2021Release notes
Open source →- add the
append_argsattribute to append attributes to delegated calls (https://github.com/kobzol/rust-delegate/pull/31)
- add the
-
0.5.106 Jan 2021Release notes
Open source →- fix breaking change caused by using
synprivate API (https://github.com/kobzol/rust-delegate/issues/28)
- fix breaking change caused by using
-
0.5.016 Nov 2020 withdrawnRelease notes
Open source →selfcan now be used as the delegation target- Rust 1.46 introduced a change that makes it a bit difficult to use
rust-delegateimplementations generated by macros. If you have this use case, please use this workaround.
-
0.4.319 Jun 2020Nothing published for this version
-
0.4.224 Mar 2020Nothing published for this version
-
0.4.124 Mar 2020Nothing published for this version
-
0.4.028 Jan 2020Nothing published for this version
-
0.3.006 Oct 2019Nothing published for this version
-
0.2.017 Jan 2019Nothing published for this version
-
0.1.331 May 2018Nothing published for this version
-
0.1.219 May 2018Nothing published for this version
-
0.1.119 May 2018Nothing published for this version
-
0.1.019 May 2018Nothing published for this version