Lines Matching refs:Maybe
14 // Called when ToChecked is called on an empty Maybe.
19 * A simple Maybe type, representing an object which may or may not have a
20 * value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
22 * If an API method returns a Maybe<>, the API method can potentially fail
29 class Maybe {
35 * An alias for |FromJust|. Will crash if the Maybe<> is nothing.
41 * the actual value of the Maybe is not needed like Object::Set.
48 * Converts this Maybe<> to a value of type T. If this Maybe<> is
57 * Converts this Maybe<> to a value of type T. If this Maybe<> is
66 * Converts this Maybe<> to a value of type T, using a default value if this
67 * Maybe<> is nothing (empty).
73 V8_INLINE bool operator==(const Maybe& other) const {
78 V8_INLINE bool operator!=(const Maybe& other) const {
83 Maybe() : has_value_(false) {}
84 explicit Maybe(const T& t) : has_value_(true), value_(t) {}
90 friend Maybe<U> Nothing();
92 friend Maybe<U> Just(const U& u);
96 inline Maybe<T> Nothing() {
97 return Maybe<T>();
101 inline Maybe<T> Just(const T& t) {
102 return Maybe<T>(t);
105 // A template specialization of Maybe<T> for the case of T = void.
107 class Maybe<void> {
112 V8_INLINE bool operator==(const Maybe& other) const {
116 V8_INLINE bool operator!=(const Maybe& other) const {
123 Maybe() : is_valid_(false) {}
124 explicit Maybe(JustTag) : is_valid_(true) {}
129 friend Maybe<U> Nothing();
130 friend Maybe<void> JustVoid();
133 inline Maybe<void> JustVoid() { return Maybe<void>(Maybe<void>::JustTag()); }