use crate::source::{Readable, Source};
use std::io::BufRead;
pub enum Chars {}
impl Readable for Chars {
type Output = Vec<char>;
fn read<R: BufRead, S: Source<R>>(source: &mut S) -> Vec<char> {
source.next_token_unwrap().chars().collect()
}
}
pub enum Bytes {}
impl Readable for Bytes {
type Output = Vec<u8>;
fn read<R: BufRead, S: Source<R>>(source: &mut S) -> Vec<u8> {
source.next_token_unwrap().bytes().collect()
}
}
pub enum Usize1 {}
impl Readable for Usize1 {
type Output = usize;
fn read<R: BufRead, S: Source<R>>(source: &mut S) -> usize {
usize::read(source)
.checked_sub(1)
.expect("attempted to read the value 0 as a Usize1")
}
}
pub enum Isize1 {}
impl Readable for Isize1 {
type Output = isize;
fn read<R: BufRead, S: Source<R>>(source: &mut S) -> isize {
isize::read(source).checked_sub(1).unwrap_or_else(|| {
panic!(
concat!(
"attempted to read the value {} as a Isize1:",
" the value is isize::MIN and cannot be decremented"
),
isize::MIN,
)
})
}
}