Debian Codegraph @

src/widgets/process_table/query/or.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#;
2
3 use craterust-analyzer cargo bottom 0.14.9 crate/::{
4 collectionrust-analyzer cargo bottom 0.14.9 collection/::processesrust-analyzer cargo bottom 0.14.9 collection/processes/::ProcessHarvestrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#,
5 widgetsrust-analyzer cargo bottom 0.14.9 widgets/::queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/::{
6 Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#, COMPARISON_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/COMPARISON_LIST., Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#, QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#, QueryProcessorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryProcessor#, QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#, errorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/::QueryErrorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryError#,
7 },
8 };
9
10 /// A node where either the left-hand side or the right-hand side are
11 /// considered. Note that the right-hand side is optional, as that's how I
12 /// implemented it a long time ago.
13 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
14 pub(superrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/) struct Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or# {
15 pub(superrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/) lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#lhs.: Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#,
16 // TODO: Maybe don't need to box rhs?
17 pub(superrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/) rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#rhs.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#>>,
18 }
19
20 impl Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or# {
21 pub(superrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/) fn checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/impl#[Or]check().(&self, process: &ProcessHarvestrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#, is_using_command: bool) -> bool {
22 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rhs) = &self.rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#rhs. {
23 self.lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#lhs..checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/impl#[And]check().(process, is_using_command) || rhs.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/impl#[And]check().(process, is_using_command)
24 } else {
25 self.lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#lhs..checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/impl#[And]check().(process, is_using_command)
26 }
27 }
28 }
29
30 impl QueryProcessorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryProcessor# for Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or# {
31 fn processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/impl#[Or][QueryProcessor]process().(query: &mut VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, options: &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#) -> QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#<Selfrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/impl#[Or][QueryProcessor]>
32 where
33 Selfrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/impl#[Or][QueryProcessor]: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
34 {
35 const OR_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/OR_LIST.: [&str; 2] = ["or", "||"];
36
37 let mut lhs = Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#::processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/impl#[And][QueryProcessor]process().(query, options)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
38 let mut rhs: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#>> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
39
40 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(queue_top) = query.frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front().() {
41 let current_lowercase = queue_top.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().();
42 if OR_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/OR_LIST..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&current_lowercase.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) {
43 query.pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().();
44 rhs = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#::processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/impl#[And][QueryProcessor]process().(query, options)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().));
45
46 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(queue_next) = query.frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front().() {
47 if OR_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/OR_LIST..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&queue_next.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) {
48 // Must merge LHS and RHS
49 lhs = Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And# {
50 lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#lhs.: Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#::Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#Or#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or# { lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#lhs., rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#rhs. })),
51 rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#rhs.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
52 };
53 rhs = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
54 }
55 } else {
56 break;
57 }
58 } else if COMPARISON_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/COMPARISON_LIST..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&current_lowercase.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) {
59 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(QueryErrorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryError#::newrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/impl#[QueryError]new().("Comparison not valid here"));
60 } else {
61 break;
62 }
63 }
64
65 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or# { lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#lhs., rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#rhs. })
66 }
67 }