Skip to main content

str_rep

Function str_rep 

Source
pub fn str_rep(state: &mut LuaState) -> Result<usize, LuaError>
Expand description

string.rep(s, n [, sep]) — return n copies of s separated by sep.

The separator argument was added in Lua 5.2; 5.1’s string.rep(s, n) ignores any 3rd argument, so the separator is unconditionally empty on 5.1.

Borrow s through to_lua_string. The previous version did the check_arg_string copy and then a second redundant s.to_vec() inside the build loop — that double-copy is gone too.