rust_bundler_cp

Crates.iorust_bundler_cp
lib.rsrust_bundler_cp
version0.3.16
sourcesrc
created_at2021-08-10 07:12:21.374549
updated_at2023-09-26 00:48:54.174577
descriptionCreates a single-source-file version of a Cargo package. This single file can be submitted for competitive programming then. Concentrating on codeforces.com now.
homepagehttps://github.com/Endle/rust-bundler-cp
repositoryhttps://github.com/Endle/rust-bundler-cp
max_upload_size
id434106
size116,377
Zhenbo Li (Endle)

documentation

https://github.com/Endle/rust-bundler-cp/blob/codeforce/README.mdr

README

rust-bundler-cp

This project is based on rust-bundler

Creates a single-source-file version of a Cargo package. It's designed for Competitive Programming like Codeforces.

I'm using rust-bundler-cp with my codeforces template https://github.com/Endle/rust_codeforce_template,

Features

  • Uses Syn to parse and manipulate a complete syntax tree, instead of doing replacement with regular expression.
  • Replaces extern crate my_lib; in main.rs with the contents of lib.rs.
  • Expands mod my_mod; declarations into mod my_mod { ... } blocks.
  • rustfmt needs to be available in PATH, i.e. dnf install rustfmt. I'll consider bundle rustfmt in my code later.

Example

Input:

// src/internal.rs:
pub fn hello_world() {
    println!("Hello, world!");
}

// src/lib.rs:
mod internal;
pub use internal::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 rust_bundler_cp

Run:

$ rust_bundler_cp --input path/to/project >output.rs
$ rust_bundler_cp --input path/to/project --binary a

Similar Projects

Commit count: 99

cargo fmt