diff --git a/flake.nix b/flake.nix index 8f30908..e5c7897 100644 --- a/flake.nix +++ b/flake.nix @@ -54,18 +54,8 @@ combine [ complete.toolchain ]; - # rs-platform = pkgs.makeRustPlatform { - # cargo = rs-toolchain; - # rustc = rs-toolchain; - # }; crane-lib = (crane.mkLib nixpkgs.legacyPackages.${system}).overrideToolchain rs-toolchain; rs-programs = final: prev: { - # s10e-jrnl = rs-platform.buildRustPackage { - # pname = "jrnl"; - # version = "0.0.1"; - # src = ./programs/jrnl; - # cargoLock.lockFile = ./programs/jrnl/Cargo.lock; - # }; s10e-jrnl = crane-lib.buildPackage { pname = "s10e-bs"; version = "0.0.1"; diff --git a/programs/flip-bool/src/main.rs b/programs/flip-bool/src/main.rs index 0b99ab8..8062888 100644 --- a/programs/flip-bool/src/main.rs +++ b/programs/flip-bool/src/main.rs @@ -1,7 +1,4 @@ -#![feature(iter_array_chunks)] -#![feature(round_char_boundary)] -#![feature(iter_collect_into)] -#![feature(pattern)] +#![feature(pattern, iter_array_chunks, round_char_boundary, iter_collect_into)] use std::{ io::{Read, Write}, @@ -17,17 +14,16 @@ const BOOLS: &[[&str; 2]] = &[ ["no", "yes"], ]; -fn main() { +fn main() -> std::io::Result<()> { let mut input = String::new(); let mut stdin = std::io::stdin(); let mut stdout = std::io::stdout(); - stdin.read_to_string(&mut input).unwrap(); + stdin.read_to_string(&mut input)?; let bool_locs = find_bools(&input); - stdout - .write_all(replace_bools(&mut input, bool_locs).as_bytes()) - .unwrap(); + + stdout.write_all(replace_bools(&mut input, bool_locs).as_bytes()) } type BoolLocs = [[Vec; 2]; BOOL_COUNT]; @@ -96,14 +92,12 @@ fn find_bools(input: &str) -> [[Vec; 2]; BOOL_COUNT] { && char_guard( input[it.1.floor_char_boundary(it.0 - 1)..it.0] .chars() - .last() - .unwrap(), + .last()?, ) && char_guard( input[(last_idx)..(input.ceil_char_boundary(last_idx + 1))] .chars() - .last() - .unwrap(), + .last()?, )) .then_some(it.0) })