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.
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string // let mut counter = 0; // for character in s.chars() { // counter += 1; // } // counter s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let count = s.chars().count(); count as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let count_u32 = s.chars().count() as u32; count_u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let count = s.chars().count(); let count_u32 = count as u32; count_u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let mut count:u32 = 0; for _ in s.chars() { count += 1; } return count;}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string return s.chars().count() as u32;}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string return s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let mut count: u32 = 0; for _ in s.chars() { count += 1; } return count}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let mut count: u32 = 0; for _ in s.chars() { count += 1 } count}
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { return s.chars().count() as u32; // let mut characters_count = 0; // for _ in s.chars() { // characters_count += 1; // } // return characters_count;}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let chars = s.chars(); chars.count().try_into().unwrap()}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string return s.chars().count() as u32;}
pub fn count_characters(s: &str) -> u32 {s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let cc = s.chars().count(); return cc as u32;}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32 }
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32 }
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string for i in s.chars(){ println!("{}",i); } let a: u32 = s.chars().count() as u32; a}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { let count = s.chars().count(); count as u32}
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
pub fn count_characters(s: &str) -> u32 { s.chars().count() as _}