Now the last argument in the arguments can be a rest argument.
Take for example the following:
/// Concatenates all of the given strings into one
///
/// (string-append strs...) -> string?
///
/// * strs ... : string?
///
/// # Examples
/// ```scheme
/// > (string-append) ;; => ""
/// > (string-append "foo" "bar") ;; => "foobar"
// ```
#[function(name = "string-append")]
pub fn string_append(rest: RestArgs<SteelString>) -> SteelVal {
let accumulated = rest
.0
.into_iter()
.fold("".to_string(), |accum, next| accum + next.as_str());
SteelVal::StringV(accumulated.into())
}
However, this will allocate a new Vec<T> for the rest. The alternative implementation will use an iterator over the rest args, making it optional to allocate:
Now the last argument in the arguments can be a rest argument.
Take for example the following:
However, this will allocate a new
Vec<T>
for the rest. The alternative implementation will use an iterator over the rest args, making it optional to allocate:Closes #64