Add rpad.
GitOrigin-RevId: 5dbc3667ef3e4ffd35cce4a358b3b986ec9bd8f4
This commit is contained in:
parent
5719636fa2
commit
da6d1d8d74
@ -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());
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user