04/Traits/07_Deref std::String::trim

Author: egregleeCreated Jan 16, 2025Updated Jun 9, 2026

04/Traits/07_Deref says:

// TODO: whenever title and description are returned via their accessor methods, they // should be normalized—i.e. leading and trailing whitespace should be removed. // There is a method in Rust's standard library that can help with this, but you won't // find it in the documentation for String. // Can you figure out where it is defined and how to use it?

This method appears to be in String:

std::String::trim

Source: mainmatter/100-exercises-to-learn-rust