add a miscompilation test
This commit is contained in:
parent
31ad5f6b2b
commit
2e5a0dc172
22
tests/run-pass/issue-73223.rs
Normal file
22
tests/run-pass/issue-73223.rs
Normal file
@ -0,0 +1,22 @@
|
||||
fn main() {
|
||||
let mut state = State { prev: None, next: Some(8) };
|
||||
let path = "/nested/some/more";
|
||||
assert_eq!(state.rest(path), "some/more");
|
||||
}
|
||||
|
||||
struct State {
|
||||
prev: Option<usize>,
|
||||
next: Option<usize>,
|
||||
}
|
||||
|
||||
impl State {
|
||||
fn rest<'r>(&mut self, path: &'r str) -> &'r str {
|
||||
let start = match self.next.take() {
|
||||
Some(v) => v,
|
||||
None => return "",
|
||||
};
|
||||
|
||||
self.prev = Some(start);
|
||||
&path[start..]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user