This will be used in the next patch in this series.
- Group Reviewers
- rHG4f1543a2f5c3: rust-hg-path: add method to get part of a path relative to a prefix
base.is_empty()? If we don't have that helper we should probably add it.
The comment says that base must end with a / however you appear to handle cases where it doesn't Can you either update the documentation or the code?
Instead of using .last() can we add and use base.ends_with(b'/')?
base.len() > 0 is redundant both with the early return above and because last() will return None if base is empty.
I would do self.as_bytes() for consistency.
Or even better I believe you can #[derive(Eq,PartialEq)].
The argument order here feels backwards. I know some frameworks (like Java's JUnit) put the expected value first, but the definition of assert_eq! doesn't seem to have any opinion and https://doc.rust-lang.org/stable/rust-by-example/testing/unit_testing.html puts the actual value first. What do you think about changing the order? That would make it more readable to me.
It looks that I took the habit because the test runner in PyCharm that I used when starting with Rust prints expected and actual in that order. I can reverse it if you really think it's more readable this way.