Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::fmt::{LowerHex, UpperHex};
use std::{
fmt::{Binary, Display},
u128,

Check warning on line 7 in src/id.rs

View workflow job for this annotation

GitHub Actions / clippy

importing legacy numeric constants

warning: importing legacy numeric constants --> src/id.rs:7:5 | 7 | u128, | ^^^^ | = help: remove this import = note: then `u128::<CONST>` will resolve to the respective associated constant = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default
};

#[derive(Debug, Eq, Clone, Copy)]
Expand Down Expand Up @@ -48,11 +48,11 @@
}
}

impl PartialOrd for Flake {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.0.cmp(&other.0))
}
}

Check warning on line 55 in src/id.rs

View workflow job for this annotation

GitHub Actions / clippy

non-canonical implementation of `partial_cmp` on an `Ord` type

warning: non-canonical implementation of `partial_cmp` on an `Ord` type --> src/id.rs:51:1 | 51 | / impl PartialOrd for Flake { 52 | | fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | | _______________________________________________________________________- 53 | || Some(self.0.cmp(&other.0)) 54 | || } | ||_____- help: change this to: `{ Some(self.cmp(other)) }` 55 | | } | |__^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#non_canonical_partial_ord_impl = note: `#[warn(clippy::non_canonical_partial_ord_impl)]` on by default

impl Ord for Flake {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
Expand Down Expand Up @@ -86,7 +86,7 @@

impl Display for Flake {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&BASE64.encode(&self.0.to_be_bytes()))
f.write_str(&BASE64.encode(&self.0.to_le_bytes()))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'de> Visitor<'de> for FlakeVisitor {
for (i, byte) in decoded_bytes.iter().take(bytes.len()).enumerate() {
bytes[i] = *byte;
}
let value = u128::from_be_bytes(bytes);
let value = u128::from_le_bytes(bytes);
Ok(Flake::new(value))
}

Expand All @@ -62,5 +62,5 @@ impl<'de> Visitor<'de> for FlakeVisitor {
#[test]
fn test_serde() {
let id = Flake::new(29866156537351941961353716432896);
assert_tokens(&id, &[Token::String("AAABePbBqL900Cue9CYAAA==")]);
assert_tokens(&id, &[Token::String("AAAm9J4r0HS/qMH2eAEAAA==")]);
}