#gamedev #inline #tool #tweak

inline_tweak

Tweak values directly from the source code

9 stable releases

1.0.9 Apr 17, 2023
1.0.8 Sep 18, 2020
1.0.2 Aug 30, 2020

#58 in Configuration

Download history 175/week @ 2023-06-06 193/week @ 2023-06-13 253/week @ 2023-06-20 290/week @ 2023-06-27 313/week @ 2023-07-04 207/week @ 2023-07-11 409/week @ 2023-07-18 295/week @ 2023-07-25 278/week @ 2023-08-01 229/week @ 2023-08-08 262/week @ 2023-08-15 241/week @ 2023-08-22 182/week @ 2023-08-29 213/week @ 2023-09-05 187/week @ 2023-09-12 160/week @ 2023-09-19

763 downloads per month
Used in 4 crates (2 directly)

CC0 license

13KB
214 lines

inline_tweak

Crates.io

inline_tweak is based on this blogpost by tuxedo labs.

Tweak any literal directly from your code, changes to the source appear while running the program.
It works by parsing the file when a change occurs.

The library is minimal, only requiring the lazy_static dependency to hold modified values.
In release mode, the tweaking code is disabled and compiled away.

Usage

use inline_tweak::*;

fn main() {
    loop {
        println!("{}", tweak!(3.14)); // Try changing the value while the application is running
    }
}

Extra features

watch!

inline_tweak provides a watch!() macro that sleeps until the file is modified, akin to a breakpoint:

use inline_tweak::*;

fn main() {
    loop {
        println!("{}", tweak!("hello world"));
        watch!(); // The thread will sleep here until anything in the file changes
    }
}

Expressions

inline_tweak allows to tweak expressions by providing a value later. For example:

tweak!(rng.gen_range(0.0, 1.0))

can then be replaced by a constant value by modifying the file (even while the application is running) to

tweak!(5.0; rng.gen_range(0.0, 1.0)) // will always return 5.0

See the "expression" example in action

Note that this works only for expressions that return a tweakable type. (number/boolean literals)

release_tweak!

The release_tweak! macro acts exactly like tweak! except that it also works in release mode.
It is accessible behind the feature flag "release_tweak" which is not enabled by default.

Installation

Simply add this line to your Cargo.toml

inline_tweak = "1.0.8"

Dependencies

~11KB