fixed most warnings

This commit is contained in:
Yehowshua Immanuel 2022-08-02 19:31:35 -04:00
parent e931d9a825
commit 21f0682500
10 changed files with 116 additions and 154 deletions

View file

@ -14,7 +14,7 @@ pub(super) fn take_until<'a>(word : &'a str, pattern : u8) -> ParseResult<'a> {
let mut new_start = 0;
for chr in word.as_bytes() {
if (*chr == pattern) {
if *chr == pattern {
break
}
else {
@ -30,25 +30,11 @@ pub(super) fn take_until<'a>(word : &'a str, pattern : u8) -> ParseResult<'a> {
}
// TODO: if I end up using simulator specific date parsers, ``take_until`` may
// suffice rendering this function obselete, at which point I should delete it.
pub(super) fn truncate_last_chr_when<'a>(word : &'a str, cond : fn(u8) -> bool) -> &'a str {
let last_chr = word.as_bytes().last().unwrap();
let mut new_end_index = word.len();
if cond(*last_chr) {
new_end_index -= 1;
}
return &word[0..new_end_index]
}
pub(super) fn take_while<'a>(word : &'a str, cond : fn(u8) -> bool) -> ParseResult<'a> {
let mut new_start = 0;
for chr in word.as_bytes() {
if (cond(*chr)) {
if cond(*chr) {
new_start += 1;
}
else {