Add append
to strings.
This commit is contained in:
parent
a264abffa4
commit
daa581bac7
@ -777,6 +777,7 @@ The following standard functions (defined in the standard library but excluded i
|
|||||||
|
|
||||||
* `len` - returns the number of characters (not number of bytes) in the string
|
* `len` - returns the number of characters (not number of bytes) in the string
|
||||||
* `pad` - pads the string with an character until a specified number of characters
|
* `pad` - pads the string with an character until a specified number of characters
|
||||||
|
* `append` - Adds a character or a string to the end of another string
|
||||||
* `clear` - empties the string
|
* `clear` - empties the string
|
||||||
* `truncate` - cuts off the string at exactly a specified number of characters
|
* `truncate` - cuts off the string at exactly a specified number of characters
|
||||||
* `contains` - checks if a certain character or sub-string occurs in the string
|
* `contains` - checks if a certain character or sub-string occurs in the string
|
||||||
|
@ -303,6 +303,8 @@ impl Engine<'_> {
|
|||||||
self.register_fn("contains", |s: &mut String, ch: char| s.contains(ch));
|
self.register_fn("contains", |s: &mut String, ch: char| s.contains(ch));
|
||||||
self.register_fn("contains", |s: &mut String, find: String| s.contains(&find));
|
self.register_fn("contains", |s: &mut String, find: String| s.contains(&find));
|
||||||
self.register_fn("clear", |s: &mut String| s.clear());
|
self.register_fn("clear", |s: &mut String| s.clear());
|
||||||
|
self.register_fn("append", |s: &mut String, ch: char| s.push(ch));
|
||||||
|
self.register_fn("append", |s: &mut String, add: String| s.push_str(&add));
|
||||||
self.register_fn("truncate", |s: &mut String, len: i64| {
|
self.register_fn("truncate", |s: &mut String, len: i64| {
|
||||||
if len >= 0 {
|
if len >= 0 {
|
||||||
let chars: Vec<_> = s.chars().take(len as usize).collect();
|
let chars: Vec<_> = s.chars().take(len as usize).collect();
|
||||||
|
Loading…
Reference in New Issue
Block a user