libluna: Allow constructing a StringView from a string that might not be null-terminated
This commit is contained in:
parent
1d6a39c924
commit
1444cbb3df
@ -43,6 +43,8 @@ class StringView
|
|||||||
Result<Vector<String>> split(StringView delim) const;
|
Result<Vector<String>> split(StringView delim) const;
|
||||||
Result<Vector<String>> split_once(char delim) const;
|
Result<Vector<String>> split_once(char delim) const;
|
||||||
|
|
||||||
|
static StringView from_fixed_size_cstring(const char* string, usize max);
|
||||||
|
|
||||||
Result<usize> to_uint() const;
|
Result<usize> to_uint() const;
|
||||||
|
|
||||||
Iterator begin() const
|
Iterator begin() const
|
||||||
|
@ -120,5 +120,10 @@ Result<usize> StringView::to_uint() const
|
|||||||
|
|
||||||
Result<String> StringView::to_string()
|
Result<String> StringView::to_string()
|
||||||
{
|
{
|
||||||
return String::from_cstring(m_string);
|
return String::from_string_view(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringView StringView::from_fixed_size_cstring(const char* string, usize max)
|
||||||
|
{
|
||||||
|
return { string, strnlen(string, max) };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user