Difference between len() vs chars().count() in Rust

Newbie might misunderstand between them.

Donald Le

--

Photo by Kevin Lang on Unsplash

If you are coming from different languages like Python, you might guess that len() return the length of variable, if it is String, means the number of characters in it, but indeed it is not.

Instead String.len() return the bytes of that String.

--

--

Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.