bundler is both an executable binary that can be run, and a library that can be used in Rust programs.
Installing the bundle
executable
Assuming you have Rust/Cargo installed , run this command in a terminal:
cargo install bundler
It will make the bundle
command available in your PATH
if you"ve allowed the PATH
to be modified when installing Rust . cargo uninstall bundler
uninstalls.
Adding bundler
library as a dependency
Run this command in a terminal, in your project"s directory:
cargo add bundler
To add it manually, edit your project"s Cargo.toml
file and add to the [dependencies]
section:
bundler = "0.1.1"
The bundler
library will be automatically available globally.
Read the bundler
library documentation .
Back to the crate overview .
Readme
rust-bundler
Creates a single-source-file version of a Cargo package.
Features
Replaces extern crate my_lib;
in main.rs
with the contents of lib.rs
.
Expands mod my_mod ;
declarations into mod my_mod { ... }
blocks.
Example
Input:
// src/lib.rs:
mod internal ;
pub use internal:: hello_world;
// src/internal.rs:
pub fn hello_world ( ) {
println! ( " Hello, world!" ) ;
}
// src/main.rs:
extern crate example;
fn main ( ) {
example:: hello_world( ) ;
}
Output:
mod internal {
pub fn hello_world ( ) {
println! ( " Hello, world!" ) ;
}
}
pub use internal:: hello_world;
fn main ( ) {
hello_world ( ) ;
}
More examples in tests/testdata .
Usage
Install:
$ cargo install bundler
Run:
$ bundle path/to/project > output.rs
Library Usage
[ dependencies ]
bundler = " 0.1.1"
extern crate bundler;
fn main ( ) {
let code = bundler:: bundle( " path/to/project" ) ;
println! ( " {} " , code) ;
}
Similar Projects