64 lines
1.7 KiB
Rust
64 lines
1.7 KiB
Rust
use crate::{AsciiChar, AsciiCharConvertable};
|
|
use source_stream_0::{CollectedSubstring, Pos, SourceStream};
|
|
use source_stream_0_converter_0::{
|
|
ConvertedSourceStream, StreamConverter, StreamConverter_Char, StreamConverter_Pos,
|
|
StreamConverter_Pos_Noop, StreamConverter_Substring,
|
|
};
|
|
use source_stream_0_default_streams_0::SourceStreamOverIterator;
|
|
use source_stream_0_default_streams_0::iterators::{
|
|
ArrayCollectedSubstring, ArraySourceIterator, StrSourceIterator,
|
|
};
|
|
use source_stream_0_default_streams_0::pos::IndexPosCounter;
|
|
use std::marker::PhantomData;
|
|
|
|
#[cfg(test)]
|
|
|
|
struct ConverterImpl {}
|
|
|
|
impl StreamConverter_Char<char> for ConverterImpl {
|
|
type WC = AsciiChar;
|
|
|
|
fn convertChar(&self, c: char) -> Self::WC {
|
|
return c.asAsciiChar();
|
|
}
|
|
}
|
|
|
|
impl<'pos, P: Pos<'pos>> StreamConverter_Pos_Noop<'pos, P> for ConverterImpl {}
|
|
|
|
impl<'source, CS: CollectedSubstring<'source, C = char>>
|
|
StreamConverter_Substring<'source, char, CS> for ConverterImpl
|
|
{
|
|
type WCS = ArrayCollectedSubstring<'source, AsciiChar>;
|
|
|
|
fn convertSubstring(&self, wcs: CS) -> Self::WCS {
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
fn printAscii(a: Option<AsciiChar>) {
|
|
match a {
|
|
None => println!("_"),
|
|
Some(aa) => match aa {
|
|
AsciiChar::NOT_ASCII => println!("#"),
|
|
AsciiChar::ASCII(c) => println!("{}", c as char),
|
|
},
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn sandbox() {
|
|
let src8 = SourceStreamOverIterator::wrap(StrSourceIterator::start(
|
|
"qwяtr",
|
|
IndexPosCounter::default(),
|
|
));
|
|
|
|
let cvt = ConverterImpl {};
|
|
let mut src = ConvertedSourceStream::convert(src8, cvt);
|
|
|
|
for _ in 0..10 {
|
|
// println!("{}", src.pos());
|
|
printAscii(src.currentChar());
|
|
src.nextChar();
|
|
}
|
|
}
|