I just tried to use these in my own code and was kind of shocked they didn't exist.
Justification: this seems like a common Rust pattern. We have is_some and is_none for Option, is_ok and is_err for Result, etc., so, it seems pretty fair to have is_borrowed and is_owned for Cow.
Having as_borrowed and as_owned wouldn't really make much sense, as a simple & and &mut/to_mut cover those use cases. But, these check functions are pretty useful on their own.
Unresolved question: do we want to ship these or defer to matches! and the future possibility of is?
I just tried to use these in my own code and was kind of shocked they didn't exist.
Justification: this seems like a common Rust pattern. We have
is_someandis_noneforOption,is_okandis_errforResult, etc., so, it seems pretty fair to haveis_borrowedandis_ownedforCow.Having
as_borrowedandas_ownedwouldn't really make much sense, as a simple&and&mut/to_mutcover those use cases. But, these check functions are pretty useful on their own.Unresolved question: do we want to ship these or defer to
matches!and the future possibility ofis?