You are given a string s
. Your task is to count the number of characters in the string and return the total amount of characters in the string with the type u32
.
chars()
method to get an iterator over the characters in the string.count()
method to count the number of elements in the iterator.The
count()
method returns ausize
which is the number of elements in the iterator. In the challenge you are asked to return au32
, you can use theas
keyword to convert theusize
to au32
. For example,let count_u32 = count as u32;
Don't use
len()
: This length is in bytes, not [char
]s or graphemes. In other words, it might not be what a human considers the length of the string.
jimlawton
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
XtebanUy
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
5822791760
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string return s.chars().count() as u32;}
woke-developer
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
mbergkvist
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
leenalmajz
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string return s.chars().count() as u32}
facat
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
DivineGod
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count().try_into().unwrap()}
StimhackSoftware
pub fn count_characters(s: &str) -> u32 { String::from(s).chars().count() as u32}
mehdihmr
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
MisterWoody
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
DistributedDoge
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
ethel-dev
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
Algorab
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
Hannnsen
pub fn count_characters(s: &str) -> u32 { s.chars().count().try_into().unwrap()}
sroas
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
itaygenkin
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
felipebalbi
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
danielmpetrov
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
yoakemae
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string return s.chars().count() as u32;}
tinthid
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
qiyuan711
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
jw
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
nickythorne
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
DV-13
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
xiuchiliudu
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let mut count = 0; // Count the number of characters in the string for character in s.chars() { count += 1; } let res = count as u32; res}
martin-unit
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
RonaldoArayadev
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
vrzwflng
pub fn count_characters(s: &str) -> u32 { s.chars() .count() .try_into() .unwrap()}
joeslow
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
Thymelizabeth
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
konishu
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
tamanishi
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
devarajang
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let iter1 = s.chars(); return iter1.count() as u32;}
nichideropa
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let mut count = 0; for c in s.chars() { count += 1 } count as u32}
nichideropa
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
jeypiti
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
stefafafan
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
0xsmarter
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
t3stlab
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
aidan1magee
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let count = s.chars().count(); count as u32}
tsucchinoko
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
ankeetparikh
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
maxvi
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
LauriSarap
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let count_chars: usize = s.chars().count(); return count_chars as u32;}
rafaellucasprogm
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
rafaellucasprogm
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count().try_into().unwrap()}
cloki0610
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
Brack0
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
risemacro
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}