diff --git a/README.md b/README.md index a379b829..1c7a3223 100644 --- a/README.md +++ b/README.md @@ -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 * `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 * `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 diff --git a/src/builtin.rs b/src/builtin.rs index ba175ea0..7c43f0a4 100644 --- a/src/builtin.rs +++ b/src/builtin.rs @@ -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, find: String| s.contains(&find)); 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| { if len >= 0 { let chars: Vec<_> = s.chars().take(len as usize).collect();