AsRef & Borrow
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Me fn hap<P: AsRef<Path>>(p: P), funksioni pranon &str, String, PathBuf… pa konvertim manual. AsRef dhe Borrow i bëjnë API-të më fleksibël.
EnglishEN
With fn open<P: AsRef<Path>>(p: P), the function accepts &str, String, PathBuf… without manual conversion. AsRef and Borrow make APIs more flexible.
Si ta mendosh
Si një prizë që pranon disa lloje spinash.
Lexoje në anglisht
Like a socket that accepts several plug types.
Shembull kodirust
fn lexo<P: AsRef<std::path::Path>>(rruga: P) -> std::io::Result<String> {
std::fs::read_to_string(rruga)
}