script: Expose new methods for obtaining a global that require a realm. (#36116)

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-03-26 19:27:25 -04:00 committed by GitHub
parent 73e7d38a8d
commit 1df1ba58d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 42 additions and 19 deletions

View file

@ -33,6 +33,18 @@ pub(crate) enum InRealm<'a> {
Entered(&'a JSAutoRealm),
}
impl<'a> From<&'a AlreadyInRealm> for InRealm<'a> {
fn from(token: &'a AlreadyInRealm) -> InRealm<'a> {
InRealm::already(token)
}
}
impl<'a> From<&'a JSAutoRealm> for InRealm<'a> {
fn from(token: &'a JSAutoRealm) -> InRealm<'a> {
InRealm::entered(token)
}
}
impl InRealm<'_> {
pub(crate) fn already(token: &AlreadyInRealm) -> InRealm {
InRealm::Already(token)