diff --git a/fish-rust/src/wutil/wcstoi.rs b/fish-rust/src/wutil/wcstoi.rs index df8f89ede..44cde6cc4 100644 --- a/fish-rust/src/wutil/wcstoi.rs +++ b/fish-rust/src/wutil/wcstoi.rs @@ -6,11 +6,13 @@ pub enum Error { Overflow, Empty, InvalidDigit, + CharsLeft, } struct ParseResult { result: u64, negative: bool, + consumed_all: bool, } /// Helper to get the current char, or \0. @@ -74,6 +76,7 @@ fn fish_parse_radix(ichars: Chars, mradix: Option) -> Result(ichars: Chars, mradix: Option) -> Result(src: Chars, mradix: Option) -> Result +fn fish_wcstoi_impl(src: Chars, mradix: Option, consume_all: bool) -> Result where Chars: Iterator, Int: PrimInt, @@ -116,11 +120,13 @@ fn fish_wcstoi_impl(src: Chars, mradix: Option) -> Result Ok(r), @@ -150,7 +156,7 @@ pub fn fish_wcstoi(src: Chars) -> Result Chars: Iterator, Int: PrimInt, { - fish_wcstoi_impl(src, None) + fish_wcstoi_impl(src, None, false) } /// Convert the given wide string to an integer using the given radix. @@ -160,7 +166,15 @@ pub fn fish_wcstoi_radix(src: Chars, radix: u32) -> Result, Int: PrimInt, { - fish_wcstoi_impl(src, Some(radix)) + fish_wcstoi_impl(src, Some(radix), false) +} + +pub fn fish_wcstoi_radix_all(src: Chars, radix: Option, consume_all: bool) -> Result +where + Chars: Iterator, + Int: PrimInt, +{ + fish_wcstoi_impl(src, radix, consume_all) } #[cfg(test)]