diff --git a/src/lib.rs b/src/lib.rs index 6f617b2..9d1fe24 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,13 +109,16 @@ impl Number { /// /// # Panics /// This function cannot be executed in an async runtime, as per [`reqwest::blocking`] restriction. - pub fn with_client(number: T, client: reqwest::blocking::Client) -> Result { + pub fn with_client( + number: T, + client: reqwest::blocking::Client, + ) -> Result { let url = format!("{}?query={}", ENDPOINT, number); let response = client.get(url).send()?; if response.status().is_success() { match response.json() { Ok(n) => Ok(n), - Err(e) => Err(e.into()) + Err(e) => Err(e.into()), } } else { Err(FactorDbError::InvalidNumber) @@ -157,10 +160,14 @@ pub struct Factor(String, i32); impl Factor { /// Returns the base as a [`BigInt`]. - pub fn base(&self) -> BigInt { BigInt::from_str(&self.0).unwrap() } + pub fn base(&self) -> BigInt { + BigInt::from_str(&self.0).unwrap() + } /// Returns the exponent as a [`BigInt`]. - pub fn exponent(&self) -> BigInt { BigInt::from(self.1) } + pub fn exponent(&self) -> BigInt { + BigInt::from(self.1) + } } impl Display for Factor { @@ -208,7 +215,7 @@ pub enum FactorDbError { RequestError(#[from] reqwest::Error), /// Invalid number #[error("Invalid number")] - InvalidNumber + InvalidNumber, } #[cfg(test)] diff --git a/src/main.rs b/src/main.rs index 7a79816..e7a75d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ -use std::process::exit; -use clap::Parser; use ansi_term::Colour::Red; +use clap::Parser; use factordb::Number; +use std::process::exit; /// Finds a factor to a number using FactorDB (http://factordb.com/) #[derive(Parser, Debug)] @@ -26,10 +26,10 @@ fn main() { println!("{}", f); } } - }, + } Err(e) => { eprintln!("{} {}", Red.paint("error:"), e); exit(1); } } -} \ No newline at end of file +} diff --git a/src/utils.rs b/src/utils.rs index 5394853..9e9f1c9 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,6 @@ -use std::fmt; -use serde::{de, Deserializer}; use serde::de::Unexpected; +use serde::{de, Deserializer}; +use std::fmt; // https://stackoverflow.com/questions/37870428/convert-two-types-into-a-single-type-with-serde @@ -37,4 +37,4 @@ where D: Deserializer<'de>, { deserializer.deserialize_any(DeserializeIdVisitor) -} \ No newline at end of file +}