Skip to content

Commit

Permalink
✨ New: serde as feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaza-Kun committed May 26, 2024
1 parent f082f30 commit 2c3716a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion wasm-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion wasm-rs/onc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "onc"
version = "0.2.0"
version = "0.2.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -14,3 +14,4 @@ serde = { version = "1.0.197", features = ["derive"] }

[features]
faker = ["dep:rand", "dep:rand_chacha"]
serde = []
1 change: 1 addition & 0 deletions wasm-rs/onc/src/phonotactics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use rand::{prelude::SliceRandom, SeedableRng};
use rand_chacha::ChaCha8Rng;

#[derive(Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct PhonotacticRule {
definition: SyllableTags<String>,
}
Expand Down
7 changes: 4 additions & 3 deletions wasm-rs/onc/src/phonotactics/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ use nom::{
bytes::complete::tag_no_case, combinator::opt, error::ParseError, multi::many0,
sequence::tuple, Compare, IResult, InputLength, InputTake, Parser,
};
use serde::Deserialize;

use super::{Phrase, SyllableUnit};

#[derive(Clone, Deserialize, Default)]
#[derive(Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct AltTagVec<T> {
pub items: Vec<T>,
#[serde(skip)]
index: usize,
}

#[derive(Clone, Deserialize, Default)]
#[derive(Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct SyllableTags<T> {
pub onset: AltTagVec<T>,
pub nucleus: AltTagVec<T>,
Expand Down

0 comments on commit 2c3716a

Please sign in to comment.