From 17a724f48a81bfbeb403a7f6c54a2783d2068cfd Mon Sep 17 00:00:00 2001 From: Glenn Slotte Date: Sat, 15 Apr 2023 00:35:25 +0200 Subject: [PATCH 1/2] docs(option): getUnsafe does not raise an exception --- src/Core__Option.resi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Core__Option.resi b/src/Core__Option.resi index fb3c8a46..697704b0 100644 --- a/src/Core__Option.resi +++ b/src/Core__Option.resi @@ -80,18 +80,18 @@ Option.getExn(None) /* Raises an Error */ let getExn: option<'a> => 'a /** -`getUnsafe(value)` returns `value`. +`getUnsafe(value)` returns `value` if `opt` is `Some(value)`, otherwise `undefined`. ## Examples ```rescript Option.getUnsafe(Some(3)) == 3 -Option.getUnsafe(None) // Raises an error +Option.getUnsafe(None: option) // Returns `undefined`, which is not a valid `int` ``` -## Exceptions +## Notes -- This is an unsafe operation, it assumes `value` is neither `None` nor `Some(None(...)))` +- This is an unsafe operation. It assumes `value` is not `None`, and may cause undefined behaviour if it is. */ external getUnsafe: option<'a> => 'a = "%identity" From 87cf34f02fdb1dbf7ba052d4cc106c1371fe5daf Mon Sep 17 00:00:00 2001 From: Glenn Slotte Date: Sat, 15 Apr 2023 00:38:24 +0200 Subject: [PATCH 2/2] value -> opt --- src/Core__Option.resi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core__Option.resi b/src/Core__Option.resi index 697704b0..fbcf89c1 100644 --- a/src/Core__Option.resi +++ b/src/Core__Option.resi @@ -80,7 +80,7 @@ Option.getExn(None) /* Raises an Error */ let getExn: option<'a> => 'a /** -`getUnsafe(value)` returns `value` if `opt` is `Some(value)`, otherwise `undefined`. +`getUnsafe(opt)` returns `value` if `opt` is `Some(value)`, otherwise `undefined`. ## Examples