Skip to content

mcu-rust/sync-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sync-code

CI Crates.io Docs.rs License Downloads

sync-code synchronizes code blocks across different files, providing a clear alternative to macros in certain scenarios.
When duplication is limited but the design is complex (for example, involving generics), macros often reduce readability and make maintenance harder.
By using sync-code instead, the code remains straightforward and maintainable, while development tools such as Go-to-definition and intelligent auto-completion continue to work as expected.

Usage

Run command:

cargo add --build sync-code

See crate.

build.rs:

fn main() {
    sync_code::Builder::new()
        .add("src/target1.rs", "src/source1.rs")
        .add("src/target2.rs", "src/source2.rs")
        .sync();
}

your_code.rs:

// $sync block_name

fn code_you_want_to_sync() {
}

// $sync end

See also tests.

🔖 Keywords

sync-code · rust · code generation · macro replacement · generics · readability · maintainability · developer tools

About

Synchronizes code blocks across different files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages