Add rpad.

GitOrigin-RevId: 5dbc3667ef3e4ffd35cce4a358b3b986ec9bd8f4
This commit is contained in:
levlam 2020-10-30 16:21:13 +03:00
parent 5719636fa2
commit da6d1d8d74
2 changed files with 9 additions and 0 deletions

View File

@ -47,6 +47,13 @@ string lpad0(string str, size_t size) {
return lpad(std::move(str), size, '0');
}
string rpad(string str, size_t size, char c) {
if (str.size() >= size) {
return str;
}
return str + string(size - str.size(), c);
}
string oneline(Slice str) {
string result;
result.reserve(str.size());

View File

@ -273,6 +273,8 @@ string lpad(string str, size_t size, char c);
string lpad0(const string str, size_t size);
string rpad(string str, size_t size, char c);
string oneline(Slice str);
template <class T>