Skip to content
This repository was archived by the owner on Nov 12, 2022. It is now read-only.

Commit 07e6ee9

Browse files
committed
Fixed Link to Examples in Documentation
1 parent 33b29de commit 07e6ee9

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/conversions.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,24 @@ impl<T: ToJSValConvertible> ToJSValConvertible for Option<T> {
545545
}
546546
}
547547

548+
impl<T: FromJSValConvertible> FromJSValConvertible for Option<T> {
549+
type Config = T::Config;
550+
unsafe fn from_jsval(
551+
cx: *mut JSContext,
552+
value: HandleValue,
553+
option: T::Config,
554+
) -> Result<ConversionResult<Option<T>>, ()> {
555+
if value.get().is_null_or_undefined() {
556+
Ok(ConversionResult::Success(None))
557+
} else {
558+
Ok(match FromJSValConvertible::from_jsval(cx, value, option)? {
559+
ConversionResult::Success(v) => ConversionResult::Success(Some(v)),
560+
ConversionResult::Failure(v) => ConversionResult::Failure(v),
561+
})
562+
}
563+
}
564+
}
565+
548566
impl<T: ToJSValConvertible> ToJSValConvertible for &'_ T {
549567
#[inline]
550568
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
@@ -566,24 +584,6 @@ impl<T: ToJSValConvertible> ToJSValConvertible for Rc<T> {
566584
}
567585
}
568586

569-
impl<T: FromJSValConvertible> FromJSValConvertible for Option<T> {
570-
type Config = T::Config;
571-
unsafe fn from_jsval(
572-
cx: *mut JSContext,
573-
value: HandleValue,
574-
option: T::Config,
575-
) -> Result<ConversionResult<Option<T>>, ()> {
576-
if value.get().is_null_or_undefined() {
577-
Ok(ConversionResult::Success(None))
578-
} else {
579-
Ok(match FromJSValConvertible::from_jsval(cx, value, option)? {
580-
ConversionResult::Success(v) => ConversionResult::Success(Some(v)),
581-
ConversionResult::Failure(v) => ConversionResult::Failure(v),
582-
})
583-
}
584-
}
585-
}
586-
587587
// https://heycam.github.io/webidl/#es-sequence
588588
impl<T: ToJSValConvertible> ToJSValConvertible for [T] {
589589
#[inline]

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
//! taking advantage of Rust's memory safety. For more about the Spidermonkey API, see the
2020
//! [API Reference][2] and the [User Guide][3] on MDN, and the [embedding examples][4] on GitHub.
2121
//!
22-
//! The code from User Guide sections [A minimal example](../../../examples/minimal.rs) and
23-
//! [Running scripts](../../../examples/eval.rs) are also included.
22+
//! The code from User Guide sections [A minimal example](https://github.com/servo/rust-mozjs/tree/master/examples/minimal.rs) and
23+
//! [Running scripts](https://github.com/servo/rust-mozjs/tree/master/examples/eval.rs) are also included.
2424
//!
2525
//! [1]: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey
2626
//! [2]: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference

0 commit comments

Comments
 (0)