From 1cc8cdcd23ffffdbe5dbca41a9f8b542429b5f82 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sat, 10 Dec 2022 19:29:22 +0330 Subject: [PATCH] AK: Add a Error::__jakt_from_string_literal(StringView) factory function Note that Jakt only allows StringView creation from string literals, so none of the invariants in the class are broken by this (if used only from within Jakt). --- AK/Error.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/AK/Error.h b/AK/Error.h index 007bd8a22a..b2221013b8 100644 --- a/AK/Error.h +++ b/AK/Error.h @@ -37,6 +37,13 @@ public: return from_string_view(StringView { string_literal, N - 1 }); } + // Note: Don't call this from C++; it's here for Jakt interop (as the name suggests). + template T> + ALWAYS_INLINE static Error __jakt_from_string_literal(T string) + { + return from_string_view(string); + } + bool operator==(Error const& other) const { return m_code == other.m_code && m_string_literal == other.m_string_literal && m_syscall == other.m_syscall;