summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2023-07-30 19:57:39 -0400
committerBotahamec <botahamec@outlook.com>2023-07-30 19:57:39 -0400
commit6261e57f55efd0c10d3011f306dccbf5ca787003 (patch)
treee3b9b0ea081facd70f822d59a7f37a3450034bf2 /src
parentf3c7e9717ba7679480aa71ecd5674d708b7837b0 (diff)
Implemented a few traits on Scanner
Diffstat (limited to 'src')
-rw-r--r--src/scanner.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/scanner.rs b/src/scanner.rs
index f947205..f2c4a2d 100644
--- a/src/scanner.rs
+++ b/src/scanner.rs
@@ -111,3 +111,24 @@ impl Scanner {
Some(i)
}
}
+
+impl From<&str> for Scanner {
+ fn from(value: &str) -> Self {
+ Self::new(value)
+ }
+}
+
+impl From<Box<[char]>> for Scanner {
+ fn from(value: Box<[char]>) -> Self {
+ Self {
+ source: value,
+ position: 0,
+ }
+ }
+}
+
+impl AsRef<[char]> for Scanner {
+ fn as_ref(&self) -> &[char] {
+ &self.source
+ }
+}