-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add methods to get Cx to ContextInternal
- Loading branch information
1 parent
bdf0183
commit 889b75b
Showing
3 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::{ | ||
context::{Context, Cx}, | ||
result::JsResult, | ||
types::extract::TryIntoJs, | ||
}; | ||
|
||
pub struct With<F>(pub F); | ||
|
||
impl<'cx, F, O> TryIntoJs<'cx> for With<F> | ||
where | ||
F: FnOnce(&mut Cx) -> O, | ||
O: TryIntoJs<'cx>, | ||
{ | ||
type Value = O::Value; | ||
|
||
fn try_into_js<C>(self, cx: &mut C) -> JsResult<'cx, Self::Value> | ||
where | ||
C: Context<'cx>, | ||
{ | ||
(self.0)(cx).try_into_js(cx) | ||
} | ||
} | ||
|
||
impl<F> super::private::Sealed for With<F> {} |