Skip to content

Commit

Permalink
fix wasm clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
anweiss committed Sep 26, 2022
1 parent 3e2b99e commit 637360d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,22 @@ crossterm = { version = "0.25.0", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1.6"
wasm-bindgen = { version = "0.2.75", features = ["serde-serialize"], optional = true }
serde-wasm-bindgen = { version = "0.4", optional = true }
wasm-bindgen = { version = "0.2", optional = true }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.25"

[features]
default = ["std", "ast-span", "ast-comments", "json", "cbor", "additional-controls"]
std = ["base16/alloc", "base64/alloc", "serde_json", "ciborium", "serde", "chrono", "wasm-bindgen", "clap", "crossterm", "uriparse", "base64-url", "regex-syntax"]
std = ["base16/alloc", "base64/alloc", "serde_json", "ciborium", "serde", "chrono", "wasm-bindgen", "serde-wasm-bindgen", "clap", "crossterm", "uriparse", "base64-url", "regex-syntax"]
lsp = ["std"]
additional-controls = []
ast-span = []
ast-comments = []
json = ["std"]
cbor = ["std"]
web = ["ast-span", "wasm-bindgen", "serde"]
web = ["ast-span", "wasm-bindgen", "serde-wasm-bindgen", "serde"]

[[bin]]
name = "cddl"
Expand Down
6 changes: 3 additions & 3 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use alloc::{
pub type Span = (usize, usize, usize);

#[cfg(feature = "ast-comments")]
#[derive(Default, Debug, PartialEq, Clone)]
#[derive(Default, Debug, PartialEq, Eq, Clone)]
#[doc(hidden)]
pub struct Comments<'a>(pub Vec<&'a str>);

Expand Down Expand Up @@ -943,7 +943,7 @@ impl<'a> fmt::Display for Type1<'a> {
/// ctlop = "." id
/// ```
#[cfg_attr(target_arch = "wasm32", derive(Serialize))]
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum RangeCtlOp<'a> {
/// Range operator
RangeOp {
Expand Down Expand Up @@ -2819,7 +2819,7 @@ impl<'a> fmt::Display for MemberKey<'a> {
/// / "?"
/// ```
#[cfg_attr(target_arch = "wasm32", derive(Serialize))]
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Occur {
/// Occurrence indicator in the form n*m, where n is an optional lower limit
/// and m is an optional upper limit
Expand Down
4 changes: 2 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3529,11 +3529,11 @@ pub fn cddl_from_str(input: &str) -> result::Result<JsValue, JsValue> {

match Parser::new(input, Box::new(lexer::Lexer::new(input).iter())) {
Ok(mut p) => match p.parse_cddl() {
Ok(c) => JsValue::from_serde(&c).map_err(|e| JsValue::from(e.to_string())),
Ok(c) => serde_wasm_bindgen::to_value(&c).map_err(|e| JsValue::from(e.to_string())),
Err(Error::INCREMENTAL) => {
if !p.errors.is_empty() {
return Err(
JsValue::from_serde(
serde_wasm_bindgen::to_value(
&p.errors
.iter()
.filter_map(|e| {
Expand Down
4 changes: 2 additions & 2 deletions src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl<'a> From<&'a str> for Value<'a> {

/// Byte string values
#[cfg_attr(target_arch = "wasm32", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum ByteValue<'a> {
/// Unprefixed byte string value
UTF8(Cow<'a, [u8]>),
Expand Down Expand Up @@ -438,7 +438,7 @@ impl<'a> fmt::Display for ByteValue<'a> {

/// Socket/plug prefix
#[cfg_attr(target_arch = "wasm32", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum SocketPlug {
/// Type socket `$`
TYPE,
Expand Down
4 changes: 2 additions & 2 deletions src/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn validate_json_from_str(
let c = p.parse_cddl().map_err(|e| JsValue::from(e.to_string()))?;
if !p.errors.is_empty() {
return Err(
JsValue::from_serde(
serde_wasm_bindgen::to_value(
&p.errors
.iter()
.filter_map(|e| {
Expand Down Expand Up @@ -231,7 +231,7 @@ pub fn validate_cbor_from_slice(
let c = p.parse_cddl().map_err(|e| JsValue::from(e.to_string()))?;
if !p.errors.is_empty() {
return Err(
JsValue::from_serde(
serde_wasm_bindgen::to_value(
&p.errors
.iter()
.filter_map(|e| {
Expand Down

0 comments on commit 637360d

Please sign in to comment.