Skip to content

Instantly share code, notes, and snippets.

@bylatt
Last active July 11, 2023 04:25
Show Gist options
  • Save bylatt/2bccc1f64bca080ee2e4e785e1830b15 to your computer and use it in GitHub Desktop.
Save bylatt/2bccc1f64bca080ee2e4e785e1830b15 to your computer and use it in GitHub Desktop.

Revisions

  1. bylatt revised this gist Jul 11, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion main.rs
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ fn main() {
    let longest_word =
    content.split("\n").fold(
    "",
    |prev, cur| if prev.len() > cur.len() { prev } else { cur },
    |prev, cur| if cur.len() > prev.len() { cur } else { prev },
    );
    println!("{longest_word}");
    }
  2. bylatt created this gist Jul 11, 2023.
    12 changes: 12 additions & 0 deletions main.rs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    use std::fs;

    fn main() {
    let content =
    fs::read_to_string("/usr/share/dict/words").unwrap_or("cannot read file".to_string());
    let longest_word =
    content.split("\n").fold(
    "",
    |prev, cur| if prev.len() > cur.len() { prev } else { cur },
    );
    println!("{longest_word}");
    }