aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.ucl/object_cast.ccm
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-07-01 17:07:04 +0100
committerLexi Winter <lexi@le-fay.org>2025-07-01 17:07:04 +0100
commit2e2d1bd3b6c7776b77c33b94f30ead89367a71e6 (patch)
tree54d37ffadf8e677938d9b7a28e4e9b71be1e75c1 /nihil.ucl/object_cast.ccm
parent36427c0966faa7aecd586b397ed9b845f18172f5 (diff)
downloadnihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.gz
nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.bz2
add nihil.std
Diffstat (limited to 'nihil.ucl/object_cast.ccm')
-rw-r--r--nihil.ucl/object_cast.ccm19
1 files changed, 6 insertions, 13 deletions
diff --git a/nihil.ucl/object_cast.ccm b/nihil.ucl/object_cast.ccm
index 3fa9eba..5a09085 100644
--- a/nihil.ucl/object_cast.ccm
+++ b/nihil.ucl/object_cast.ccm
@@ -1,17 +1,11 @@
-/*
- * This source code is released into the public domain.
- */
-
+// This source code is released into the public domain.
module;
-#include <coroutine>
-#include <cstdlib>
-#include <expected>
-
#include <ucl.h>
export module nihil.ucl:object_cast;
+import nihil.std;
import nihil.monad;
import :type;
import :object;
@@ -19,10 +13,9 @@ import :array;
namespace nihil::ucl {
-/*
- * Ensure a UCL object is convertible to another type. Throws type_mismatch
- * if not.
- */
+//
+// Ensure a UCL object is convertible to another type.
+//
// Implementation for basic types.
template<datatype To>
@@ -80,7 +73,7 @@ struct convert_check<array<T>>
export template<datatype To>
auto object_cast(object const &from) -> std::expected<To, type_mismatch>
{
- auto uobj = from.get_ucl_object();
+ auto const *uobj = from.get_ucl_object();
co_await convert_check<To>{}.check(uobj);
co_return To(nihil::ucl::ref, uobj);