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;
ogaca42
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
oTTeuMsTudio
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.len() as u32}
Mxn-ptr
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.len() as u32}
ShileiShen
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
jamtg
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
jamtg
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
yansq
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.len() as u32}
ctylx
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
macgeargear
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string // s.len() as u32 s.chars().count() as u32}
macgeargear
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.len() as u32}
funny233-github
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.to_owned().len() as u32}
zelsazgh
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let c = s.chars().count(); c as u32}
VladyslavY
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
jose-bernardo
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.len() as u32}
jose-bernardo
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.len() as u32}
tiagombsilva
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
digitalresistor
pub fn count_characters(s: &str) -> u32 { s.chars().count().try_into().unwrap()}
carlos-quantexai
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let mut result = 0; for i in s.chars(){ result += 1; } result as u32}
Maki-SIO
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
radloffl
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
retinotopic
pub fn count_characters(s: &str) -> u32 { let mut sum: u32 = 0; for c in s.chars() { sum+=1; } return sum;}
jhq223
pub fn count_characters(s: &str) -> u32 { s.to_string().chars().count() as u32}
xbarnett
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.len() as u32}
mk-comm
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
Johnchoi913
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
majesticalcreature
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
matei
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
sander-b-postnl
pub fn count_characters(s: &str) -> u32 { s.len() as u32}
edoardo-morosanu
pub fn count_characters(s: &str) -> u32 { s.len() as u32}
i5-650
pub fn count_characters(s: &str) -> u32 { s.len() as u32}
amassare
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
alexromanov
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let mut n = 0; for c in s.chars() { n += 1; } n}
zavakid
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
RiskyRomero
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count().try_into().unwrap()}
IdoPort
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
Ustin
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
LaurentiuStoleriu
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string let numar = s.chars().count(); return numar as u32}
shankun
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
Parallaxes
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.len() as u32}
dylan-park
pub fn count_characters(s: &str) -> u32 { s.len() as u32}
Xinoi
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
otherJL0
pub fn count_characters(s: &str) -> u32 { s.len() as u32}
CianciuStyles
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
ayushrawat10
pub fn count_characters(s: &str) -> u32 { s.len() as u32}
pbjarterot
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
masteryachty
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
damascussteel21
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.len() as u32}
kyhou
pub fn count_characters(s: &str) -> u32 { s.chars().count() as u32}
oneopane
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}
AtJiawei
pub fn count_characters(s: &str) -> u32 { // Count the number of characters in the string s.chars().count() as u32}