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).
This commit is contained in:
Ali Mohammad Pur 2022-12-10 19:29:22 +03:30 committed by Ali Mohammad Pur
parent 537924a8d0
commit 1cc8cdcd23

View file

@ -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<SameAs<StringView> 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;