-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug when using custom_extensions and initials together, made lo…
…ckfile alphabetical to prevent annoying git diffs when nothing changed (#13)
- Loading branch information
Showing
7 changed files
with
93 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
mod ordered_map_serializer; | ||
pub mod user_input; | ||
pub use ordered_map_serializer::ordered_map_serializer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::collections::{BTreeMap, HashMap}; | ||
|
||
use serde::{Serialize, Serializer}; | ||
|
||
/// For use with serde's [serialize_with] attribute. | ||
/// | ||
/// Will make a hashmap alphabetically ordered by key on serialization. | ||
/// | ||
/// Source: https://stackoverflow.com/questions/42723065/how-to-sort-hashmap-keys-when-serializing-with-serde | ||
pub fn ordered_map_serializer<S, K: Ord + Serialize, V: Serialize>( | ||
value: &HashMap<K, V>, | ||
serializer: S, | ||
) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
let ordered: BTreeMap<_, _> = value.iter().collect(); | ||
ordered.serialize(serializer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters