This repository was archived by the owner on Dec 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,12 @@ impl ToBase64 for [u8] {
191191 }
192192}
193193
194+ impl < ' a , T : ?Sized + ToBase64 > ToBase64 for & ' a T {
195+ fn to_base64 ( & self , config : Config ) -> String {
196+ ( * * self ) . to_base64 ( config)
197+ }
198+ }
199+
194200/// A trait for converting from base64 encoded values.
195201pub trait FromBase64 {
196202 /// Converts the value of `self`, interpreted as base64 encoded data, into
@@ -317,6 +323,12 @@ impl FromBase64 for [u8] {
317323 }
318324}
319325
326+ impl < ' a , T : ?Sized + FromBase64 > FromBase64 for & ' a T {
327+ fn from_base64 ( & self ) -> Result < Vec < u8 > , FromBase64Error > {
328+ ( * * self ) . from_base64 ( )
329+ }
330+ }
331+
320332/// Base64 decoding lookup table, generated using:
321333/// ```rust
322334/// let mut ch = 0u8;
Original file line number Diff line number Diff line change @@ -53,6 +53,12 @@ impl ToHex for [u8] {
5353 }
5454}
5555
56+ impl < ' a , T : ?Sized + ToHex > ToHex for & ' a T {
57+ fn to_hex ( & self ) -> String {
58+ ( * * self ) . to_hex ( )
59+ }
60+ }
61+
5662/// A trait for converting hexadecimal encoded values
5763pub trait FromHex {
5864 /// Converts the value of `self`, interpreted as hexadecimal encoded data,
@@ -155,6 +161,12 @@ impl FromHex for str {
155161 }
156162}
157163
164+ impl < ' a , T : ?Sized + FromHex > FromHex for & ' a T {
165+ fn from_hex ( & self ) -> Result < Vec < u8 > , FromHexError > {
166+ ( * * self ) . from_hex ( )
167+ }
168+ }
169+
158170#[ cfg( test) ]
159171mod tests {
160172 use hex:: { FromHex , ToHex } ;
You can’t perform that action at this time.
0 commit comments