Skip to content

Commit 8d5ab30

Browse files
committed
core: add char_len method
1 parent 4b0f29a commit 8d5ab30

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libcore/str.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,7 @@ pub trait StrSlice {
22632263
pure fn is_whitespace(&self) -> bool;
22642264
pure fn is_alphanumeric(&self) -> bool;
22652265
pure fn len(&self) -> uint;
2266+
pure fn char_len(&self) -> uint;
22662267
pure fn slice(&self, begin: uint, end: uint) -> ~str;
22672268
pure fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str];
22682269
pure fn split_char(&self, sep: char) -> ~[~str];
@@ -2343,9 +2344,12 @@ impl StrSlice for &'self str {
23432344
*/
23442345
#[inline]
23452346
pure fn is_alphanumeric(&self) -> bool { is_alphanumeric(*self) }
2346-
#[inline]
23472347
/// Returns the size in bytes not counting the null terminator
2348+
#[inline]
23482349
pure fn len(&self) -> uint { len(*self) }
2350+
/// Returns the number of characters that a string holds
2351+
#[inline]
2352+
pure fn char_len(&self) -> uint { char_len(*self) }
23492353
/**
23502354
* Returns a slice of the given string from the byte range
23512355
* [`begin`..`end`)

0 commit comments

Comments
 (0)