#override #final #proc-macro #overload

macro overrider

Override funcitons, methods, and more

8 releases (4 breaking)

0.7.0 Jul 21, 2020
0.6.1 Jun 8, 2020
0.5.1 Jun 7, 2020
0.4.0 Jun 1, 2020
0.3.2 May 28, 2020

#1499 in Development tools

GPL-2.0+

26KB
452 lines

overrider-rs

overrider is a set of Rust crates that provide overloading of functions, methods, and more. For example:

// main.rs
use overrider::*;
#[default]
fn foo() {
    println!("Hello World");
}

Calling foo() will print Hello World. However, if an override_default version of foo is defined:

// main.rs
use overrider::*;
#[default]
fn foo() {
    println!("Hello World");
}

#[override_default]
fn foo() {
    println!("Hello Za Warudo");
}

Calling foo() will now print Hello Za Warudo. The first function definition may remain.

Using

Due to limitations in proc_macro, overrider requires the use of two crates:

  • overrider for code in src
  • overrider_build for a build script such as build.rs The code from above shows how to use the overrider crate. Below is how to use the build portion:
// build.rs
use overrider_build::watch_files;
fn main() {
    watch_files!("src/main.rs");
}

For examples, see the git repo.

Dependencies

~1.5MB
~33K SLoC