Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastrac committed Feb 9, 2024
1 parent 23cd376 commit 6b1a4d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::any::type_name;
use std::convert::From;
use std::convert::Infallible;
use std::convert::TryFrom;
use std::error::Error;
use std::fmt;
Expand Down Expand Up @@ -247,6 +248,14 @@ impl DataError {
}
}

impl From<Infallible> for DataError {
fn from(_: Infallible) -> Self {
// While we wait for the never type to stabilize, this allows us to convert from the Infallible
// type: https://github.com/rust-lang/rust/issues/35121
unreachable!()
}
}

impl Display for DataError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Expand Down
3 changes: 3 additions & 0 deletions tests/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5309,6 +5309,9 @@ fn snapshot_creator() {
context_data_index_2,
);
assert!(matches!(bad_type_err, Err(v8::DataError::BadType { .. })));
// Ensure we can compile a request for v8::Data
scope
.get_context_data_from_snapshot_once::<v8::Data>(context_data_index_2);
}
}
}
Expand Down

0 comments on commit 6b1a4d0

Please sign in to comment.