| 1 | //! A library for parsing and manipulating R DESCRIPTION files. |
| 2 | //! |
| 3 | //! See https://r-pkgs.org/description.html and https://cran.r-project.org/doc/manuals/R-exts.html |
| 4 | //! for more information |
| 5 | //! |
| 6 | //! See the ``lossless`` module for a lossless parser that is |
| 7 | //! forgiving in the face of errors and preserves formatting while editing |
| 8 | //! at the expense of a more complex API. |
| 9 | use deb822_deriverust-analyzer cargo deb822-derive 0.3.1 crate/::{FromDeb822rust-analyzer cargo deb822-derive 0.3.1 FromDeb822:, ToDeb822rust-analyzer cargo deb822-derive 0.3.1 ToDeb822:}; |
| 10 | use deb822_fastrust-analyzer cargo deb822-fast 0.2.3 crate/::{FromDeb822Paragraphrust-analyzer cargo deb822-fast 0.2.3 convert/FromDeb822Paragraph#, ToDeb822Paragraphrust-analyzer cargo deb822-fast 0.2.3 convert/ToDeb822Paragraph#}; |
| 11 | |
| 12 | use craterust-analyzer cargo r-description 0.4.1 crate/::RCoderust-analyzer cargo r-description 0.4.1 RCode#; |
| 13 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/Peekable#; |
| 14 | |
| 15 | use craterust-analyzer cargo r-description 0.4.1 crate/::relationsrust-analyzer cargo r-description 0.4.1 relations/::SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::*; |
| 16 | use craterust-analyzer cargo r-description 0.4.1 crate/::relationsrust-analyzer cargo r-description 0.4.1 relations/::{lexrust-analyzer cargo r-description 0.4.1 relations/lex()., SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#, VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#}; |
| 17 | use craterust-analyzer cargo r-description 0.4.1 crate/::versionrust-analyzer cargo r-description 0.4.1 version/::Versionrust-analyzer cargo r-description 0.4.1 version/Version#; |
| 18 | |
| 19 | #[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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, 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:)] |
| 20 | /// A URL entry in the URL field. |
| 21 | pub struct UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry# { |
| 22 | /// URL |
| 23 | pub urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url.: urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#, |
| 24 | |
| 25 | /// Optional label for the URL. |
| 26 | pub labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 27 | } |
| 28 | |
| 29 | 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 UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry# { |
| 30 | fn fmtrust-analyzer cargo r-description 0.4.1 lossy/impl#[UrlEntry][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# { |
| 31 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", self.urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 32 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(label) = &self.labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label. { |
| 33 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " ({label})")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 34 | } |
| 35 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | 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 UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry# { |
| 40 | type Errrust-analyzer cargo r-description 0.4.1 lossy/impl#[UrlEntry][FromStr]Err# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; |
| 41 | |
| 42 | fn from_strrust-analyzer cargo r-description 0.4.1 lossy/impl#[UrlEntry][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[UrlEntry][FromStr], Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[UrlEntry][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 43 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pos) = s.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('(') { |
| 44 | let url = s[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 ops/range/RangeTo#pos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(); |
| 45 | let label = s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos 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..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]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]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(); |
| 46 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry# { |
| 47 | urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url.: urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().(url).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 48 | labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(label.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 49 | }) |
| 50 | } else { |
| 51 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry# { |
| 52 | urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url.: urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().(s).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 53 | labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 54 | }) |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | fn serialize_url_listrust-analyzer cargo r-description 0.4.1 lossy/serialize_url_list().(urls: &[UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#]) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 60 | let mut s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 61 | for (i, url) in urls.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().() { |
| 62 | if i 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().0 { |
| 63 | s.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(", "); |
| 64 | } |
| 65 | s.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(url.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()); |
| 66 | } |
| 67 | s |
| 68 | } |
| 69 | |
| 70 | fn deserialize_url_listrust-analyzer cargo r-description 0.4.1 lossy/deserialize_url_list().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#>, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 71 | s.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().([',', '\n'].as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().()) |
| 72 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|s| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().()) |
| 73 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()) |
| 74 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>() |
| 75 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 76 | } |
| 77 | |
| 78 | fn serialize_repository_listrust-analyzer cargo r-description 0.4.1 lossy/serialize_repository_list().(repositories: &[urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#]) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 79 | let mut s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 80 | for (i, repository) in repositories.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().() { |
| 81 | if i 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().0 { |
| 82 | s.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(", "); |
| 83 | } |
| 84 | s.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(repository.as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().()); |
| 85 | } |
| 86 | s |
| 87 | } |
| 88 | |
| 89 | fn deserialize_repository_listrust-analyzer cargo r-description 0.4.1 lossy/deserialize_repository_list().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#>, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 90 | s.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().([',', '\n'].as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().()) |
| 91 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|s| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().()) |
| 92 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().(s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().()).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())) |
| 93 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 94 | } |
| 95 | |
| 96 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(FromDeb822rust-analyzer cargo deb822-derive 0.3.1 FromDeb822:, ToDeb822rust-analyzer cargo deb822-derive 0.3.1 ToDeb822:, 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:)] |
| 97 | /// A DESCRIPTION file. |
| 98 | pub struct RDescriptionrust-analyzer cargo r-description 0.4.1 lossy/RDescription# { |
| 99 | /// The name of the package. |
| 100 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Package")] |
| 101 | pub namerust-analyzer cargo r-description 0.4.1 lossy/RDescription#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 102 | |
| 103 | /// A short description of the package. |
| 104 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Description")] |
| 105 | pub descriptionrust-analyzer cargo r-description 0.4.1 lossy/RDescription#description.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 106 | |
| 107 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Title")] |
| 108 | /// The title of the package. |
| 109 | pub titlerust-analyzer cargo r-description 0.4.1 lossy/RDescription#title.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 110 | |
| 111 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Maintainer")] |
| 112 | /// The maintainer of the package. |
| 113 | pub maintainerrust-analyzer cargo r-description 0.4.1 lossy/RDescription#maintainer.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 114 | |
| 115 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Author")] |
| 116 | /// Who wrote the the package |
| 117 | pub authorrust-analyzer cargo r-description 0.4.1 lossy/RDescription#author.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 118 | |
| 119 | /// 'Authors@R' is a special field that can contain R code |
| 120 | /// that is evaluated to get the authors and maintainers. |
| 121 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Authors@R")] |
| 122 | pub authorsrust-analyzer cargo r-description 0.4.1 lossy/RDescription#authors.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<RCoderust-analyzer cargo r-description 0.4.1 RCode#>, |
| 123 | |
| 124 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Version")] |
| 125 | /// The version of the package. |
| 126 | pub versionrust-analyzer cargo r-description 0.4.1 lossy/RDescription#version.: Versionrust-analyzer cargo r-description 0.4.1 version/Version#, |
| 127 | |
| 128 | /// If the DESCRIPTION file is not written in pure ASCII, the encoding |
| 129 | /// field must be used to specify the encoding. |
| 130 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Encoding")] |
| 131 | pub encodingrust-analyzer cargo r-description 0.4.1 lossy/RDescription#encoding.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 132 | |
| 133 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "License")] |
| 134 | /// The license of the package. |
| 135 | pub licenserust-analyzer cargo r-description 0.4.1 lossy/RDescription#license.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 136 | |
| 137 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "URL", serialize_with = serialize_url_listrust-analyzer cargo r-description 0.4.1 lossy/serialize_url_list()., deserialize_with = deserialize_url_listrust-analyzer cargo r-description 0.4.1 lossy/deserialize_url_list().)] |
| 138 | // TODO: parse this as a list of URLs, separated by commas |
| 139 | /// URLs related to the package. |
| 140 | pub urlrust-analyzer cargo r-description 0.4.1 lossy/RDescription#url.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#>>, |
| 141 | |
| 142 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "BugReports")] |
| 143 | /// The URL or email address where bug reports should be sent. |
| 144 | pub bug_reportsrust-analyzer cargo r-description 0.4.1 lossy/RDescription#bug_reports.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 145 | |
| 146 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Imports")] |
| 147 | /// The packages that this package depends on. |
| 148 | pub importsrust-analyzer cargo r-description 0.4.1 lossy/RDescription#imports.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#>, |
| 149 | |
| 150 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Suggests")] |
| 151 | /// The packages that this package suggests. |
| 152 | pub suggestsrust-analyzer cargo r-description 0.4.1 lossy/RDescription#suggests.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#>, |
| 153 | |
| 154 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Depends")] |
| 155 | /// The packages that this package depends on. |
| 156 | pub dependsrust-analyzer cargo r-description 0.4.1 lossy/RDescription#depends.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#>, |
| 157 | |
| 158 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "LinkingTo")] |
| 159 | /// The packages that this package links to. |
| 160 | pub linking_torust-analyzer cargo r-description 0.4.1 lossy/RDescription#linking_to.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#>, |
| 161 | |
| 162 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "LazyData")] |
| 163 | /// Whether the package has lazy data. |
| 164 | pub lazy_datarust-analyzer cargo r-description 0.4.1 lossy/RDescription#lazy_data.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 165 | |
| 166 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Collate")] |
| 167 | /// The order in which R scripts are loaded. |
| 168 | pub collaterust-analyzer cargo r-description 0.4.1 lossy/RDescription#collate.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 169 | |
| 170 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "VignetteBuilder")] |
| 171 | /// The package used to build vignettes. |
| 172 | pub vignette_builderrust-analyzer cargo r-description 0.4.1 lossy/RDescription#vignette_builder.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 173 | |
| 174 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "SystemRequirements")] |
| 175 | /// The system requirements for the package. |
| 176 | pub system_requirementsrust-analyzer cargo r-description 0.4.1 lossy/RDescription#system_requirements.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 177 | |
| 178 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Date")] |
| 179 | /// The release date of the current version of the package. |
| 180 | /// Strongly recommended to use the ISO 8601 format: YYYY-MM-DD |
| 181 | pub daterust-analyzer cargo r-description 0.4.1 lossy/RDescription#date.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 182 | |
| 183 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Language")] |
| 184 | /// Indicates the package documentation is not in English. |
| 185 | /// This should be a comma-separated list of IETF language |
| 186 | /// tags as defined by RFC5646 |
| 187 | pub languagerust-analyzer cargo r-description 0.4.1 lossy/RDescription#language.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 188 | |
| 189 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Repository")] |
| 190 | /// The R Repository to use for this package. E.g. "CRAN" or "Bioconductor" |
| 191 | pub repositoryrust-analyzer cargo r-description 0.4.1 lossy/RDescription#repository.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 192 | |
| 193 | #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Additional_repositories", serialize_with = serialize_repository_listrust-analyzer cargo r-description 0.4.1 lossy/serialize_repository_list()., deserialize_with = deserialize_repository_listrust-analyzer cargo r-description 0.4.1 lossy/deserialize_repository_list().)] |
| 194 | /// Additional repositories where dependency packages may be found. |
| 195 | pub additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossy/RDescription#additional_repositories.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#>>, |
| 196 | } |
| 197 | |
| 198 | /// A relation entry in a relationship field. |
| 199 | #[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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, 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:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 200 | pub struct Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# { |
| 201 | /// Package name. |
| 202 | pub namerust-analyzer cargo r-description 0.4.1 lossy/Relation#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 203 | /// Version constraint and version. |
| 204 | pub versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#, Versionrust-analyzer cargo r-description 0.4.1 version/Version#)>, |
| 205 | } |
| 206 | |
| 207 | impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# { |
| 208 | fn defaultrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][Default]default().() -> Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][Default] { |
| 209 | Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][Default]::newrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation]new().() |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | impl Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# { |
| 214 | /// Create an empty relation. |
| 215 | pub fn newrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation]new().() -> Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation] { |
| 216 | Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation] { |
| 217 | namerust-analyzer cargo r-description 0.4.1 lossy/Relation#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(), |
| 218 | versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | /// Check if this entry is satisfied by the given package versions. |
| 223 | /// |
| 224 | /// # Arguments |
| 225 | /// * `package_version` - A function that returns the version of a package. |
| 226 | /// |
| 227 | /// # Example |
| 228 | /// ``` |
| 229 | /// use r_description::lossy::Relation; |
| 230 | /// use r_description::Version; |
| 231 | /// let entry: Relation = "cli (>= 2.0)".parse().unwrap(); |
| 232 | /// assert!(entry.satisfied_by(|name: &str| -> Option<Version> { |
| 233 | /// match name { |
| 234 | /// "cli" => Some("2.0".parse().unwrap()), |
| 235 | /// _ => None |
| 236 | /// }})); |
| 237 | /// ``` |
| 238 | pub fn satisfied_byrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation]satisfied_by().(&self, package_version: impl craterust-analyzer cargo r-description 0.4.1 crate/::relationsrust-analyzer cargo r-description 0.4.1 relations/::VersionLookuprust-analyzer cargo r-description 0.4.1 relations/VersionLookup#) -> bool { |
| 239 | let actual = package_version.lookup_versionrust-analyzer cargo r-description 0.4.1 relations/VersionLookup#lookup_version().(self.namerust-analyzer cargo r-description 0.4.1 lossy/Relation#name..as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()); |
| 240 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((vc, version)) = &self.versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version. { |
| 241 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(actual) = actual { |
| 242 | match vc { |
| 243 | VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual# => actual.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]ge().version, |
| 244 | VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThanEqual# => actual.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]le().version, |
| 245 | VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::Equalrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#Equal# => actual.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().() 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().version, |
| 246 | VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::NotEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#NotEqual# => actual.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().version, |
| 247 | VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThan# => actual.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]gt().version, |
| 248 | VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThan# => actual.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]lt().version, |
| 249 | } |
| 250 | } else { |
| 251 | false |
| 252 | } |
| 253 | } else { |
| 254 | actual.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | 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 Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# { |
| 260 | fn fmtrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][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# { |
| 261 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", self.namerust-analyzer cargo r-description 0.4.1 lossy/Relation#name.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 262 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((constraint, version)) = &self.versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version. { |
| 263 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " ({constraint} {version})")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 264 | } |
| 265 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | #[cfg(feature = "serde")] |
| 270 | impl<'de> serderust-analyzer cargo serde 1.0.229 crate/::Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de> for Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# { |
| 271 | fn deserializerust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][`Deserialize<'de>`]deserialize().<D>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation#, D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#> |
| 272 | where |
| 273 | D: serderust-analyzer cargo serde 1.0.229 crate/::Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#<'de>, |
| 274 | { |
| 275 | let s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::deserializerust-analyzer cargo serde_core 1.0.229 de/impls/impl#[String][`Deserialize<'de>`]deserialize().(deserializer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 276 | s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(serderust-analyzer cargo serde 1.0.229 crate/::derust-analyzer cargo serde_core 1.0.229 de/::Errorrust-analyzer cargo serde_core 1.0.229 de/Error#::customrust-analyzer cargo serde_core 1.0.229 de/Error#custom().) |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | #[cfg(feature = "serde")] |
| 281 | impl serderust-analyzer cargo serde 1.0.229 crate/::Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize# for Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# { |
| 282 | fn serializerust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Error#> |
| 283 | where |
| 284 | S: serderust-analyzer cargo serde 1.0.229 crate/::Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#, |
| 285 | { |
| 286 | self.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().serializerust-analyzer cargo serde_core 1.0.229 ser/impls/impl#[String][Serialize]serialize().(serializer) |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | /// A collection of relation entries in a relationship field. |
| 291 | #[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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, 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:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 292 | pub struct Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#(pub Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation#>); |
| 293 | |
| 294 | impl 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/::Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<usize> for Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# { |
| 295 | type Outputrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]Output# = Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation#; |
| 296 | |
| 297 | fn indexrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().(&self, index: usize) -> &Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#Output# { |
| 298 | &self.0rust-analyzer cargo r-description 0.4.1 lossy/Relations#0.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().index]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | impl 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/::IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#<usize> for Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# { |
| 303 | fn index_mutrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`IndexMut<usize>`]index_mut().(&mut self, index: usize) -> &mut Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`IndexMut<usize>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#Output# { |
| 304 | &mut self.0rust-analyzer cargo r-description 0.4.1 lossy/Relations#0.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().index]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | impl FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation#> for Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# { |
| 309 | fn from_iterrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`FromIterator<Relation>`]from_iter().<I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation#>>(iter: I) -> Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`FromIterator<Relation>`] { |
| 310 | Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`FromIterator<Relation>`](iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()) |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# { |
| 315 | fn defaultrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][Default]default().() -> Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][Default] { |
| 316 | Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][Default]::newrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]new().() |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | impl Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# { |
| 321 | /// Create an empty relations. |
| 322 | pub fn newrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]new().() -> Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations] { |
| 323 | Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations](Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()) |
| 324 | } |
| 325 | |
| 326 | /// Remove an entry from the relations. |
| 327 | pub fn removerust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]remove().(&mut self, index: usize) { |
| 328 | self.0rust-analyzer cargo r-description 0.4.1 lossy/Relations#0..removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]remove().(index); |
| 329 | } |
| 330 | |
| 331 | /// Iterate over the entries in the relations. |
| 332 | pub fn iterrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]iter().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation#> { |
| 333 | self.0rust-analyzer cargo r-description 0.4.1 lossy/Relations#0..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 334 | } |
| 335 | |
| 336 | /// Number of entries in the relations. |
| 337 | pub fn lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(&self) -> usize { |
| 338 | self.0rust-analyzer cargo r-description 0.4.1 lossy/Relations#0..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() |
| 339 | } |
| 340 | |
| 341 | /// Check if the relations are empty. |
| 342 | pub fn is_emptyrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]is_empty().(&self) -> bool { |
| 343 | self.0rust-analyzer cargo r-description 0.4.1 lossy/Relations#0..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 344 | } |
| 345 | |
| 346 | /// Check if the relations are satisfied by the given package versions. |
| 347 | pub fn satisfied_byrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]satisfied_by().( |
| 348 | &self, |
| 349 | package_version: impl craterust-analyzer cargo r-description 0.4.1 crate/::relationsrust-analyzer cargo r-description 0.4.1 relations/::VersionLookuprust-analyzer cargo r-description 0.4.1 relations/VersionLookup# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 350 | ) -> bool { |
| 351 | self.0rust-analyzer cargo r-description 0.4.1 lossy/Relations#0..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|r| r.satisfied_byrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation]satisfied_by().(package_version)) |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | 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 Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# { |
| 356 | fn fmtrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][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# { |
| 357 | for (i, relation) in self.0rust-analyzer cargo r-description 0.4.1 lossy/Relations#0..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().() { |
| 358 | if i 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().0 { |
| 359 | f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(", ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 360 | } |
| 361 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{relation}")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 362 | } |
| 363 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | 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 Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# { |
| 368 | type Errrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][FromStr]Err# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; |
| 369 | |
| 370 | fn from_strrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][FromStr], Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 371 | let tokens = lexrust-analyzer cargo r-description 0.4.1 relations/lex().(s); |
| 372 | let mut tokens = tokens.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().(); |
| 373 | |
| 374 | fn eat_whitespacerust-analyzer cargo r-description 0.4.1 lossy/eat_whitespace().(tokens: &mut Peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/Peekable#<impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)>>) { |
| 375 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((k, _)) = tokens.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() { |
| 376 | match k { |
| 377 | WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE# | NEWLINErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NEWLINE# => { |
| 378 | tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 379 | } |
| 380 | _ => break, |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | let name = match tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().() { |
| 386 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#, name)) => name, |
| 387 | _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("Expected package name".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 388 | }; |
| 389 | |
| 390 | eat_whitespacerust-analyzer cargo r-description 0.4.1 lossy/eat_whitespace().(&mut tokens); |
| 391 | |
| 392 | let version = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((L_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#L_PARENS#, _)) = tokens.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() { |
| 393 | tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 394 | eat_whitespacerust-analyzer cargo r-description 0.4.1 lossy/eat_whitespace().(&mut tokens); |
| 395 | let mut constraint = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 396 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((kind, t)) = tokens.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() { |
| 397 | match kind { |
| 398 | EQUALrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#EQUAL# | L_ANGLErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#L_ANGLE# | R_ANGLErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#R_ANGLE# | NOTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NOT# => { |
| 399 | constraint.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(t); |
| 400 | tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 401 | } |
| 402 | _ => break, |
| 403 | } |
| 404 | } |
| 405 | let constraint = constraint.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 406 | eat_whitespacerust-analyzer cargo r-description 0.4.1 lossy/eat_whitespace().(&mut tokens); |
| 407 | // Read IDENT and COLON tokens until we see R_PARENS |
| 408 | let version_string = match tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().() { |
| 409 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#, s)) => s, |
| 410 | _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("Expected version string".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 411 | }; |
| 412 | let version: Versionrust-analyzer cargo r-description 0.4.1 version/Version# = version_string.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#| e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 413 | eat_whitespacerust-analyzer cargo r-description 0.4.1 lossy/eat_whitespace().(&mut tokens); |
| 414 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((R_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#R_PARENS#, _)) = tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().() { |
| 415 | } else { |
| 416 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Expected ')', found {:?}", tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().())); |
| 417 | } |
| 418 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((constraint, version)) |
| 419 | } else { |
| 420 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 421 | }; |
| 422 | |
| 423 | eat_whitespacerust-analyzer cargo r-description 0.4.1 lossy/eat_whitespace().(&mut tokens); |
| 424 | |
| 425 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((kind, _)) = tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().() { |
| 426 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Unexpected token: {kind:?}")); |
| 427 | } |
| 428 | |
| 429 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# { namerust-analyzer cargo r-description 0.4.1 lossy/Relation#name., versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version. }) |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | 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 Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# { |
| 434 | type Errrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][FromStr]Err# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; |
| 435 | |
| 436 | fn from_strrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][FromStr], Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 437 | let mut relations = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 438 | if s.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 439 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#(relations)); |
| 440 | } |
| 441 | for relation in s.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',') { |
| 442 | let relation = relation.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(); |
| 443 | if relation.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 444 | // Ignore empty entries. |
| 445 | continue; |
| 446 | } |
| 447 | relations.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(relation.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 448 | } |
| 449 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#(relations)) |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | #[cfg(feature = "serde")] |
| 454 | impl<'de> serderust-analyzer cargo serde 1.0.229 crate/::Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de> for Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# { |
| 455 | fn deserializerust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Deserialize<'de>`]deserialize().<D>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#, D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#> |
| 456 | where |
| 457 | D: serderust-analyzer cargo serde 1.0.229 crate/::Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#<'de>, |
| 458 | { |
| 459 | let s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::deserializerust-analyzer cargo serde_core 1.0.229 de/impls/impl#[String][`Deserialize<'de>`]deserialize().(deserializer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 460 | s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(serderust-analyzer cargo serde 1.0.229 crate/::derust-analyzer cargo serde_core 1.0.229 de/::Errorrust-analyzer cargo serde_core 1.0.229 de/Error#::customrust-analyzer cargo serde_core 1.0.229 de/Error#custom().) |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | #[cfg(feature = "serde")] |
| 465 | impl serderust-analyzer cargo serde 1.0.229 crate/::Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize# for Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# { |
| 466 | fn serializerust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Error#> |
| 467 | where |
| 468 | S: serderust-analyzer cargo serde 1.0.229 crate/::Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#, |
| 469 | { |
| 470 | self.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().serializerust-analyzer cargo serde_core 1.0.229 ser/impls/impl#[String][Serialize]serialize().(serializer) |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | 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 RDescriptionrust-analyzer cargo r-description 0.4.1 lossy/RDescription# { |
| 475 | type Errrust-analyzer cargo r-description 0.4.1 lossy/impl#[RDescription][FromStr]Err# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; |
| 476 | |
| 477 | fn from_strrust-analyzer cargo r-description 0.4.1 lossy/impl#[RDescription][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[RDescription][FromStr], Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[RDescription][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 478 | let para = deb822_fastrust-analyzer cargo deb822-fast 0.2.3 crate/::Paragraphrust-analyzer cargo deb822-fast 0.2.3 Paragraph#::from_strrust-analyzer cargo deb822-fast 0.2.3 impl#[Paragraph][FromStr]from_str().(s).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 479 | Selfrust-analyzer cargo r-description 0.4.1 lossy/impl#[RDescription][FromStr]::from_paragraphrust-analyzer cargo r-description 0.4.1 lossy/impl#[RDescription][`FromDeb822Paragraph<P>`]from_paragraph().(¶) |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | 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 RDescriptionrust-analyzer cargo r-description 0.4.1 lossy/RDescription# { |
| 484 | fn fmtrust-analyzer cargo r-description 0.4.1 lossy/impl#[RDescription][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# { |
| 485 | let para: deb822_fastrust-analyzer cargo deb822-fast 0.2.3 crate/::Paragraphrust-analyzer cargo deb822-fast 0.2.3 Paragraph# = self.to_paragraphrust-analyzer cargo r-description 0.4.1 lossy/impl#[RDescription][`ToDeb822Paragraph<P>`]to_paragraph().(); |
| 486 | f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(¶.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 487 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | #[cfg(test)] |
| 492 | mod testsrust-analyzer cargo r-description 0.4.1 lossy/tests/ { |
| 493 | use superrust-analyzer cargo r-description 0.4.1 lossy/::*; |
| 494 | |
| 495 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 496 | fn test_parserust-analyzer cargo r-description 0.4.1 lossy/tests/test_parse().() { |
| 497 | let s = r###"Package: mypackage |
| 498 | Title: What the Package Does (One Line, Title Case) |
| 499 | Version: 0.0.0.9000 |
| 500 | Authors@R: |
| 501 | person("First", "Last", , "[email protected]", role = c("aut", "cre"), |
| 502 | comment = c(ORCID = "YOUR-ORCID-ID")) |
| 503 | Description: What the package does (one paragraph). |
| 504 | License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a |
| 505 | license |
| 506 | Encoding: UTF-8 |
| 507 | Roxygen: list(markdown = TRUE) |
| 508 | RoxygenNote: 7.3.2 |
| 509 | "###; |
| 510 | let desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossy/RDescription# = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 511 | |
| 512 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.namerust-analyzer cargo r-description 0.4.1 lossy/RDescription#name., "mypackage".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 513 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 514 | desc.titlerust-analyzer cargo r-description 0.4.1 lossy/RDescription#title., |
| 515 | "What the Package Does (One Line, Title Case)".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 516 | ); |
| 517 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.versionrust-analyzer cargo r-description 0.4.1 lossy/RDescription#version., "0.0.0.9000".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 518 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 519 | desc.authorsrust-analyzer cargo r-description 0.4.1 lossy/RDescription#authors., |
| 520 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(RCoderust-analyzer cargo r-description 0.4.1 RCode#( |
| 521 | r#" |
| 522 | person("First", "Last", , "[email protected]", role = c("aut", "cre"), |
| 523 | comment = c(ORCID = "YOUR-ORCID-ID"))"# |
| 524 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 525 | )) |
| 526 | ); |
| 527 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 528 | desc.descriptionrust-analyzer cargo r-description 0.4.1 lossy/RDescription#description., |
| 529 | "What the package does (one paragraph).".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 530 | ); |
| 531 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 532 | desc.licenserust-analyzer cargo r-description 0.4.1 lossy/RDescription#license., |
| 533 | "`use_mit_license()`, `use_gpl3_license()` or friends to pick a\nlicense".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 534 | ); |
| 535 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.encodingrust-analyzer cargo r-description 0.4.1 lossy/RDescription#encoding., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("UTF-8".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 536 | |
| 537 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 538 | desc.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 539 | r###"Package: mypackage |
| 540 | Description: What the package does (one paragraph). |
| 541 | Title: What the Package Does (One Line, Title Case) |
| 542 | Authors@R: |
| 543 | person("First", "Last", , "[email protected]", role = c("aut", "cre"), |
| 544 | comment = c(ORCID = "YOUR-ORCID-ID")) |
| 545 | Version: 0.0.0.9000 |
| 546 | Encoding: UTF-8 |
| 547 | License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a |
| 548 | license |
| 549 | "### |
| 550 | ); |
| 551 | } |
| 552 | |
| 553 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 554 | fn test_parse_dplyrrust-analyzer cargo r-description 0.4.1 lossy/tests/test_parse_dplyr().() { |
| 555 | let s = include_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_str!!("../testdata/dplyr.desc"); |
| 556 | let desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossy/RDescription# = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 557 | |
| 558 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.namerust-analyzer cargo r-description 0.4.1 lossy/RDescription#name., "dplyr".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 559 | } |
| 560 | |
| 561 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 562 | fn test_parse_relationsrust-analyzer cargo r-description 0.4.1 lossy/tests/test_parse_relations().() { |
| 563 | let input = "cli"; |
| 564 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 565 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input); |
| 566 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(), 1); |
| 567 | let relation = &parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().0]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().; |
| 568 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli"); |
| 569 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 570 | |
| 571 | let input = "cli (>= 0.20.21)"; |
| 572 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 573 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input); |
| 574 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(), 1); |
| 575 | let relation = &parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().0]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().; |
| 576 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21)"); |
| 577 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 578 | relation.versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version., |
| 579 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(( |
| 580 | VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#, |
| 581 | "0.20.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 582 | )) |
| 583 | ); |
| 584 | |
| 585 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = "xml2 (> 1.0.0)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 586 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(), 1); |
| 587 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().0]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index()..namerust-analyzer cargo r-description 0.4.1 lossy/Relation#name., "xml2"); |
| 588 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 589 | parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().0]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index()..versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version., |
| 590 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThan#, "1.0.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())) |
| 591 | ); |
| 592 | |
| 593 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = "xml2 (< 2.0.0)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 594 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(), 1); |
| 595 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().0]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index()..namerust-analyzer cargo r-description 0.4.1 lossy/Relation#name., "xml2"); |
| 596 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 597 | parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().0]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index()..versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version., |
| 598 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThan#, "2.0.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())) |
| 599 | ); |
| 600 | |
| 601 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = "xml2 (== 2.0.0)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 602 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(), 1); |
| 603 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 604 | parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().0]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index()..versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version., |
| 605 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::Equalrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#Equal#, "2.0.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())) |
| 606 | ); |
| 607 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "xml2 (== 2.0.0)"); |
| 608 | |
| 609 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = "xml2 (!= 2.0.0)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 610 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(), 1); |
| 611 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 612 | parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().0]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index()..versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version., |
| 613 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::NotEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#NotEqual#, "2.0.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())) |
| 614 | ); |
| 615 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "xml2 (!= 2.0.0)"); |
| 616 | } |
| 617 | |
| 618 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 619 | fn test_multiplerust-analyzer cargo r-description 0.4.1 lossy/tests/test_multiple().() { |
| 620 | let input = "cli (>= 0.20.21), cli (< 0.21)"; |
| 621 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 622 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input); |
| 623 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(), 2); |
| 624 | let relation = &parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().0]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().; |
| 625 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21)"); |
| 626 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 627 | relation.versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version., |
| 628 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(( |
| 629 | VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#, |
| 630 | "0.20.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 631 | )) |
| 632 | ); |
| 633 | let relation = &parsed[rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().1]rust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations][`Index<usize>`]index().; |
| 634 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (< 0.21)"); |
| 635 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 636 | relation.versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version., |
| 637 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThan#, "0.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())) |
| 638 | ); |
| 639 | } |
| 640 | |
| 641 | #[cfg(feature = "serde")] |
| 642 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 643 | fn test_serde_relationsrust-analyzer cargo r-description 0.4.1 lossy/tests/test_serde_relations().() { |
| 644 | let input = "cli (>= 0.20.21), cli (< 0.21)"; |
| 645 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 646 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::to_stringrust-analyzer cargo serde_json 1.0.151 ser/to_string().(&parsed).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 647 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#""cli (>= 0.20.21), cli (< 0.21)""#); |
| 648 | let deserialized: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::from_strrust-analyzer cargo serde_json 1.0.151 de/from_str().(&serialized).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 649 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized, parsed); |
| 650 | } |
| 651 | |
| 652 | #[cfg(feature = "serde")] |
| 653 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 654 | fn test_serde_relationrust-analyzer cargo r-description 0.4.1 lossy/tests/test_serde_relation().() { |
| 655 | let input = "cli (>= 0.20.21)"; |
| 656 | let parsed: Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 657 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::to_stringrust-analyzer cargo serde_json 1.0.151 ser/to_string().(&parsed).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 658 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#""cli (>= 0.20.21)""#); |
| 659 | let deserialized: Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::from_strrust-analyzer cargo serde_json 1.0.151 de/from_str().(&serialized).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 660 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized, parsed); |
| 661 | } |
| 662 | |
| 663 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 664 | fn test_relations_is_emptyrust-analyzer cargo r-description 0.4.1 lossy/tests/test_relations_is_empty().() { |
| 665 | let input = "cli (>= 0.20.21)"; |
| 666 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 667 | 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().parsed.is_emptyrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]is_empty().()); |
| 668 | let input = ""; |
| 669 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 670 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parsed.is_emptyrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]is_empty().()); |
| 671 | } |
| 672 | |
| 673 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 674 | fn test_relations_lenrust-analyzer cargo r-description 0.4.1 lossy/tests/test_relations_len().() { |
| 675 | let input = "cli (>= 0.20.21), cli (< 0.21)"; |
| 676 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 677 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(), 2); |
| 678 | } |
| 679 | |
| 680 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 681 | fn test_relations_removerust-analyzer cargo r-description 0.4.1 lossy/tests/test_relations_remove().() { |
| 682 | let input = "cli (>= 0.20.21), cli (< 0.21)"; |
| 683 | let mut parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 684 | parsed.removerust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]remove().(1); |
| 685 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]len().(), 1); |
| 686 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21)"); |
| 687 | } |
| 688 | |
| 689 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 690 | fn test_relations_satisfied_byrust-analyzer cargo r-description 0.4.1 lossy/tests/test_relations_satisfied_by().() { |
| 691 | let input = "cli (>= 0.20.21), cli (< 0.21)"; |
| 692 | let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 693 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parsed.satisfied_byrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]satisfied_by().(|name: &str| -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Versionrust-analyzer cargo r-description 0.4.1 version/Version#> { |
| 694 | match name { |
| 695 | "cli" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.20.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 696 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 697 | } |
| 698 | })); |
| 699 | 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().parsed.satisfied_byrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]satisfied_by().(|name: &str| -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Versionrust-analyzer cargo r-description 0.4.1 version/Version#> { |
| 700 | match name { |
| 701 | "cli" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 702 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 703 | } |
| 704 | })); |
| 705 | } |
| 706 | |
| 707 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 708 | fn test_relation_satisfied_byrust-analyzer cargo r-description 0.4.1 lossy/tests/test_relation_satisfied_by().() { |
| 709 | let input = "cli (>= 0.20.21)"; |
| 710 | let parsed: Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 711 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parsed.satisfied_byrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation]satisfied_by().(|name: &str| -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Versionrust-analyzer cargo r-description 0.4.1 version/Version#> { |
| 712 | match name { |
| 713 | "cli" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.20.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 714 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 715 | } |
| 716 | })); |
| 717 | 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().parsed.satisfied_byrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation]satisfied_by().(|name: &str| -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Versionrust-analyzer cargo r-description 0.4.1 version/Version#> { |
| 718 | match name { |
| 719 | "cli" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.20.20".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 720 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 721 | } |
| 722 | })); |
| 723 | } |
| 724 | |
| 725 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 726 | fn test_parse_url_entryrust-analyzer cargo r-description 0.4.1 lossy/tests/test_parse_url_entry().() { |
| 727 | let input = "https://example.com/"; |
| 728 | let parsed: UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 729 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), input); |
| 730 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 731 | |
| 732 | let input = "https://example.com (Example)"; |
| 733 | let parsed: UrlEntryrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 734 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.com/"); |
| 735 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Example".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 736 | } |
| 737 | |
| 738 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 739 | fn test_deserialize_url_listrust-analyzer cargo r-description 0.4.1 lossy/tests/test_deserialize_url_list().() { |
| 740 | let input = "https://example.com/, https://example.org (Example)"; |
| 741 | let parsed = deserialize_url_listrust-analyzer cargo r-description 0.4.1 lossy/deserialize_url_list().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 742 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 743 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.com/"); |
| 744 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 745 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.org/"); |
| 746 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Example".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 747 | } |
| 748 | |
| 749 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 750 | fn test_deserialize_url_list2rust-analyzer cargo r-description 0.4.1 lossy/tests/test_deserialize_url_list2().() { |
| 751 | let input = "https://example.com/\n https://example.org (Example)\n https://example.net"; |
| 752 | let parsed = deserialize_url_listrust-analyzer cargo r-description 0.4.1 lossy/deserialize_url_list().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 753 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 3); |
| 754 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.com/"); |
| 755 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 756 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.org/"); |
| 757 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Example".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 758 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..urlrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#url..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.net/"); |
| 759 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..labelrust-analyzer cargo r-description 0.4.1 lossy/UrlEntry#label., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 760 | } |
| 761 | |
| 762 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 763 | fn test_deserialize_repository_listrust-analyzer cargo r-description 0.4.1 lossy/tests/test_deserialize_repository_list().() { |
| 764 | let input = "https://example.com/src/contrib,\n https://example.org/src/contrib"; |
| 765 | let parsed = deserialize_repository_listrust-analyzer cargo r-description 0.4.1 lossy/deserialize_repository_list().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 766 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 767 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.com/src/contrib"); |
| 768 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.org/src/contrib"); |
| 769 | } |
| 770 | |
| 771 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 772 | fn test_parse_additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossy/tests/test_parse_additional_repositories().() { |
| 773 | let s = r###"Package: mypackage |
| 774 | Title: What the Package Does |
| 775 | Version: 1.0.0 |
| 776 | Description: What the package does. |
| 777 | License: MIT |
| 778 | Additional_repositories: https://example.com/src/contrib, |
| 779 | https://example.org/src/contrib |
| 780 | "###; |
| 781 | let desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossy/RDescription# = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 782 | |
| 783 | let repositories = desc.additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossy/RDescription#additional_repositories..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 784 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repositories.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 785 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repositories[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.com/src/contrib"); |
| 786 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repositories[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().(), "https://example.org/src/contrib"); |
| 787 | |
| 788 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 789 | desc.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 790 | "Package: mypackage\nDescription: What the package does.\nTitle: What the Package Does\nVersion: 1.0.0\nLicense: MIT\nAdditional_repositories: https://example.com/src/contrib, https://example.org/src/contrib\n" |
| 791 | ); |
| 792 | } |
| 793 | } |