Skip to content

Commit

Permalink
Merge pull request #6 from quodlibetor/enable-clippy
Browse files Browse the repository at this point in the history
Enable clippy in CI, fix justified lints
  • Loading branch information
quodlibetor authored Jun 20, 2024
2 parents ec0a018 + db1af9f commit 65ddc7a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ jobs:
- name: Set up Rust
uses: moonrepo/setup-rust@v1
with:
channel: ${{ matrix.rust-version }}
bins: cargo-nextest
channel: ${{ matrix.rust-version }}
components: clippy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -47,3 +48,6 @@ jobs:
run: cargo nextest run --features diesel-uuid,serde
env:
PG_DATABASE_URL: postgres://postgres:postgres@localhost/postgres

- name: Clippy
run: cargo clippy --features diesel-uuid,serde
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ impl UuidB64 {
let mut buf = InlineString::from("0000000000000000000000"); // not actually zeroes
unsafe {
let raw_buf = buf.as_mut_slice();
URL_SAFE_NO_PAD.encode_slice(self.0.as_bytes(), &mut raw_buf[0..22]).unwrap();
URL_SAFE_NO_PAD
.encode_slice(self.0.as_bytes(), &mut raw_buf[0..22])
.unwrap();
}
buf
}
Expand Down Expand Up @@ -184,13 +186,21 @@ impl FromStr for UuidB64 {

fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut output = [0; 16];
URL_SAFE_NO_PAD.decode_slice(s, &mut output)
URL_SAFE_NO_PAD
.decode_slice(s, &mut output)
.chain_err(|| ErrorKind::ParseError(s.into()))?;
let id = Uuid::from_bytes(output);
Ok(UuidB64(id))
}
}

/// Construct a new V4 (random) UUID
impl Default for UuidB64 {
fn default() -> Self {
Self::new()
}
}

/// Right now this is just `Uuid`, but anything Uuid is comfortable with, we are
impl<T> From<T> for UuidB64
where
Expand Down
2 changes: 1 addition & 1 deletion src/serde_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'de> Visitor<'de> for UuidB64Visitor {
where
E: de::Error,
{
Ok(s.parse().map_err(de::Error::custom)?)
s.parse().map_err(de::Error::custom)
}
}

Expand Down

0 comments on commit 65ddc7a

Please sign in to comment.