| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 2 | |
| 3 | /// Whether the patch has been forwarded to the upstream project. |
| 4 | #[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:, 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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 5 | pub enum Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded# { |
| 6 | /// The patch has not been forwarded to the upstream project. |
| 7 | Norust-analyzer cargo dep3 0.2.4 fields/Forwarded#No#, |
| 8 | |
| 9 | /// The patch does not need to be forwarded to the upstream project. |
| 10 | NotNeededrust-analyzer cargo dep3 0.2.4 fields/Forwarded#NotNeeded#, |
| 11 | |
| 12 | /// The patch has been forwarded to the upstream project, and the value |
| 13 | /// provides some reference to the forwarded patch. |
| 14 | Yesrust-analyzer cargo dep3 0.2.4 fields/Forwarded#Yes#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str>), |
| 15 | } |
| 16 | |
| 17 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded# { |
| 18 | fn fmtrust-analyzer cargo dep3 0.2.4 fields/impl#[Forwarded][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 19 | match self { |
| 20 | Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::Norust-analyzer cargo dep3 0.2.4 fields/Forwarded#No# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("no"), |
| 21 | Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::NotNeededrust-analyzer cargo dep3 0.2.4 fields/Forwarded#NotNeeded# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("not-needed"), |
| 22 | Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::Yesrust-analyzer cargo dep3 0.2.4 fields/Forwarded#Yes#(s) => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(s), |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded# { |
| 28 | type Errrust-analyzer cargo dep3 0.2.4 fields/impl#[Forwarded][FromStr]Err# = &'static str; |
| 29 | |
| 30 | fn from_strrust-analyzer cargo dep3 0.2.4 fields/impl#[Forwarded][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo dep3 0.2.4 fields/impl#[Forwarded][FromStr], Selfrust-analyzer cargo dep3 0.2.4 fields/impl#[Forwarded][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 31 | match s { |
| 32 | "no" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::Norust-analyzer cargo dep3 0.2.4 fields/Forwarded#No#), |
| 33 | "not-needed" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::NotNeededrust-analyzer cargo dep3 0.2.4 fields/Forwarded#NotNeeded#), |
| 34 | s => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::Yesrust-analyzer cargo dep3 0.2.4 fields/Forwarded#Yes#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))), |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | /// The category of the origin |
| 40 | #[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:, 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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 41 | pub enum OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory# { |
| 42 | /// an upstream patch that had to be modified to apply on the current version |
| 43 | Backportrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Backport#, |
| 44 | /// a patch created by Debian or another distribution vendor |
| 45 | Vendorrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Vendor#, |
| 46 | /// a patch cherry-picked from the upstream VCS |
| 47 | Upstreamrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Upstream#, |
| 48 | |
| 49 | /// a patch that does not fit in any of the above categories |
| 50 | Otherrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Other#, |
| 51 | } |
| 52 | |
| 53 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory# { |
| 54 | fn fmtrust-analyzer cargo dep3 0.2.4 fields/impl#[OriginCategory][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 55 | match self { |
| 56 | OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Backportrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Backport# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("backport"), |
| 57 | OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Vendorrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Vendor# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("vendor"), |
| 58 | OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Upstreamrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Upstream# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("upstream"), |
| 59 | OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Otherrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Other# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("other"), |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory# { |
| 65 | type Errrust-analyzer cargo dep3 0.2.4 fields/impl#[OriginCategory][FromStr]Err# = &'static str; |
| 66 | |
| 67 | fn from_strrust-analyzer cargo dep3 0.2.4 fields/impl#[OriginCategory][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo dep3 0.2.4 fields/impl#[OriginCategory][FromStr], Selfrust-analyzer cargo dep3 0.2.4 fields/impl#[OriginCategory][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 68 | match s { |
| 69 | "backport" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Backportrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Backport#), |
| 70 | "vendor" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Vendorrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Vendor#), |
| 71 | "upstream" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Upstreamrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Upstream#), |
| 72 | "other" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Otherrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Other#), |
| 73 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid origin category"), |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /// The origin of the patch |
| 79 | #[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:, 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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 80 | pub enum Originrust-analyzer cargo dep3 0.2.4 fields/Origin# { |
| 81 | /// The patch was cherry-picked from the upstream VCS |
| 82 | Commitrust-analyzer cargo dep3 0.2.4 fields/Origin#Commit#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str>), |
| 83 | |
| 84 | /// Some other origin |
| 85 | Otherrust-analyzer cargo dep3 0.2.4 fields/Origin#Other#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str>), |
| 86 | } |
| 87 | |
| 88 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Originrust-analyzer cargo dep3 0.2.4 fields/Origin# { |
| 89 | fn fmtrust-analyzer cargo dep3 0.2.4 fields/impl#[Origin][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 90 | match self { |
| 91 | Originrust-analyzer cargo dep3 0.2.4 fields/Origin#::Commitrust-analyzer cargo dep3 0.2.4 fields/Origin#Commit#(s) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "commit:{}", s), |
| 92 | Originrust-analyzer cargo dep3 0.2.4 fields/Origin#::Otherrust-analyzer cargo dep3 0.2.4 fields/Origin#Other#(s) => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(s), |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Originrust-analyzer cargo dep3 0.2.4 fields/Origin# { |
| 98 | type Errrust-analyzer cargo dep3 0.2.4 fields/impl#[Origin][FromStr]Err# = &'static str; |
| 99 | |
| 100 | fn from_strrust-analyzer cargo dep3 0.2.4 fields/impl#[Origin][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo dep3 0.2.4 fields/impl#[Origin][FromStr], Selfrust-analyzer cargo dep3 0.2.4 fields/impl#[Origin][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 101 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rest) = s.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().("commit:") { |
| 102 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Originrust-analyzer cargo dep3 0.2.4 fields/Origin#::Commitrust-analyzer cargo dep3 0.2.4 fields/Origin#Commit#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(rest.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))) |
| 103 | } else { |
| 104 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Originrust-analyzer cargo dep3 0.2.4 fields/Origin#::Otherrust-analyzer cargo dep3 0.2.4 fields/Origin#Other#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))) |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /// Whether the patch has been applied in the upstream project. |
| 110 | #[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:, 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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 111 | pub enum AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream# { |
| 112 | /// The patch has not been applied in the upstream project, in the specified commit. |
| 113 | Commitrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#Commit#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str>), |
| 114 | |
| 115 | /// The patch has been applied in the upstream project, in the specified reference. |
| 116 | Otherrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#Other#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str>), |
| 117 | } |
| 118 | |
| 119 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream# { |
| 120 | fn fmtrust-analyzer cargo dep3 0.2.4 fields/impl#[AppliedUpstream][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 121 | match self { |
| 122 | AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#::Commitrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#Commit#(s) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "commit:{}", s), |
| 123 | AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#::Otherrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#Other#(s) => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(s), |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream# { |
| 129 | type Errrust-analyzer cargo dep3 0.2.4 fields/impl#[AppliedUpstream][FromStr]Err# = &'static str; |
| 130 | |
| 131 | fn from_strrust-analyzer cargo dep3 0.2.4 fields/impl#[AppliedUpstream][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo dep3 0.2.4 fields/impl#[AppliedUpstream][FromStr], Selfrust-analyzer cargo dep3 0.2.4 fields/impl#[AppliedUpstream][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 132 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rest) = s.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().("commit:") { |
| 133 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#::Commitrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#Commit#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(rest.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))) |
| 134 | } else { |
| 135 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#::Otherrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#Other#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))) |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | pub(craterust-analyzer cargo dep3 0.2.4 crate/) fn parse_originrust-analyzer cargo dep3 0.2.4 fields/parse_origin().(s: &str) -> (Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#>, Originrust-analyzer cargo dep3 0.2.4 fields/Origin#) { |
| 141 | // if origin starts with "<category>, " then it is a category |
| 142 | |
| 143 | let mut parts = s.splitnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]splitn().(2, ", "); |
| 144 | let (category, s) = match parts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`SplitN<'a, P>`][Iterator]next().() { |
| 145 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("backport") => (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Backportrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Backport#), parts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`SplitN<'a, P>`][Iterator]next().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("")), |
| 146 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("vendor") => (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Vendorrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Vendor#), parts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`SplitN<'a, P>`][Iterator]next().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("")), |
| 147 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("upstream") => (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Upstreamrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Upstream#), parts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`SplitN<'a, P>`][Iterator]next().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("")), |
| 148 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("other") => (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Otherrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Other#), parts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`SplitN<'a, P>`][Iterator]next().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("")), |
| 149 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_) => (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, s), |
| 150 | }; |
| 151 | |
| 152 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rest) = s.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().("commit:") { |
| 153 | (category, Originrust-analyzer cargo dep3 0.2.4 fields/Origin#::Commitrust-analyzer cargo dep3 0.2.4 fields/Origin#Commit#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(rest.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))) |
| 154 | } else { |
| 155 | (category, Originrust-analyzer cargo dep3 0.2.4 fields/Origin#::Otherrust-analyzer cargo dep3 0.2.4 fields/Origin#Other#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))) |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | pub(craterust-analyzer cargo dep3 0.2.4 crate/) fn format_originrust-analyzer cargo dep3 0.2.4 fields/format_origin().(category: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#>, origin: &Originrust-analyzer cargo dep3 0.2.4 fields/Origin#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 160 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 161 | "{}{}", |
| 162 | category.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|c| c.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() +rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). ", ").unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 163 | origin |
| 164 | ) |
| 165 | } |
| 166 | |
| 167 | /// Parse a Debian BTS bug-id value into a number, accepting: |
| 168 | /// - a bare decimal number (`123456`) |
| 169 | /// - a `#`-prefixed number |
| 170 | /// - a `https://bugs.debian.org/NNNNNN` URL |
| 171 | pub fn parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().(value: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32> { |
| 172 | let trimmed = value.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(); |
| 173 | let candidate = trimmed |
| 174 | .trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().("https://bugs.debian.org/") |
| 175 | .trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().("http://bugs.debian.org/") |
| 176 | .trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().('#'); |
| 177 | candidate.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().() |
| 178 | } |
| 179 | |
| 180 | #[cfg(test)] |
| 181 | mod testsrust-analyzer cargo dep3 0.2.4 fields/tests/ { |
| 182 | use superrust-analyzer cargo dep3 0.2.4 fields/::*; |
| 183 | |
| 184 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 185 | fn test_forwarded_displayrust-analyzer cargo dep3 0.2.4 fields/tests/test_forwarded_display().() { |
| 186 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::Norust-analyzer cargo dep3 0.2.4 fields/Forwarded#No#.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "no"); |
| 187 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::Yesrust-analyzer cargo dep3 0.2.4 fields/Forwarded#Yes#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("url")).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "url"); |
| 188 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::NotNeededrust-analyzer cargo dep3 0.2.4 fields/Forwarded#NotNeeded#.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "not-needed"); |
| 189 | } |
| 190 | |
| 191 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 192 | fn test_applied_upstream_displayrust-analyzer cargo dep3 0.2.4 fields/tests/test_applied_upstream_display().() { |
| 193 | let commit = AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#::Commitrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#Commit#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("abc123")); |
| 194 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(commit.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "commit:abc123"); |
| 195 | |
| 196 | let other = AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#::Otherrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#Other#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("merged")); |
| 197 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(other.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "merged"); |
| 198 | } |
| 199 | |
| 200 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 201 | fn test_parse_debian_bug_id_bare_numberrust-analyzer cargo dep3 0.2.4 fields/tests/test_parse_debian_bug_id_bare_number().() { |
| 202 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().("123456"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(123456)); |
| 203 | } |
| 204 | |
| 205 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 206 | fn test_parse_debian_bug_id_hash_prefixrust-analyzer cargo dep3 0.2.4 fields/tests/test_parse_debian_bug_id_hash_prefix().() { |
| 207 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().("#123456"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(123456)); |
| 208 | } |
| 209 | |
| 210 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 211 | fn test_parse_debian_bug_id_https_urlrust-analyzer cargo dep3 0.2.4 fields/tests/test_parse_debian_bug_id_https_url().() { |
| 212 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 213 | parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().("https://bugs.debian.org/510219"), |
| 214 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(510219) |
| 215 | ); |
| 216 | } |
| 217 | |
| 218 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 219 | fn test_parse_debian_bug_id_http_urlrust-analyzer cargo dep3 0.2.4 fields/tests/test_parse_debian_bug_id_http_url().() { |
| 220 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 221 | parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().("http://bugs.debian.org/510219"), |
| 222 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(510219) |
| 223 | ); |
| 224 | } |
| 225 | |
| 226 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 227 | fn test_parse_debian_bug_id_trims_whitespacerust-analyzer cargo dep3 0.2.4 fields/tests/test_parse_debian_bug_id_trims_whitespace().() { |
| 228 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().(" 42 "), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(42)); |
| 229 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().("\t#42\n"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(42)); |
| 230 | } |
| 231 | |
| 232 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 233 | fn test_parse_debian_bug_id_rejects_garbagerust-analyzer cargo dep3 0.2.4 fields/tests/test_parse_debian_bug_id_rejects_garbage().() { |
| 234 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().(""), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 235 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().("abc"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 236 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().("12abc"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 237 | // Non-Debian BTS URL is not stripped, so the parse fails. |
| 238 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 239 | parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().("https://bugzilla.example.com/9697"), |
| 240 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 241 | ); |
| 242 | // A negative number is not a valid u32. |
| 243 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_debian_bug_idrust-analyzer cargo dep3 0.2.4 fields/parse_debian_bug_id().("-1"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 244 | } |
| 245 | } |