Fixing `Punctuation` deserialize without argument.
@@ -10,9 +10,14 @@ fn is_punc(x: char) -> bool {
#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
#[serde(tag = "type")]
pub struct Punctuation {
+ #[serde(default = "default_split")]
behavior: SplitDelimiterBehavior,
}
+fn default_split() -> SplitDelimiterBehavior {
+ SplitDelimiterBehavior::Isolated
+}
+
impl Punctuation {
pub fn new(behavior: SplitDelimiterBehavior) -> Self {
Self { behavior }
@@ -57,4 +62,9 @@ mod tests {
]
);
}
+
+ #[test]
+ fn deserialization() {
+ let _punctuation: Punctuation = serde_json::from_str(r#"{"type": "punctuation"}"#).unwrap();
+ }
}
