mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Use safe NonZero constructor instead of an explicit null check
This commit is contained in:
parent
10ec5a2bb0
commit
b78ac6ba6a
4 changed files with 6 additions and 10 deletions
|
@ -154,8 +154,7 @@ impl TestBindingMethods for TestBinding {
|
|||
#[allow(unsafe_code)]
|
||||
unsafe fn ArrayAttribute(&self, cx: *mut JSContext) -> NonNull<JSObject> {
|
||||
rooted!(in(cx) let array = JS_NewUint8ClampedArray(cx, 16));
|
||||
assert!(!array.is_null());
|
||||
NonNull::new_unchecked(array.get())
|
||||
NonNull::new(array.get()).expect("got a null pointer")
|
||||
}
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn AnyAttribute(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||
|
@ -164,8 +163,7 @@ impl TestBindingMethods for TestBinding {
|
|||
#[allow(unsafe_code)]
|
||||
unsafe fn ObjectAttribute(&self, cx: *mut JSContext) -> NonNull<JSObject> {
|
||||
rooted!(in(cx) let obj = JS_NewPlainObject(cx));
|
||||
assert!(!obj.is_null());
|
||||
NonNull::new_unchecked(obj.get())
|
||||
NonNull::new(obj.get()).expect("got a null pointer")
|
||||
}
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn SetObjectAttribute(&self, _: *mut JSContext, _: *mut JSObject) {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue