Debian Codegraph @

src/parse.rs

raw symbols SCIP
1 use craterust-analyzer cargo runtime-format 0.1.3 crate/::ToFormatParserrust-analyzer cargo runtime-format 0.1.3 ToFormatParser#;
2
3 #[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:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)]
4 /// An enum representing the parsed portion of a format string
5 #[non_exhaustive]
6 pub enum ParseSegmentrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#<'a> {
7 /// A string literal to be included as is
8 Literalrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#Literal#(&'a str),
9 /// A keyed value, that should be looked up using [`FormatKey`](crate::FormatKey)
10 Keyrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#Key#(&'a str),
11 }
12
13 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for ParseSegmentrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#<'_> {
14 fn defaultrust-analyzer cargo runtime-format 0.1.3 parse/impl#[`ParseSegment<'_>`][Default]default().() -> Selfrust-analyzer cargo runtime-format 0.1.3 parse/impl#[`ParseSegment<'_>`][Default] {
15 Selfrust-analyzer cargo runtime-format 0.1.3 parse/impl#[`ParseSegment<'_>`][Default]::Literalrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#Literal#("")
16 }
17 }
18
19 /// An [`Iterator`] of [`ParseSegment`]s. Returned by of [`str::to_parser`](ToFormatParser).
20 pub struct FromStrrust-analyzer cargo runtime-format 0.1.3 parse/FromStr#<'a> {
21 pub(craterust-analyzer cargo runtime-format 0.1.3 crate/) srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s.: &'a str,
22 pub(craterust-analyzer cargo runtime-format 0.1.3 crate/) is_keyrust-analyzer cargo runtime-format 0.1.3 parse/FromStr#is_key.: bool,
23 }
24
25 impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for FromStrrust-analyzer cargo runtime-format 0.1.3 parse/FromStr#<'a> {
26 type Itemrust-analyzer cargo runtime-format 0.1.3 parse/impl#[`FromStr<'a>`][Iterator]Item# = ParseSegmentrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#<'a>;
27
28 fn nextrust-analyzer cargo runtime-format 0.1.3 parse/impl#[`FromStr<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo runtime-format 0.1.3 parse/impl#[`FromStr<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
29 if self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
30 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
31 } else if self.is_keyrust-analyzer cargo runtime-format 0.1.3 parse/FromStr#is_key. {
32 match self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s..strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('{') {
33 // escaped
34 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rest) => match rest.split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().('{') {
35 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
36 self.is_keyrust-analyzer cargo runtime-format 0.1.3 parse/FromStr#is_key. = false;
37 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParseSegmentrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#::Literalrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#Literal#(corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/take().(&mut self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s.)))
38 }
39 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((prefix, rest)) => {
40 let x = &self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#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#prefix.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][`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/index/Index#index().;
41 self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s. = rest;
42 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParseSegmentrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#::Literalrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#Literal#(x))
43 }
44 },
45 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => match self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s..split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().('}') {
46 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((key, rest)) => {
47 self.is_keyrust-analyzer cargo runtime-format 0.1.3 parse/FromStr#is_key. = false;
48 self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s. = rest;
49 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParseSegmentrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#::Keyrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#Key#(key))
50 }
51 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
52 },
53 }
54 } else {
55 match self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s..split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().('{') {
56 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParseSegmentrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#::Literalrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#Literal#(corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/take().(&mut self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s.))),
57 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((prefix, rest)) => {
58 self.is_keyrust-analyzer cargo runtime-format 0.1.3 parse/FromStr#is_key. = true;
59 self.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s. = rest;
60 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParseSegmentrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#::Literalrust-analyzer cargo runtime-format 0.1.3 parse/ParseSegment#Literal#(prefix))
61 }
62 }
63 }
64 }
65 }
66
67 impl<'a> ToFormatParserrust-analyzer cargo runtime-format 0.1.3 ToFormatParser#<'a> for str {
68 type Parserrust-analyzer cargo runtime-format 0.1.3 parse/impl#[str][`ToFormatParser<'a>`]Parser# = FromStrrust-analyzer cargo runtime-format 0.1.3 parse/FromStr#<'a>;
69
70 fn to_parserrust-analyzer cargo runtime-format 0.1.3 parse/impl#[str][`ToFormatParser<'a>`]to_parser().(&'a self) -> Selfrust-analyzer cargo runtime-format 0.1.3 parse/impl#[str][`ToFormatParser<'a>`]::Parserrust-analyzer cargo runtime-format 0.1.3 ToFormatParser#Parser# {
71 FromStrrust-analyzer cargo runtime-format 0.1.3 parse/FromStr# {
72 srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s.: self,
73 is_keyrust-analyzer cargo runtime-format 0.1.3 parse/FromStr#is_key.: false,
74 }
75 }
76
77 fn unparsedrust-analyzer cargo runtime-format 0.1.3 parse/impl#[str][`ToFormatParser<'a>`]unparsed().(iter: Selfrust-analyzer cargo runtime-format 0.1.3 parse/impl#[str][`ToFormatParser<'a>`]::Parserrust-analyzer cargo runtime-format 0.1.3 ToFormatParser#Parser#) -> &'a str {
78 iter.srust-analyzer cargo runtime-format 0.1.3 parse/FromStr#s.
79 }
80 }