Debian Codegraph @

src/column.rs

raw symbols SCIP
1 /*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
9 pub(craterust-analyzer cargo esl01-renderdag 0.3.0 crate/) enum Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#<N> {
10 Emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Empty#,
11 Blockedrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Blocked#,
12 Reservedrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Reserved#(N),
13 Ancestorrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Ancestor#(N),
14 Parentrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Parent#(N),
15 }
16
17 impl<N> Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#<N>
18 where
19 N: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
20 {
21 pub(craterust-analyzer cargo esl01-renderdag 0.3.0 crate/) fn matchesrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`]matches().(&self, n: &N) -> bool
22 where
23 N: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#,
24 {
25 match self {
26 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Empty# | Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Blockedrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Blocked# => false,
27 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Reservedrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Reserved#(o) => n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().o,
28 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Ancestorrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Ancestor#(o) => n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().o,
29 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Parentrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Parent#(o) => n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().o,
30 }
31 }
32
33 fn variantrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`]variant().(&self) -> usize {
34 match self {
35 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Empty# => 0,
36 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Blockedrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Blocked# => 1,
37 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Reservedrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Reserved#(_) => 2,
38 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Ancestorrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Ancestor#(_) => 3,
39 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Parentrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Parent#(_) => 4,
40 }
41 }
42
43 pub(craterust-analyzer cargo esl01-renderdag 0.3.0 crate/) fn mergerust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`]merge().(&mut self, other: &Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#<N>) {
44 if other.variantrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`]variant().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().self.variantrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`]variant().() {
45 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self = other.clonerust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`][Clone]clone().();
46 }
47 }
48
49 fn resetrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`]reset().(&mut self) {
50 match self {
51 Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Blockedrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Blocked# => *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self = Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Empty#,
52 _ => {}
53 }
54 }
55 }
56
57 pub(craterust-analyzer cargo esl01-renderdag 0.3.0 crate/) trait ColumnsExtrust-analyzer cargo esl01-renderdag 0.3.0 column/ColumnsExt#<N> {
58 fn findrust-analyzer cargo esl01-renderdag 0.3.0 column/ColumnsExt#find().(&self, node: &N) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>;
59 fn find_emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/ColumnsExt#find_empty().(&self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>;
60 fn first_emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/ColumnsExt#first_empty().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>;
61 fn new_emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/ColumnsExt#new_empty().(&mut self) -> usize;
62 fn resetrust-analyzer cargo esl01-renderdag 0.3.0 column/ColumnsExt#reset().(&mut self);
63 }
64
65 impl<N> ColumnsExtrust-analyzer cargo esl01-renderdag 0.3.0 column/ColumnsExt#<N> for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#<N>>
66 where
67 N: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#,
68 {
69 fn findrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Vec<Column<N>>`][`ColumnsExt<N>`]find().(&self, node: &N) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize> {
70 for (index, column) in self.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
71 if column.matchesrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`]matches().(node) {
72 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(index);
73 }
74 }
75 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
76 }
77
78 fn find_emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Vec<Column<N>>`][`ColumnsExt<N>`]find_empty().(&self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize> {
79 if self.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(index) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Empty#) {
80 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(index);
81 }
82 self.first_emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Vec<Column<N>>`][`ColumnsExt<N>`]first_empty().()
83 }
84
85 fn first_emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Vec<Column<N>>`][`ColumnsExt<N>`]first_empty().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize> {
86 for (i, column) in self.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
87 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().column rust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`][`PartialEq<Self>`]eq().==rust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`][`PartialEq<Self>`]eq(). rust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`][`PartialEq<Self>`]eq().Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Empty# {
88 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i);
89 }
90 }
91 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
92 }
93
94 fn new_emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Vec<Column<N>>`][`ColumnsExt<N>`]new_empty().(&mut self) -> usize {
95 self.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Empty#);
96 self.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() 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().1
97 }
98
99 fn resetrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Vec<Column<N>>`][`ColumnsExt<N>`]reset().(&mut self) {
100 for column in self.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() {
101 column.resetrust-analyzer cargo esl01-renderdag 0.3.0 column/impl#[`Column<N>`]reset().();
102 }
103 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Columnrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#::Emptyrust-analyzer cargo esl01-renderdag 0.3.0 column/Column#Empty#) = self.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().() {
104 self.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().();
105 }
106 }
107 }