string: add some docs

pull/2569/head
Don Alfons Nisnoni 2019-10-28 03:29:55 +08:00 committed by Alexander Medvednikov
parent 384e81fe28
commit 8358528888
1 changed files with 4 additions and 4 deletions

View File

@ -1044,19 +1044,19 @@ pub fn (s []string) join_lines() string {
return s.join('\n')
}
// reverse will return a new reversed string.
pub fn (s string) reverse() string {
mut res := string {
len: s.len
str: malloc(s.len)
}
for i := s.len - 1; i >= 0; i-- {
res[s.len-i-1] = s[i]
}
return res
}
// limit returns a portion of the string, starting at `0` and extending for a given number of characters afterward.
// 'hello'.limit(2) => 'he'
// 'hi'.limit(10) => 'hi'
pub fn (s string) limit(max int) string {
@ -1094,7 +1094,7 @@ pub fn (s string) bytes() []byte {
return buf
}
// Returns a new string with a specified number of copies of the string it was called on.
// repeat returns a new string with a specified number of copies of the string it was called on.
pub fn (s string) repeat(count int) string {
if count <= 1 {
return s