aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.ucl/object_cast.ccm
diff options
context:
space:
mode:
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);