Pad string to exact length even when padding string is not multiple.
This commit is contained in:
parent
8a17856f27
commit
d68c951795
@ -49,7 +49,7 @@ pub type Locked<T> = RefCell<T>;
|
||||
#[cfg(feature = "sync")]
|
||||
pub type Locked<T> = RwLock<T>;
|
||||
|
||||
/// Context of a script evaluation process.
|
||||
/// Context of native Rust function call.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct NativeCallContext<'e, 'm> {
|
||||
engine: &'e Engine,
|
||||
|
@ -324,8 +324,13 @@ mod string_functions {
|
||||
let p = s.make_mut();
|
||||
|
||||
while str_len < len as usize {
|
||||
if str_len + padding_len <= len as usize {
|
||||
p.push_str(padding);
|
||||
str_len += padding_len;
|
||||
} else {
|
||||
p.extend(padding.chars().take(len as usize - str_len));
|
||||
str_len = len as usize;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
|
Loading…
Reference in New Issue
Block a user