Skip to content

A Rust crate for providing helpful methods in online judging.

License

Notifications You must be signed in to change notification settings

paninizer/dmoj-rust-windows

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dmoj-rust Travis CI

A Rust crate for providing helpful methods in online judging. Cloned from DMOJ Rust, this fork aims to create better usability of this library on Windows, as the original only supports Linux.

Usage

#[macro_use] extern crate dmoj;

fn main() {
    println!("Hello, World!");
}

Provided macros

print!, println!

This crate provides print! and println! macros that shadow the prelude versions. These versions are about 10 times faster and fully API compatible, but sacrifice thread safety.

Example

#[macro_use] extern crate dmoj;

fn main() {
    print!("Hello, ");
    println!("World!");
}

flush!

Flushes the stdout buffer.

Example

#[macro_use] extern crate dmoj;

use std::thread;
use std::time::Duration;

fn main() {
    print!("Hello,");
    flush!();
    thread::sleep(Duration::from_secs(2));
    println!(" World!");
}

scan!

scan!(T) -> T;
scan!(T1, ..., Tn) -> (T1, ..., Tn);

A macro for scanning values from stdin. Currently, only scanning chars and integers is supported. Note that when scanning integers, the scanner will continue to read stdin until it finds something that looks like an integer. If the macro is called with multiple type arguments a tuple of the values will be returned, otherwise the value itself is returned.

Example

#[macro_use] extern crate dmoj;

fn main() {
    // For example, if stdin contains " 2020 \n  +4 test \n   -19xy" then

    print!("{:?}", scan!(u64));      // prints "2020", and
    print!("{:?}", scan!(i16, i16)); // prints "(4, -19)"
    print!("{:?}", scan!(char));     // prints "'x'"
    print!("{:?}", scan!(char));     // prints "'y'"
}

About

A Rust crate for providing helpful methods in online judging.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%