✳flâneur — a map of the web's best reading
Creating a Rust function that returns a &str or String
hermanradtke.com · saved by 1 readers
We learned how to create a function that accepts String or &str as an argument. Now I want to show you how to create a function that returns either String or &str. I also want to discuss why we would want to do this. To start, let us write a function to remove all the spaces from a given string. Our function might look something like this:
Explore this link on the map →