Skip to content

Commit

Permalink
Release v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
aurexav committed Jan 8, 2025
1 parent c02c299 commit 3cb835c
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 32 deletions.
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# System
.DS_Store

# Integrated development environment
# Integrated development environment.
.vscode

# Package manager
## Cargo
# Package manager.
## Cargo.
target
## NPM
## NPM.
node_modules

# Test data
# System.
.DS_Store

# Test data.
tmp
8 changes: 4 additions & 4 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Basic
# Basic.
edition = "2021"
hard_tabs = true
max_width = 100
tab_spaces = 4

# Imports
# Import.
imports_granularity = "Crate"
reorder_imports = true

# Format comments
# Comments.
comment_width = 100
wrap_comments = true

# Misc
# Misc.
format_code_in_doc_comments = true
inline_attribute_width = 100
match_arm_blocks = false
Expand Down
59 changes: 45 additions & 14 deletions Cargo.lock

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

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ license = "GPL-3.0"
name = "language"
readme = "README.md"
repository = "https://github.com/hack-ink/language"
version = "0.1.2"
version = "0.1.3"

[profile.ci-dev]
incremental = false
inherits = "dev"

# [profile.ci-release]
# inherits = "release"
# lto = true

[dependencies]
serde = { version = "1.0", optional = true, features = ["derive"] }

[dev-dependencies]
serde_json = { version = "1.0" }
14 changes: 13 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ use serde::{
ser::Serializer,
Deserialize, Serialize,
};
#[cfg(all(not(feature = "serde"), test))] use serde_json as _;
// self
use Language::*;

/// Language collection.
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Language {
/// Afrikaans (South Africa)
Expand Down Expand Up @@ -1818,3 +1819,14 @@ impl<'de> Deserialize<'de> for Language {
Language::from_tag(&tag).ok_or_else(|| Error::unknown_variant(&tag, &[]))
}
}

#[cfg(feature = "serde")]
#[test]
fn serde_should_work() {
let lang = Language::EnUs;
let serialized = serde_json::to_string(&lang).unwrap();
assert_eq!(serialized, "\"en-US\"");

let deserialized: Language = serde_json::from_str(&serialized).unwrap();
assert_eq!(deserialized, lang);
}

0 comments on commit 3cb835c

Please sign in to comment.