NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #1503 most downloaded on crates.io
Method delegation with less boilerplate
Last release 10 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
Implement support for delegating to fields ( #88 from JRRudy1).
Do not explicitly forward lifetime arguments when calling delegated functions (https://github.com/Kobzol/rust-delegate/issues/85).
One column per quarter.
Add #[const(path::Trait::CONST)] attribute to delegate associated constants via a getter (implemented by @vic1707).
#[const(path::to::Trait::CONST)] attribute to delegate associated constants via a getter (implemented by @vic1707).#[expr(<$ template>)] attribute to modify delegated call using custom code (implemented by @vic1707).Correctly parse attributes with segmented paths (e.g. #[a::c]) (https://github.com/Kobzol/rust-delegate/issues/77).
#[a::b::c]) (https://github.com/Kobzol/rust-delegate/issues/77).Correctly pass generic method type and lifetime arguments to the delegated method.
Generalize match arms handling. You can now combine a match expression target with annotations like #[into] and others:
#[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(),
// }
// }
}
#[no_std] compatible again (https://github.com/Kobzol/rust-delegate/pull/74).Add new #[newtype] function parameter modifier (#64). Implemented by Techassi
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 { ... }
}
}
#[inline(always)]
to #[inline] (https://github.com/Kobzol/rust-delegate/issues/61).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;
}
}
}
Allow specifying certain attributes (e.g. #[into] or #[unwrap]) on delegated segments. The attribute will then be applied to all methods in that segme
#[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()
}
}
#[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()
#[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)
}
}
#[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()
#[into] expression modifier:#[into(u64)]
fn foo(&self) -> u64; // Into::<u64>::into(foo())
#[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())
Add new #[as_ref] function parameter modifier (#47). Implemented by trueegorletov.
#[as_ref] function parameter modifier (#47).
Implemented by trueegorletov.Allow simple delegation to enum variants (#45). Implemented by gfreezy.
Add new #[into] attribute for delegated function parameters. If specified, the parameter will be converted using the From trait before being passed as
#[into] attribute for delegated function parameters. If specified, the parameter will be
converted using the From trait before being passed as an argument to the called function.#[try_from] attribute to delegated functions. You can use it to convert the delegated
expression using the TryFrom trait. You can also use #[try_from(unwrap)] to unwrap the result of
the conversion.Add new #[await(true/false)] attribute to delegated functions. You can use it to control whether .await will be appended to the delegated expression.
#[await(true/false)] attribute to delegated functions. You can use it to control whether
.await will be appended to the delegated expression. It will be generated by default if the delegation
method signature is async.add support for async functions. The delegated call will now use .await.
async functions. The delegated call will now use .await.add the option to specify inline expressions that will be used as arguments for the delegated call
append_args attribute, which is superseded by the mentioned expression in signature supportadd the append_args attribute to append attributes to delegated calls
append_args attribute to append attributes to delegated
calls (https://github.com/kobzol/rust-delegate/pull/31)fix breaking change caused by using syn private API
syn private API (https://github.com/kobzol/rust-delegate/issues/28)self can now be used as the delegation target
self can now be used as the delegation targetrust-delegate implementations
generated by macros. If you have this use case, please
use this workaround.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →