PackageTrack
Sign in Get early access

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 2025
2019 2020 2021 2022 2023 2024 2025 2026
Release Pre-release Withdrawn

Releases

latest 28
  1. 0.13.5 17 Nov 2025
    Release notes

    New features

    • Implement support for delegating to fields (#88 from JRRudy1).

    Internal

    • Start using release-plz for releases, together with crates.io Trusted Publishing.
    Open source →
  2. 0.13.4 14 Jul 2025
    Release notes
    • Do not explicitly forward lifetime arguments when calling delegated functions (https://github.com/Kobzol/rust-delegate/issues/85).
    Open source →
  3. 0.13.3 25 Mar 2025
    Release notes
    • 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).
    Open source →
  4. 0.13.2 14 Jan 2025
    Release notes
    • Correctly parse attributes with segmented paths (e.g. #[a::b::c]) (https://github.com/Kobzol/rust-delegate/issues/77).
    Open source →
  5. 0.13.1 09 Oct 2024
    Release notes
    • Correctly pass generic method type and lifetime arguments to the delegated method.
    Open source →
  6. 0.13.0 02 Sep 2024
    Release notes
    • 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).
    Open source →
  7. 0.12.0 22 Dec 2023
    Release notes
    • 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).
    Open source →
  8. 0.11.0 04 Dec 2023
    Release notes
    • 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;
            }
        }
    }
    
    Open source →
  9. 0.10.0 29 Jun 2023
    Release notes
    • 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())
    
    Open source →
  10. 0.9.0 16 Jan 2023
    Release notes
    • Add new #[as_ref] function parameter modifier (#47). Implemented by trueegorletov.
    Open source →
  11. 0.8.0 07 Sep 2022
    Release notes
    • Allow simple delegation to enum variants (#45). Implemented by gfreezy.
    Open source →
  12. 0.7.0 06 Jun 2022
    Release notes
    • Add new #[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.
    • Add new #[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.
    Open source →
  13. 0.6.2 31 Jan 2022
    Release notes
    • Add new #[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.
    Open source →
  14. 0.6.1 25 Jul 2021
    Release notes
    • add support for async functions. The delegated call will now use .await.
    Open source →
  15. 0.6.0 07 Jul 2021
    Release notes
    • 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_args attribute, which is superseded by the mentioned expression in signature support
    Open source →
  16. 0.5.2 15 Jun 2021
    Release notes
    • add the append_args attribute to append attributes to delegated calls (https://github.com/kobzol/rust-delegate/pull/31)
    Open source →
  17. 0.5.1 06 Jan 2021
    Release notes
    • fix breaking change caused by using syn private API (https://github.com/kobzol/rust-delegate/issues/28)
    Open source →
  18. 0.5.0 16 Nov 2020 withdrawn
    Release notes
    • self can now be used as the delegation target
    • Rust 1.46 introduced a change that makes it a bit difficult to use rust-delegate implementations generated by macros. If you have this use case, please use this workaround.
    Open source →
  19. 0.4.3 19 Jun 2020

    Nothing published for this version

  20. 0.4.2 24 Mar 2020

    Nothing published for this version

  21. 0.4.1 24 Mar 2020

    Nothing published for this version

  22. 0.4.0 28 Jan 2020

    Nothing published for this version

  23. 0.3.0 06 Oct 2019

    Nothing published for this version

  24. 0.2.0 17 Jan 2019

    Nothing published for this version

  25. 0.1.3 31 May 2018

    Nothing published for this version

  26. 0.1.2 19 May 2018

    Nothing published for this version

  27. 0.1.1 19 May 2018

    Nothing published for this version

  28. 0.1.0 19 May 2018

    Nothing published for this version

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive