`AsRef<Path>` instead of `AsRef<Self>` in `Utf8Path::starts_with`?
smoelius opened this issue · comments
Mostly because I am curious, what is the rationale for requiring base
to implement AsRef<Path>
instead of AsRef<Self>
in Utf8Path::starts_with
?
Line 817 in 8aa7205
Hi @smoelius--great question, thanks for asking!
Consider what happens if you have a Path
-- it is reasonable to ask if a Utf8Path
starts with a Path
, and camino can answer that for you without having to convert the Path
to a Utf8Path
(you could always return false if the conversion fails, but it's an extra annoyance).
The same applies to other third party types that implement AsRef<Path>
. consider what happens if there's another third party type MyPath
which is unaware of camino but implements AsRef<Path>
.
So impl AsRef<Path>
is more general than AsRef<Self>
.
Got it. Thank you for the explanation.