Skip to content

Commit

Permalink
Revert as_str() change
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Feb 29, 2024
1 parent f2ed642 commit a8639b6
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions crates/quickjs-wasm-rs/src/js_binding/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,8 @@ impl<'a> JSValueRef<'a> {

/// Converts the JavaScript value to a string if it is a string.
pub fn as_str(&self) -> Result<&str> {
if self.is_str() {
let buffer = self.as_wtf8_str_buffer();
str::from_utf8(buffer).map_err(Into::into)
} else {
Err(anyhow!("Value {:?} is not a str", self.value))
}
let buffer = self.as_wtf8_str_buffer();
str::from_utf8(buffer).map_err(Into::into)
}

/// Converts the JavaScript value to a string, replacing any invalid UTF-8 sequences with the
Expand Down

0 comments on commit a8639b6

Please sign in to comment.