Skip to content

Commit

Permalink
feature: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
shenek committed Jan 19, 2024
1 parent a2bc4c8 commit f1d9fe3
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 163 deletions.
113 changes: 8 additions & 105 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions ucelofka-data/src/invoice/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Invoice {
.iter()
.map(|i| i.id + 1)
.max()
.unwrap_or_else(|| Utc::today().naive_utc().year() as u64 * 100_000 + 1)
.unwrap_or_else(|| Utc::now().date_naive().year() as u64 * 100_000 + 1)
}

pub fn new(
Expand All @@ -86,7 +86,7 @@ impl Invoice {
Self {
_version: VERSION,
id: new_id,
issue_day: Utc::today().format("%Y-%m-%d").to_string(),
issue_day: Utc::now().format("%Y-%m-%d").to_string(),
due_day: (Utc::now() + Duration::days(DEFAULT_DUE))
.format("%Y-%m-%d")
.to_string(),
Expand Down
4 changes: 2 additions & 2 deletions ucelofka-data/src/invoice/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Invoice {
.iter()
.map(|i| i.id + 1)
.max()
.unwrap_or_else(|| Utc::today().naive_utc().year() as u64 * 100_000 + 1)
.unwrap_or_else(|| Utc::now().date_naive().year() as u64 * 100_000 + 1)
}

pub fn new(
Expand All @@ -110,7 +110,7 @@ impl Invoice {
Self {
_version: VERSION,
id: new_id,
issue_date: Utc::today().format("%Y-%m-%d").to_string(),
issue_date: Utc::now().format("%Y-%m-%d").to_string(),
due_date: (Utc::now()
+ Duration::days(
due.map(|v| i64::try_from(v).unwrap())
Expand Down
10 changes: 5 additions & 5 deletions ucelofka-data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ struct Ver {
pub _version: u32,
}

impl Into<u32> for Ver {
fn into(self) -> u32 {
self._version
impl From<Ver> for u32 {
fn from(value: Ver) -> Self {
value._version
}
}

impl TryFrom<&str> for Ver {
type Error = serde_yaml::Error;

fn try_from(input: &str) -> Result<Self, Self::Error> {
Ok(serde_yaml::from_str(input)?)
serde_yaml::from_str(input)
}
}

Expand Down Expand Up @@ -69,7 +69,7 @@ macro_rules! data_try_from {
type Error = serde_yaml::Error;

fn try_from(input: String) -> Result<Self, Self::Error> {
Ok(serde_yaml::from_str(&input)?)
serde_yaml::from_str(&input)
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion ucelofka-data/src/template/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Template {
pub text: Option<String>,
}

impl<'a> fmt::Display for Template {
impl fmt::Display for Template {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} ({})", self.name, self.path.to_str().unwrap())?;
if let Some(text) = &self.text {
Expand Down
2 changes: 1 addition & 1 deletion ucelofka/src/actions/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn ids(data_path: &Path) -> Result<String> {

pub fn list(data_path: &Path) -> Result<Accounts> {
let account_path = data_path.join(Path::new("accounts"));
Ok(Accounts::load(account_path.as_path())?)
Accounts::load(account_path.as_path())
}

pub fn get(data_path: &Path, id: &str) -> Result<Account> {
Expand Down
6 changes: 3 additions & 3 deletions ucelofka/src/actions/customer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ pub fn ids(data_path: &Path) -> Result<String> {

pub fn list(data_path: &Path) -> Result<Customers> {
let customer_path = data_path.join(Path::new("customers"));
Ok(Customers::load(customer_path.as_path())?)
Customers::load(customer_path.as_path())
}

pub fn get(data_path: &Path, id: &str) -> Result<Customer> {
Ok(list(data_path)?
list(data_path)?
.get(id)
.ok_or_else(|| anyhow!("Customer {} not found.", id))?)
.ok_or_else(|| anyhow!("Customer {} not found.", id))
}
6 changes: 3 additions & 3 deletions ucelofka/src/actions/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub fn ids(data_path: &Path) -> Result<String> {

pub fn list(data_path: &Path) -> Result<Entries> {
let entry_path = data_path.join(Path::new("entries"));
Ok(Entries::load(entry_path.as_path())?)
Entries::load(entry_path.as_path())
}

pub fn get(data_path: &Path, id: &str) -> Result<Entry> {
Ok(list(data_path)?
list(data_path)?
.get(id)
.ok_or_else(|| anyhow!("Entry {} not found.", id))?)
.ok_or_else(|| anyhow!("Entry {} not found.", id))
}

pub fn create(
Expand Down
6 changes: 3 additions & 3 deletions ucelofka/src/actions/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ pub fn ids(data_path: &Path) -> Result<String> {

pub fn list(data_path: &Path) -> Result<Identities> {
let identity_path = data_path.join(Path::new("identities"));
Ok(Identities::load(identity_path.as_path())?)
Identities::load(identity_path.as_path())
}

pub fn get(data_path: &Path, id: &str) -> Result<Identity> {
Ok(list(data_path)?
list(data_path)?
.get(id)
.ok_or_else(|| anyhow!("Identity {} not found.", id))?)
.ok_or_else(|| anyhow!("Identity {} not found.", id))
}
2 changes: 1 addition & 1 deletion ucelofka/src/actions/ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn ids(data_path: &Path) -> Result<String> {
result += &template::list(data_path)?
.templates
.iter()
.map(|template| format!("{}\n", template.name))
.map(|template| template.name.clone() + "\n")
.collect::<String>();

Ok(result)
Expand Down
Loading

0 comments on commit f1d9fe3

Please sign in to comment.