Skip to content

Commit a10bbd3

Browse files
committedMar 28, 2025··
chore: sliced string as bytes
1 parent 158f350 commit a10bbd3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed
 

‎Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ route-recognizer = "0.3"
3232
matchit = "0.7"
3333
gonzales = "0.0.3-beta"
3434
futures = "0.3"
35-
rand = "0.8"
35+
rand = "0.9"
3636
criterion = { version = "0.5", features = ["html_reports"] }
3737
hyper = { version = "1", features = ["full"] }
3838
hyper-util = { version = "0.1", features = ["tokio"] }

‎src/parser.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'a> Parser<'a> {
5959
'\\' => {
6060
if start < i {
6161
self.pos = i;
62-
return self.input[start..i].as_bytes();
62+
return &self.input.as_bytes()[start..i];
6363
}
6464

6565
self.cursor.next();
@@ -70,13 +70,13 @@ impl<'a> Parser<'a> {
7070
} else {
7171
self.cursor.next();
7272
self.pos = j + c.len_utf8();
73-
return self.input[j..self.pos].as_bytes();
73+
return &self.input.as_bytes()[j..self.pos];
7474
}
7575
}
7676
}
7777
':' | '+' | '*' => {
7878
self.pos = i + 1;
79-
return self.input[start..i].as_bytes();
79+
return &self.input.as_bytes()[start..i];
8080
}
8181
_ => {
8282
self.cursor.next();
@@ -94,15 +94,15 @@ impl<'a> Parser<'a> {
9494
'-' | '.' | '~' | '/' | '\\' | ':' => {
9595
self.pos = i;
9696
return (
97-
Position::Named(self.input[start..i].as_bytes().to_vec()),
97+
Position::Named(self.input.as_bytes()[start..i].to_vec()),
9898
Kind::Normal,
9999
);
100100
}
101101
'?' | '+' | '*' => {
102102
self.cursor.next();
103103
self.pos = i + 1;
104104
return (
105-
Position::Named(self.input[start..i].as_bytes().to_vec()),
105+
Position::Named(self.input.as_bytes()[start..i].to_vec()),
106106
if c == '+' {
107107
Kind::OneOrMore
108108
} else {
@@ -133,7 +133,7 @@ impl<'a> Parser<'a> {
133133
}
134134

135135
(
136-
Position::Named(self.input[start..].as_bytes().to_vec()),
136+
Position::Named(self.input.as_bytes()[start..].to_vec()),
137137
Kind::Normal,
138138
)
139139
}

0 commit comments

Comments
 (0)
Please sign in to comment.