macro_rules! input {
(@from [$source:expr] @rest) => { ... };
(@from [$source:expr] @rest mut $($rest:tt)*) => { ... };
(@from [$source:expr] @rest $($rest:tt)*) => { ... };
(@from [$source:expr] @mut [$($mut:tt)?] @rest $var:tt: $($rest:tt)*) => { ... };
(@from [$source:expr] @mut [$($mut:tt)?] @var $var:tt @kind [$($kind:tt)*] @rest) => { ... };
(@from [$source:expr] @mut [$($mut:tt)?] @var $var:tt @kind [$($kind:tt)*] @rest, $($rest:tt)*) => { ... };
(@from [$source:expr] @mut [$($mut:tt)?] @var $var:tt @kind [$($kind:tt)*] @rest $tt:tt $($rest:tt)*) => { ... };
(from $source:expr, $($rest:tt)*) => { ... };
($($rest:tt)*) => { ... };
}
read input from stdin.
basic syntax is:
input! {
from source, // optional: if you omitted, stdin is used by default.
(mut) variable: type, // mut is optional: mut makes the variable mutable.
...
}
the trailing comma is optional. source
can be anything implementing Source
. This macro
moves out the specified source. If you want to prevent moving, you can use &mut source
since
&mut S
where S: Source
also implements Source
.