mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
Changes Maybe.ptr to Maybe.unsafe-ptr and all it's ocurrences
This commit is contained in:
parent
d5ca0ed552
commit
2c0fcbd6c9
@ -52,9 +52,9 @@ It is the inverse of [`just?`](#just?).")
|
||||
(Nothing) false
|
||||
(Just y) (= x y))))
|
||||
|
||||
(doc ptr "Creates a `(Ptr a)` from a `(Maybe a)`. If the `Maybe` was
|
||||
(doc unsafe-ptr "Creates a `(Ptr a)` from a `(Maybe a)`. If the `Maybe` was
|
||||
`Nothing`, this function will return a `NULL` value.")
|
||||
(defn ptr [a]
|
||||
(defn unsafe-ptr [a]
|
||||
(the (Ptr a) (Unsafe.coerce
|
||||
(match @a
|
||||
(Nothing) NULL
|
||||
|
@ -75,12 +75,12 @@
|
||||
)
|
||||
(assert-equal test
|
||||
1
|
||||
@(Pointer.to-ref (ptr &(Just 1)))
|
||||
"ptr works on Just"
|
||||
@(Pointer.to-ref (unsafe-ptr &(Just 1)))
|
||||
"unsafe-ptr works on Just"
|
||||
)
|
||||
(assert-true test
|
||||
(null? (ptr &(the (Maybe Int) (Nothing))))
|
||||
"ptr works on Nothing"
|
||||
(null? (unsafe-ptr &(the (Maybe Int) (Nothing))))
|
||||
"unsafe-ptr works on Nothing"
|
||||
)
|
||||
(assert-equal test
|
||||
&(Just 0)
|
||||
|
Loading…
Reference in New Issue
Block a user