overrider

Crates.iooverrider
lib.rsoverrider
version0.7.0
sourcesrc
created_at2020-05-28 21:46:11.233235
updated_at2020-07-21 15:25:46.292734
descriptionOverride funcitons, methods, and more
homepage
repositoryhttps://github.com/Shizcow/overrider-rs
max_upload_size
id247171
size25,456
Devin Pohl (Shizcow)

documentation

README

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.

Commit count: 64

cargo fmt