Skip to content

Commit

Permalink
CR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Razz4780 committed Feb 7, 2025
1 parent 028f79c commit ab3e69b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions mirrord/agent/env/src/checked_env.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
any,
convert::Infallible,
fmt,
marker::PhantomData,
Expand Down Expand Up @@ -39,15 +40,15 @@ impl<T: StoredAsString> EnvValue for T {
}

fn from_repr(repr: &[u8]) -> Result<Self, Self::FromReprError> {
let as_str = std::str::from_utf8(repr).map_err(ParseEnvError::Utf8Error)?;
let as_str = std::str::from_utf8(repr)?;
as_str.parse().map_err(ParseEnvError::ParseError)
}
}

/// Errors that can occur when reading a [`StoredAsString`] environment variable value.
#[derive(Error, Debug)]
pub enum ParseEnvError<E> {
Utf8Error(#[source] Utf8Error),
Utf8Error(#[from] Utf8Error),
ParseError(#[source] E),
}

Expand Down Expand Up @@ -118,7 +119,10 @@ impl CheckedEnv<bool> {

impl<V: EnvValue> fmt::Debug for CheckedEnv<V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.name)
f.debug_struct("CheckedEnv")
.field("name", &self.name)
.field("value_type", &any::type_name::<V>())
.finish()
}
}

Expand Down Expand Up @@ -149,7 +153,7 @@ impl EnvValue for Vec<IpAddr> {
}

fn from_repr(repr: &[u8]) -> Result<Self, Self::FromReprError> {
let as_str = std::str::from_utf8(repr).map_err(ParseEnvError::Utf8Error)?;
let as_str = std::str::from_utf8(repr)?;

as_str
.split(',')
Expand Down

0 comments on commit ab3e69b

Please sign in to comment.