mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Add to_string() method to StringView
This allows easy creation of a new string from an existing StringView. Can be used e.g. for output with printf(..., view.to_string().characters()) instead of writing printf(..., String{view}.characters()).
This commit is contained in:
parent
c7568943d9
commit
8fe821fae2
Notes:
sideshowbarker
2024-07-19 06:55:50 +09:00
Author: https://github.com/lnzero1dev Commit: https://github.com/SerenityOS/serenity/commit/8fe821fae29 Pull-request: https://github.com/SerenityOS/serenity/pull/2133
2 changed files with 4 additions and 0 deletions
|
@ -264,4 +264,6 @@ Optional<size_t> StringView::find_last_of(const StringView& view) const
|
|||
return {};
|
||||
}
|
||||
|
||||
String StringView::to_string() const { return String { *this }; }
|
||||
|
||||
}
|
||||
|
|
|
@ -152,6 +152,8 @@ public:
|
|||
|
||||
const StringImpl* impl() const { return m_impl; }
|
||||
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
friend class String;
|
||||
const StringImpl* m_impl { nullptr };
|
||||
|
|
Loading…
Reference in a new issue