AsRef lets a function accept different values as shared references to a target type. For string input, `T: AsRef<str>` allows both `String` and `&str` without requiring a trivial cast between their different memory representations. section 6.3.1
Generic password validation
A password validator can check `password.as_ref().len() > 5`, accepting any `T` that implements `AsRef<str>`. This supports read-only access while keeping the validation logic reusable. section 6.3.1
fn is_strong<T: AsRef<str>>(password: T) -> bool { #1
password.as_ref().len() > 5
}
Inspect the generic validator and its `as_ref()` call. section 6.3.1
Use `AsMut<T>` when mutable access is needed. Alternatively, accept `Into<String>` and convert inside the function, but repeated conversions can be less efficient than converting once at the call site. section 6.3.1
