From 376247ba8afcb1db3fd19e853f048d48fff9652c Mon Sep 17 00:00:00 2001 From: apio Date: Mon, 1 May 2023 20:03:16 +0200 Subject: [PATCH] libluna: Add String::from_string_view() --- apps/ls.cpp | 2 +- libluna/include/luna/String.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/ls.cpp b/apps/ls.cpp index 65d6b0e3..2da0c0d6 100644 --- a/apps/ls.cpp +++ b/apps/ls.cpp @@ -41,7 +41,7 @@ Result luna_main(int argc, char** argv) } else { - auto str = TRY(String::from_cstring(pathname.chars())); + auto str = TRY(String::from_string_view(pathname)); TRY(files.try_append(move(str))); } diff --git a/libluna/include/luna/String.h b/libluna/include/luna/String.h index 2140fffb..e8abc98e 100644 --- a/libluna/include/luna/String.h +++ b/libluna/include/luna/String.h @@ -41,6 +41,10 @@ class String static Result vformat(StringView fmt, va_list ap); static Result from_cstring(const char* str); + static Result from_string_view(StringView str) + { + return from_cstring(str.chars()); + } const char* chars() const {