diff --git a/Cargo.toml b/Cargo.toml index 463b124..4602b94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ publish = false [dependencies] [dev-dependencies] -input = { path = "./crates/input" } proconio = "=0.3.6" proconio-derive = "0.2.1" rand = "0.7.3" diff --git a/crates/input/Cargo.toml b/crates/input/Cargo.toml deleted file mode 100644 index feab978..0000000 --- a/crates/input/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "input" -version = "0.1.0" -authors = ["rust-lang-ja Developers"] -edition = "2018" -description = "Provides an `input!` macro for the `examples`." -license = "CC0-1.0" -publish = false - -[dependencies] diff --git a/crates/input/src/lib.rs b/crates/input/src/lib.rs deleted file mode 100644 index ea7cd6a..0000000 --- a/crates/input/src/lib.rs +++ /dev/null @@ -1,96 +0,0 @@ -//! A simple `input!` macro with minimal functionality. -//! -//! ```no_run -//! #[macro_use] -//! extern crate input as _; -//! -//! fn main() { -//! input! { -//! a: [u64], -//! } -//! } -//! ``` - -use std::{ - fmt, - io::{self, Read}, - str::{FromStr, SplitAsciiWhitespace}, -}; - -#[macro_export] -macro_rules! input { - ($($tt:tt)*) => { - let mut __scanner = $crate::Scanner::new().unwrap(); - $crate::input_inner!(@scanner(__scanner), @tts($($tt)*)); - ::std::mem::drop(__scanner); - }; -} - -#[doc(hidden)] -#[macro_export] -macro_rules! input_inner { - (@scanner($scanner:ident), @tts()) => {}; - (@scanner($scanner:ident), @tts(mut $single_tt_pat:tt : $readable:tt)) => { - let mut $single_tt_pat = $crate::read!(from $scanner { $readable }); - }; - (@scanner($scanner:ident), @tts($single_tt_pat:tt : $readable:tt)) => { - let $single_tt_pat = $crate::read!(from $scanner { $readable }); - }; - (@scanner($scanner:ident), @tts(mut $single_tt_pat:tt : $readable:tt, $($rest:tt)*)) => { - $crate::input_inner!(@scanner($scanner), @tts(mut $single_tt_pat: $readable)); - $crate::input_inner!(@scanner($scanner), @tts($($rest)*)); - }; - (@scanner($scanner:ident), @tts($single_tt_pat:tt : $readable:tt, $($rest:tt)*)) => { - $crate::input_inner!(@scanner($scanner), @tts($single_tt_pat: $readable)); - $crate::input_inner!(@scanner($scanner), @tts($($rest)*)); - }; -} - -#[doc(hidden)] -#[macro_export] -macro_rules! read { - (from $scanner:ident { [$tt:tt] }) => { - $crate::read!(from $scanner { [$tt; $crate::read!(from $scanner { usize })] }) - }; - (from $scanner:ident { [$tt:tt; $n:expr] }) => { - (0..$n).map(|_| $crate::read!(from $scanner { $tt })).collect::>() - }; - (from $scanner:ident { ($($tt:tt),+) }) => { - ($($crate::read!(from $scanner { $tt })),*) - }; - (from $scanner:ident { $ty:ty }) => { - $scanner.parse::<$ty>() - }; -} - -#[doc(hidden)] -pub struct Scanner { - words: SplitAsciiWhitespace<'static>, -} - -impl Scanner { - pub fn new() -> io::Result { - let mut buf = String::with_capacity(1024); - io::stdin().read_to_string(&mut buf)?; - let words = Box::leak(buf.into_boxed_str()).split_ascii_whitespace(); - Ok(Self { words }) - } - - /// Parses the next word. - /// - /// # Panics - /// - /// Panics if: - /// - /// - reached the end of input. - /// - the word is not successfully parsed. - pub fn parse(&mut self) -> T - where - T: FromStr, - T::Err: fmt::Display, - { - let word = self.words.next().expect("reached the end of input"); - word.parse() - .unwrap_or_else(|e| panic!("could not parse {:?}: {}", word, e)) - } -} diff --git a/examples/library-checker-convolution-mod.rs b/examples/library-checker-convolution-mod.rs index 9e179b0..4ee3f31 100644 --- a/examples/library-checker-convolution-mod.rs +++ b/examples/library-checker-convolution-mod.rs @@ -1,5 +1,5 @@ #[macro_use] -extern crate input as _; +extern crate proconio as _; use ac_library_rs::{convolution, modint::ModInt998244353 as Mint}; use std::fmt; diff --git a/examples/library-checker-static-range-sum.rs b/examples/library-checker-static-range-sum.rs index a4a5d8b..db38391 100644 --- a/examples/library-checker-static-range-sum.rs +++ b/examples/library-checker-static-range-sum.rs @@ -1,5 +1,5 @@ #[macro_use] -extern crate input as _; +extern crate proconio as _; #[macro_use] extern crate proconio_derive as _; diff --git a/examples/library-checker-sum-of-floor-of-linear.rs b/examples/library-checker-sum-of-floor-of-linear.rs index 78c3ca6..c0ee4d4 100644 --- a/examples/library-checker-sum-of-floor-of-linear.rs +++ b/examples/library-checker-sum-of-floor-of-linear.rs @@ -1,5 +1,5 @@ #[macro_use] -extern crate input as _; +extern crate proconio as _; #[macro_use] extern crate proconio_derive as _; diff --git a/examples/library-checker-unionfind.rs b/examples/library-checker-unionfind.rs index b6e1081..006457a 100644 --- a/examples/library-checker-unionfind.rs +++ b/examples/library-checker-unionfind.rs @@ -1,5 +1,5 @@ #[macro_use] -extern crate input as _; +extern crate proconio as _; use ac_library_rs::dsu::Dsu;