Skip to content

Commit

Permalink
refactor: "".to_owned() -> String::new()
Browse files Browse the repository at this point in the history
  • Loading branch information
craigmayhew committed May 22, 2024
1 parent 6f0a347 commit 507dfb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn view(model: &Model) -> Node<Msg> {
}

fn routes(url: seed::Url) -> (Page, std::string::String) {
let empty_string = "".to_owned();
let empty_string = String::new();

if url.path().is_empty() {
return (Page::Home, empty_string);
Expand Down
8 changes: 4 additions & 4 deletions src/pages/cruncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod numerics_to_text {
fn den2numerals(n: &str, glyphs: Vec<Vec<&str>>) -> String {
//this function converts a number in the form of a string
//to roman/egyptian/babylonian/chinese numerals
let mut numerals: String = "".to_owned();
let mut numerals: String = String::new();
let n_vec: Vec<char> = n.chars().collect();
for i in 0..n.len() {
let digit: String = n_vec[n.len() - 1 - i].to_string();
Expand Down Expand Up @@ -408,7 +408,7 @@ mod numerics_to_text {
let x: usize = ((&num / &hundred) % &ten).to_usize().unwrap();
let y: usize = (&num % &hundred).to_usize().unwrap();
// init the output string
let mut string: String = "".to_owned();
let mut string: String = String::new();
// do hundreds
if x > 0 {
string.push_str(units[x]);
Expand Down Expand Up @@ -481,7 +481,7 @@ mod numerics_to_text {
}

if factorial_n != 0 {
let mut string: String = "".to_owned();
let mut string: String = String::new();
string.push_str("It is the ");
string.push_str(&nth(factorial_n));
string.push_str(" factorial number. (");
Expand Down Expand Up @@ -514,7 +514,7 @@ mod numerics_to_text {
let answer = number.nth_root(n.to_u32().unwrap()).to_owned();

if pow(answer.to_owned(), n) == number {
let mut string: String = "".to_owned();
let mut string: String = String::new();
string.push_str(&answer.to_string());
Some(string)
} else {
Expand Down

0 comments on commit 507dfb9

Please sign in to comment.