Skip to content

Commit

Permalink
fix: complete clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tmorin committed Nov 11, 2023
1 parent 70cba95 commit dba3ce0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/cmd/diagram/generate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn get_last_modified(path: &Path) -> Result<i64> {
))
})?;
let date_time: DateTime<Local> = DateTime::from(modified);
Ok(date_time.timestamp_nanos())
Ok(date_time.timestamp_nanos_opt().unwrap())
}
false => Ok(0),
}
Expand All @@ -56,7 +56,7 @@ fn get_last_generation_timestamp(last_gen_path: &Path) -> Result<i64> {

fn save_last_generation_timestamp(last_gen_path: &Path) -> Result<()> {
let now: DateTime<Local> = DateTime::from(SystemTime::now());
let value = now.timestamp_nanos().to_string();
let value = now.timestamp_nanos_opt().unwrap().to_string();
log::debug!("save_last_generation_timestamp {}", value);
let mut last_gen_file = OpenOptions::new()
.create(true)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/workspace/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn execute_workspace_init(arg_matches: &ArgMatches) -> Result<()> {
let manifest_path = source_path.join(&config.workspace_manifest);
// stop if manifest already exists
if manifest_path.exists() {
return Err(anyhow::Error::msg(format!(
Err(anyhow::Error::msg(format!(
"The manifest {} already exists",
manifest_path.to_str().unwrap(),
)))?;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/workspace/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn execute_workspace_install(arg_matches: &ArgMatches) -> anyhow::Result<()>

// stop if manifest doesn't exists
if !manifest_path.exists() {
return Err(anyhow::Error::msg(format!(
Err(anyhow::Error::msg(format!(
"the manifest {} doesn't exists",
manifest_path.to_str().unwrap(),
)))?;
Expand Down
30 changes: 15 additions & 15 deletions src/urn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::str::FromStr;

use heck::ToTitleCase;
use schemars::JsonSchema;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{Error, Visitor};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[derive(Debug, Clone, JsonSchema)]
pub struct Urn {
Expand Down Expand Up @@ -37,13 +37,13 @@ impl Urn {
pub fn is_included_in(&self, urns: &[Urn]) -> bool {
urns.is_empty()
|| urns.iter().any(|other| {
// OK if descendant
if other.value.len() <= self.value.len() && self.value.starts_with(&other.value) {
return true;
}
// OK if ancestor
other.value.starts_with(&self.value)
})
// OK if descendant
if other.value.len() <= self.value.len() && self.value.starts_with(&other.value) {
return true;
}
// OK if ancestor
other.value.starts_with(&self.value)
})
}
}

Expand All @@ -55,17 +55,17 @@ impl fmt::Display for Urn {

impl Serialize for Urn {
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where
S: Serializer,
where
S: Serializer,
{
serializer.serialize_str(&self.value)
}
}

impl<'de> Deserialize<'de> for Urn {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
where
D: Deserializer<'de>,
{
struct UrnVisitor;

Expand All @@ -77,8 +77,8 @@ impl<'de> Deserialize<'de> for Urn {
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: Error,
where
E: Error,
{
Ok(Urn::from(v))
}
Expand All @@ -97,7 +97,7 @@ impl FromStr for Urn {

impl From<&str> for Urn {
fn from(value: &str) -> Self {
let parts: Vec<&str> = value.split('/').skip(0).map(|_| "..").collect();
let parts: Vec<&str> = value.split('/').map(|_| "..").collect();
let path_to_base = match parts.is_empty() {
true => ".".to_string(),
false => parts.join("/"),
Expand Down

0 comments on commit dba3ce0

Please sign in to comment.