Skip to content

Commit

Permalink
Merge pull request #9 from myelin-ai/add-serde-support
Browse files Browse the repository at this point in the history
Add serde support
  • Loading branch information
Ruben Schmidmeister authored Nov 17, 2020
2 parents 06fa048 + 0ffd498 commit bd3f914
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ install:
- rustup component add clippy rustfmt

script:
- cargo build
- cargo test
- cargo clippy -- -Dwarnings
- cargo build --all-features
- cargo test --all-features
- cargo clippy --all-features -- -Dwarnings
- cargo fmt --all -- --check
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "unordered-pair"
description = "A tuple struct representing an unordered pair"
version = "0.2.2"
version = "0.2.3"
authors = [
"Jeremy Stucki <[email protected]>",
"Ruben Schmidmeister <[email protected]>",
Expand All @@ -12,3 +12,9 @@ repository = "https://github.com/myelin-ai/unordered-pair"
homepage = "https://github.com/myelin-ai/unordered-pair"
documentation = "https://docs.rs/unordered-pair"
edition = "2018"

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

[package.metadata.docs.rs]
all-features = true
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
## 0.2.2
- Derive Copy

## 0.2.3
- Add support for Serialization/Deserialization using serde.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! This crate provides a tuple struct for an unordered pair
//! ## Crate Features
//! - `serde`: Enables serde support for [`UnorderedPair`].
#![deny(
rust_2018_idioms,
Expand All @@ -13,6 +15,7 @@ use std::hash::{Hash, Hasher};

/// A tuple struct representing an unordered pair
#[derive(Debug, Copy, Clone, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct UnorderedPair<T>(pub T, pub T);

impl<T> From<(T, T)> for UnorderedPair<T> {
Expand Down

0 comments on commit bd3f914

Please sign in to comment.