From 856bb308d9a33096a481b9bfdbe05a439637300e Mon Sep 17 00:00:00 2001 From: Andrew Golovashevich Date: Wed, 19 Nov 2025 01:35:38 +0300 Subject: [PATCH] Collapsed all crates to root since they anyway don't use any dependencies except stdlib --- Cargo.toml | 1 - ascii/Cargo.toml | 15 ---- ascii/src/_sandbox.rs | 79 ------------------- ascii/src/lib.rs | 8 -- converter/Cargo.toml | 11 --- default-streams/Cargo.toml | 11 --- default-streams/src/iterator.rs | 9 --- default-streams/src/lib.rs | 5 -- default-streams/src/pos/mod.rs | 7 -- {ascii/src => src/ascii}/char.rs | 0 {ascii/src => src/ascii}/converters.rs | 2 +- {ascii/src => src/ascii}/keyword.rs | 4 +- src/ascii/mod.rs | 7 ++ converter/src/lib.rs => src/converter.rs | 2 +- .../default_streams}/array.rs | 7 +- .../default_streams}/empty.rs | 4 +- .../iterators => src/default_streams}/mod.rs | 0 .../iterators => src/default_streams}/str.rs | 7 +- src/lib.rs | 4 + {default-streams/src => src}/pos/index.rs | 2 +- src/pos/mod.rs | 19 +++++ {default-streams/src => src}/pos/newline.rs | 4 +- {default-streams/src => src}/pos/nop.rs | 3 +- 23 files changed, 47 insertions(+), 164 deletions(-) delete mode 100644 ascii/Cargo.toml delete mode 100644 ascii/src/_sandbox.rs delete mode 100644 ascii/src/lib.rs delete mode 100644 converter/Cargo.toml delete mode 100644 default-streams/Cargo.toml delete mode 100644 default-streams/src/iterator.rs delete mode 100644 default-streams/src/lib.rs delete mode 100644 default-streams/src/pos/mod.rs rename {ascii/src => src/ascii}/char.rs (100%) rename {ascii/src => src/ascii}/converters.rs (98%) rename {ascii/src => src/ascii}/keyword.rs (85%) create mode 100644 src/ascii/mod.rs rename converter/src/lib.rs => src/converter.rs (99%) rename {default-streams/src/iterators => src/default_streams}/array.rs (96%) rename {default-streams/src/iterators => src/default_streams}/empty.rs (93%) rename {default-streams/src/iterators => src/default_streams}/mod.rs (100%) rename {default-streams/src/iterators => src/default_streams}/str.rs (96%) rename {default-streams/src => src}/pos/index.rs (91%) create mode 100644 src/pos/mod.rs rename {default-streams/src => src}/pos/newline.rs (95%) rename {default-streams/src => src}/pos/nop.rs (89%) diff --git a/Cargo.toml b/Cargo.toml index 1869363..fe802f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ edition = "2024" [lib] [workspace] -members = ["default-streams", "converter", "ascii"] [lints] rust = { nonstandard_style = "allow" } \ No newline at end of file diff --git a/ascii/Cargo.toml b/ascii/Cargo.toml deleted file mode 100644 index 3389de9..0000000 --- a/ascii/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "source-stream-0-ascii-0" -edition = "2024" - -[lib] - -[dependencies] - -[dev-dependencies] -source-stream-0 = { path = ".." } -source-stream-0-default-streams-0 = { path = "../default-streams" } -source-stream-0-converter-0 = { path = "../converter" } - -[lints] -rust = { nonstandard_style = "allow" } \ No newline at end of file diff --git a/ascii/src/_sandbox.rs b/ascii/src/_sandbox.rs deleted file mode 100644 index e47f433..0000000 --- a/ascii/src/_sandbox.rs +++ /dev/null @@ -1,79 +0,0 @@ -#[cfg(test)] - -use crate::{AsciiChar, AsciiCharConvertable}; -use source_stream_0::{CollectResult, 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, ArraySourceStream, StrSourceStream, -}; -use source_stream_0_default_streams_0::pos::IndexPosCounter; -use std::marker::PhantomData; -use crate::asciiLiteral; - -struct ConverterImpl {} - -impl StreamConverter_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) { - 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(StrSourceStream::start( - "qwяtr", - IndexPosCounter::default(), - )); - - let cvt = ConverterImpl {}; - let mut src = ConvertedSourceStream::convert(src8, cvt); - - /* let cs = src.collect(); - - - match cs { - CollectResult::EOF => {} - CollectResult::NotMatches => {} - CollectResult::Matches(z) => { - z.compareKeyword(&asciiLiteral(b"azboba")); - (); - } - } -*/ - for _ in 0..10 { - // println!("{}", src.pos()); - printAscii(src.currentChar()); - src.nextChar(); - } - - -} diff --git a/ascii/src/lib.rs b/ascii/src/lib.rs deleted file mode 100644 index d8c1622..0000000 --- a/ascii/src/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -mod _sandbox; -mod char; -mod converters; -mod keyword; - -pub use crate::char::AsciiChar; -pub use crate::converters::AsciiCharConvertable; -pub use crate::keyword::asciiLiteral; diff --git a/converter/Cargo.toml b/converter/Cargo.toml deleted file mode 100644 index d94473f..0000000 --- a/converter/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "source-stream-0-converter-0" -edition = "2024" - -[lib] - -[dependencies] -source-stream-0 = { path = ".." } - -[lints] -rust = { nonstandard_style = "allow" } \ No newline at end of file diff --git a/default-streams/Cargo.toml b/default-streams/Cargo.toml deleted file mode 100644 index 04065fd..0000000 --- a/default-streams/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "source-stream-0-default-streams-0" -edition = "2024" - -[lib] - -[dependencies] -source-stream-0 = { path = ".." } - -[lints] -rust = { nonstandard_style = "allow" } diff --git a/default-streams/src/iterator.rs b/default-streams/src/iterator.rs deleted file mode 100644 index 2ae1a72..0000000 --- a/default-streams/src/iterator.rs +++ /dev/null @@ -1,9 +0,0 @@ -use source_stream_0::Pos; - -pub trait PosCounter<'pos, C: Copy> { - type P: Pos<'pos>; - - fn update(&mut self, c: C); - - fn export(&self) -> Self::P; -} diff --git a/default-streams/src/lib.rs b/default-streams/src/lib.rs deleted file mode 100644 index 816fec2..0000000 --- a/default-streams/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod iterator; -pub use iterator::PosCounter; - -pub mod pos; -pub mod iterators; \ No newline at end of file diff --git a/default-streams/src/pos/mod.rs b/default-streams/src/pos/mod.rs deleted file mode 100644 index 5f41f3d..0000000 --- a/default-streams/src/pos/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod index; -mod newline; -mod nop; - -pub use index::IndexPosCounter; -pub use newline::PosLineCol; -pub use newline::NewLinePosCounter; \ No newline at end of file diff --git a/ascii/src/char.rs b/src/ascii/char.rs similarity index 100% rename from ascii/src/char.rs rename to src/ascii/char.rs diff --git a/ascii/src/converters.rs b/src/ascii/converters.rs similarity index 98% rename from ascii/src/converters.rs rename to src/ascii/converters.rs index bdff5b8..7397771 100644 --- a/ascii/src/converters.rs +++ b/src/ascii/converters.rs @@ -1,4 +1,4 @@ -use crate::AsciiChar; +use crate::ascii::AsciiChar; pub trait AsciiCharConvertable { fn asAsciiChar(&self) -> AsciiChar; diff --git a/ascii/src/keyword.rs b/src/ascii/keyword.rs similarity index 85% rename from ascii/src/keyword.rs rename to src/ascii/keyword.rs index 3132e53..e9a4340 100644 --- a/ascii/src/keyword.rs +++ b/src/ascii/keyword.rs @@ -1,4 +1,4 @@ -use crate::{AsciiChar}; +use crate::ascii::AsciiChar; pub const fn asciiLiteral( str: &[u8; S], @@ -6,7 +6,7 @@ pub const fn asciiLiteral( let mut out: [AsciiChar; S] = [AsciiChar::NOT_ASCII; S]; let mut i = 0usize; while i < S { - let a = str[i] as u32; + let a = str[i] as u32; if a >= 128 { panic!("Not ascii char in literal"); } diff --git a/src/ascii/mod.rs b/src/ascii/mod.rs new file mode 100644 index 0000000..b69aaca --- /dev/null +++ b/src/ascii/mod.rs @@ -0,0 +1,7 @@ +mod char; +mod converters; +mod keyword; + +pub use char::AsciiChar; +pub use converters::AsciiCharConvertable; +pub use keyword::asciiLiteral; diff --git a/converter/src/lib.rs b/src/converter.rs similarity index 99% rename from converter/src/lib.rs rename to src/converter.rs index c1b5794..93d0cdd 100644 --- a/converter/src/lib.rs +++ b/src/converter.rs @@ -1,7 +1,7 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] -use source_stream_0::{ +use crate::{ CollectedSubstring, Keyword, KeywordComparatorIterator, Pos, Predicate, SourceStream, }; use std::marker::PhantomData; diff --git a/default-streams/src/iterators/array.rs b/src/default_streams/array.rs similarity index 96% rename from default-streams/src/iterators/array.rs rename to src/default_streams/array.rs index 3b46217..f4864d2 100644 --- a/default-streams/src/iterators/array.rs +++ b/src/default_streams/array.rs @@ -1,9 +1,8 @@ -use crate::iterator::{PosCounter}; -use source_stream_0::{ - CollectedSubstring, Keyword, KeywordComparatorIterator, Predicate, SourceStream, -}; +use crate::KeywordComparatorIterator; use std::marker::PhantomData; use std::slice::Iter; +use crate::{CollectedSubstring, Keyword, Predicate, SourceStream}; +use crate::pos::PosCounter; pub struct ArrayCollectedSubstring<'source, C> { pub slice: &'source [C], diff --git a/default-streams/src/iterators/empty.rs b/src/default_streams/empty.rs similarity index 93% rename from default-streams/src/iterators/empty.rs rename to src/default_streams/empty.rs index f81de8a..cb33138 100644 --- a/default-streams/src/iterators/empty.rs +++ b/src/default_streams/empty.rs @@ -1,6 +1,6 @@ -use crate::PosCounter; -use source_stream_0::{CollectedSubstring, Pos, Predicate, SourceStream}; use std::marker::PhantomData; +use crate::{CollectedSubstring, Pos, Predicate, SourceStream}; +use crate::pos::PosCounter; pub struct EmptySourceStream< 'source, diff --git a/default-streams/src/iterators/mod.rs b/src/default_streams/mod.rs similarity index 100% rename from default-streams/src/iterators/mod.rs rename to src/default_streams/mod.rs diff --git a/default-streams/src/iterators/str.rs b/src/default_streams/str.rs similarity index 96% rename from default-streams/src/iterators/str.rs rename to src/default_streams/str.rs index aa935a8..d5240cf 100644 --- a/default-streams/src/iterators/str.rs +++ b/src/default_streams/str.rs @@ -1,9 +1,8 @@ -use crate::iterator::{PosCounter}; -use source_stream_0::{ - CollectedSubstring, Keyword, KeywordComparatorIterator, Predicate, SourceStream, -}; +use crate::KeywordComparatorIterator; use std::marker::PhantomData; use std::str::CharIndices; +use crate::{CollectedSubstring, Keyword, Predicate, SourceStream}; +use crate::pos::PosCounter; pub struct StrCollectedSubstring<'source> { pub slice: &'source str, diff --git a/src/lib.rs b/src/lib.rs index e505eb5..3284bc2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,10 @@ mod _keyword_impls; mod macros; +mod default_streams; +mod ascii; +mod converter; +pub mod pos; pub trait Predicate { fn check(&mut self, chr: C) -> bool; diff --git a/default-streams/src/pos/index.rs b/src/pos/index.rs similarity index 91% rename from default-streams/src/pos/index.rs rename to src/pos/index.rs index 3cc9b5b..70e31c7 100644 --- a/default-streams/src/pos/index.rs +++ b/src/pos/index.rs @@ -1,4 +1,4 @@ -use crate::iterator::PosCounter; +use crate::pos::PosCounter; pub struct IndexPosCounter { index: usize, diff --git a/src/pos/mod.rs b/src/pos/mod.rs new file mode 100644 index 0000000..9d918df --- /dev/null +++ b/src/pos/mod.rs @@ -0,0 +1,19 @@ +use crate::Pos; + +pub trait PosCounter<'pos, C: Copy> { + type P: Pos<'pos>; + + fn update(&mut self, c: C); + + fn export(&self) -> Self::P; +} + + +mod index; +mod newline; +mod nop; + +pub use index::IndexPosCounter; +pub use newline::PosLineCol; +pub use newline::NewLinePosCounter; +pub use nop::NopPosCounter; \ No newline at end of file diff --git a/default-streams/src/pos/newline.rs b/src/pos/newline.rs similarity index 95% rename from default-streams/src/pos/newline.rs rename to src/pos/newline.rs index 93e0621..e7471d0 100644 --- a/default-streams/src/pos/newline.rs +++ b/src/pos/newline.rs @@ -1,5 +1,5 @@ -use crate::iterator::PosCounter; -use source_stream_0::Pos; +use crate::Pos; +use crate::pos::PosCounter; pub struct PosLineCol { pub row: usize, diff --git a/default-streams/src/pos/nop.rs b/src/pos/nop.rs similarity index 89% rename from default-streams/src/pos/nop.rs rename to src/pos/nop.rs index b4edf6f..80e60d4 100644 --- a/default-streams/src/pos/nop.rs +++ b/src/pos/nop.rs @@ -1,4 +1,5 @@ -use crate::iterator::PosCounter; +use crate::pos::PosCounter; + pub struct NopPosCounter {} impl Default for NopPosCounter {