Lines Matching refs:Maybe

17 // Called when ToChecked is called on an empty Maybe.
22 * A simple Maybe type, representing an object which may or may not have a
23 * value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
25 * If an API method returns a Maybe<>, the API method can potentially fail
32 class Maybe {
38 * An alias for |FromJust|. Will crash if the Maybe<> is nothing.
44 * the actual value of the Maybe is not needed like Object::Set.
51 * Converts this Maybe<> to a value of type T. If this Maybe<> is
60 * Converts this Maybe<> to a value of type T. If this Maybe<> is
69 * Converts this Maybe<> to a value of type T. If this Maybe<> is
78 * Converts this Maybe<> to a value of type T, using a default value if this
79 * Maybe<> is nothing (empty).
85 V8_INLINE bool operator==(const Maybe& other) const {
90 V8_INLINE bool operator!=(const Maybe& other) const {
95 Maybe() : has_value_(false) {}
96 explicit Maybe(const T& t) : has_value_(true), value_(t) {}
97 explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {}
103 friend Maybe<U> Nothing();
105 friend Maybe<U> Just(const U& u);
107 friend Maybe<U> Just(U&& u);
111 inline Maybe<T> Nothing() {
112 return Maybe<T>();
116 inline Maybe<T> Just(const T& t) {
117 return Maybe<T>(t);
124 inline Maybe<T> Just(T&& t) {
125 return Maybe<T>(std::move(t));
128 // A template specialization of Maybe<T> for the case of T = void.
130 class Maybe<void> {
135 V8_INLINE bool operator==(const Maybe& other) const {
139 V8_INLINE bool operator!=(const Maybe& other) const {
146 Maybe() : is_valid_(false) {}
147 explicit Maybe(JustTag) : is_valid_(true) {}
152 friend Maybe<U> Nothing();
153 friend Maybe<void> JustVoid();
156 inline Maybe<void> JustVoid() { return Maybe<void>(Maybe<void>::JustTag()); }