| 1 | const fn in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(pat: &[u8], range: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>, keys: &[&str]) -> bool { |
| 2 | let mut k = 0; |
| 3 | while k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().keys.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 4 | 'keycheck: { |
| 5 | if range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().keys[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().k]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() { |
| 6 | let mut i = range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.; |
| 7 | while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. { |
| 8 | if pat[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().keys[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().k]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). { |
| 9 | break 'keycheck; |
| 10 | } |
| 11 | i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1 |
| 12 | } |
| 13 | |
| 14 | return true; |
| 15 | } |
| 16 | } |
| 17 | k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1 |
| 18 | } |
| 19 | |
| 20 | false |
| 21 | } |
| 22 | |
| 23 | pub const fn check_keysrust-analyzer cargo sudo-rs 0.2.14 gettext/check/check_keys().(pat: &str, keys: &[&str]) { |
| 24 | let pat = pat.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(); |
| 25 | let mut i = 0; |
| 26 | 'outer: while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().pat.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 27 | if pat[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'{' { |
| 28 | let mut j = i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 29 | while j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().pat.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 30 | if pat[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().j]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'}' { |
| 31 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 32 | in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(pat, i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1..j, keys), |
| 33 | "unmatched key in xlat-format string" |
| 34 | ); |
| 35 | i = j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 36 | continue 'outer; |
| 37 | } |
| 38 | j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1 |
| 39 | } |
| 40 | |
| 41 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unmatched }} in pattern"); |
| 42 | } |
| 43 | |
| 44 | i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1 |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | #[cfg(test)] |
| 49 | mod testrust-analyzer cargo sudo-rs 0.2.14 gettext/check/test/ { |
| 50 | use superrust-analyzer cargo sudo-rs 0.2.14 gettext/check/::*; |
| 51 | |
| 52 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 53 | const fn eq_worksrust-analyzer cargo sudo-rs 0.2.14 gettext/check/test/eq_works().() { |
| 54 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(b"flerbage", 0..8, &["flerbage"])); |
| 55 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(b"foo", 0..3, &["flerbage"])); |
| 56 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(b"flerbage", 0..8, &["foo"])); |
| 57 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(b"flarbege", 0..8, &["flerbage"])); |
| 58 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(b"flerbage", 0..8, &["foo", "flerbage"])); |
| 59 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(b"flerbage", 0..8, &["flerbage", "foo"])); |
| 60 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(b"bar", 0..3, &["flerbage", "foo"])); |
| 61 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(b"flerbage", 0..7, &["flerbage"])); |
| 62 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(in_setrust-analyzer cargo sudo-rs 0.2.14 gettext/check/in_set().(b"_flerbage_", 1..9, &["flerbage"])); |
| 63 | } |
| 64 | |
| 65 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 66 | fn check_worksrust-analyzer cargo sudo-rs 0.2.14 gettext/check/test/check_works().() { |
| 67 | check_keysrust-analyzer cargo sudo-rs 0.2.14 gettext/check/check_keys().("{foo}{bar}", &["bar", "foo"]); |
| 68 | } |
| 69 | |
| 70 | #[should_panic] |
| 71 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 72 | fn check_panicsrust-analyzer cargo sudo-rs 0.2.14 gettext/check/test/check_panics().() { |
| 73 | check_keysrust-analyzer cargo sudo-rs 0.2.14 gettext/check/check_keys().("{foo}", &["bar"]); |
| 74 | } |
| 75 | } |