Skip to content

Commit 55e3005

Browse files
jdxgibbz00
authored andcommitted
fix: compatible with derive_more 2.1.0
The derive_more 2.1.0 release includes a fix for 'Missing trait bounds in AsRef/AsMut derives when associative types are involved' (#474). This fix adds additional where clauses to the generated impl blocks that require GenericArray to implement AsRef for itself, which it doesn't. Replace the derived AsRef with a manual implementation to avoid the trait bound issue while maintaining the same functionality.
1 parent 18772a5 commit 55e3005

3 files changed

Lines changed: 35 additions & 13 deletions

File tree

Cargo.lock

Lines changed: 26 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ chrono = { version = "0.4", features = ["serde"] }
2323
clap = { version = "4", features = ["derive"] }
2424
console = "0.15"
2525
ctrlc = "3"
26-
derive_more = { version = "2.0", features = ["display", "from", "deref", "deref_mut", "into", "as_ref"] }
26+
derive_more = { version = "2.1", features = ["display", "from", "deref", "deref_mut", "into", "as_ref"] }
2727
directories = "6"
2828
generic-array = "0.14"
2929
hex = "0.4"

crates/lib/src/cryptography/authorization_tag.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
use std::str::FromStr;
22

33
use aes_gcm::Tag;
4-
use derive_more::{AsMut, AsRef, From};
4+
use derive_more::{AsMut, From};
55
use generic_array::GenericArray;
66

77
use crate::*;
88

9-
#[derive(AsRef, AsMut, From)]
9+
#[derive(AsMut, From)]
1010
#[as_mut([u8])]
11-
#[as_ref[Tag<C::AuthorizationTagSize>]]
1211
#[impl_tools::autoimpl(Debug, PartialEq)]
1312
pub struct AuthorizationTag<C: Cipher>(GenericArray<u8, C::AuthorizationTagSize>);
1413

14+
impl<C: Cipher> AsRef<Tag<C::AuthorizationTagSize>> for AuthorizationTag<C> {
15+
fn as_ref(&self) -> &Tag<C::AuthorizationTagSize> {
16+
&self.0
17+
}
18+
}
19+
1520
impl<C: Cipher> FromStr for AuthorizationTag<C> {
1621
type Err = Base64DecodeError;
1722

0 commit comments

Comments
 (0)