fix a panic

This commit is contained in:
Tove 2025-12-17 20:52:26 +01:00
parent 4125d61dfe
commit 8dcd0ed9c2
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
5 changed files with 16 additions and 2 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use nix

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/target
/Cargo.lock
.direnv/

View file

@ -1,6 +1,6 @@
[package]
name = "readformat"
version = "1.0.1"
version = "1.0.2"
edition = "2021"
repository = "https://github.com/tudbut/readformat"
license = "MIT"

12
shell.nix Normal file
View file

@ -0,0 +1,12 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rust-analyzer
cargo
rustc
clippy
rustfmt
cargo-watch
];
}

View file

@ -35,7 +35,7 @@ pub fn readf(format: &str, mut s: &str) -> Option<Vec<String>> {
}
{
let pat = patterns[0];
if &s[..pat.len()] != pat {
if !s.get(..pat.len()).is_some_and(|x| x == pat) {
return None;
}
if DEBUG {