GitHunt
SU

sugar700/extension-trait

extension-trait

A macro to declare extension traits - a trait that is created to add
methods to an external type.

Example

#[macro_use]
extern crate extension_trait;

#[extension_trait]
pub impl DoubleExt for str {
   fn double(&self) -> String {
       self.repeat(2)
   }
}

fn main() {
    assert_eq!("Hello".double(), "HelloHello");
}

Languages

Rust100.0%

Contributors

Apache License 2.0
Created November 4, 2017
Updated April 2, 2025