my-rust-bingenerate the binary which links to different versions of a lib namedmy_rust_lib, then call the functionpub fn my_rust_lib(left: usize, right: usize) -> usizemy-rust-lib-v1generate the lib namedmy_rust_libin versionv1my-rust-lib-v2generate the lib namedmy_rust_libin versionv2libis the directory which contains the lib ofmy_rust_libin any version
- Copy the library created in folder
my-rust-lib-v1intolib - Build the binary in folder
my-rust-bin
cd my-rust-bin
cargo build --features="v1"
- Validate the binary
- find out the binary
my-rust-binbuilt in foldermy-rust-bin - execute the binary via command
./my-rust-bin,the output should be like below:
my_rust_lib_v1: 8
The return value of my_rust_lib is [8]
- Copy the library created in folder
my-rust-lib-v2intolib - Build the binary in folder
my-rust-bin
cd my-rust-bin
cargo build --features="v2"
- Validate the binary
- find out the binary
my-rust-binbuilt in foldermy-rust-bin - execute the binary via command
./my-rust-bin,the output should be like below:
my_rust_lib_v2: 8
The return value of my_rust_lib is [8]
This rust example is for A practice of rewriting foundation software from C to Rust(2).