Skip to content

Commit

Permalink
lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dherman committed Feb 2, 2025
1 parent 837cbfe commit 08dae0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 1 addition & 3 deletions crates/neon/src/types_impl/extract/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ impl<'cx, T: 'static> TryFromJs<'cx> for RefMut<'cx, T> {
match v.downcast::<JsBox<RefCell<T>>, _>(cx) {
Ok(v) => {
let cell = JsBox::deref(&v);
Ok(cell
.try_borrow_mut()
.map_err(|_| RefCellError::Borrowed))
Ok(cell.try_borrow_mut().map_err(|_| RefCellError::Borrowed))
}
Err(_) => Ok(Err(RefCellError::WrongType)),
}
Expand Down
16 changes: 11 additions & 5 deletions test/napi/src/js/container.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use neon::{prelude::*, types::extract::Error};
use neon::prelude::*;

use std::cell::{Ref, RefCell, RefMut};

Expand Down Expand Up @@ -33,16 +33,22 @@ fn write_string_ref(mut s: RefMut<String>, value: String) {
}

#[neon::export]
fn borrow_and_then<'cx>(cx: &mut Cx<'cx>, cell: &RefCell<String>, f: Handle<JsFunction>)
-> JsResult<'cx, JsString> {
fn borrow_and_then<'cx>(
cx: &mut Cx<'cx>,
cell: &RefCell<String>,
f: Handle<JsFunction>,
) -> JsResult<'cx, JsString> {
let s = cell.borrow();
f.bind(cx).exec()?;
Ok(cx.string(s.clone()))
}

#[neon::export]
fn borrow_mut_and_then<'cx>(cx: &mut Cx<'cx>, cell: &RefCell<String>, f: Handle<JsFunction>)
-> JsResult<'cx, JsString> {
fn borrow_mut_and_then<'cx>(
cx: &mut Cx<'cx>,
cell: &RefCell<String>,
f: Handle<JsFunction>,
) -> JsResult<'cx, JsString> {
let mut s = cell.borrow_mut();
f.bind(cx).exec()?;
*s = "overwritten".to_string();
Expand Down

0 comments on commit 08dae0e

Please sign in to comment.