Parses a list resource. The list must be non-empty and it has to contain uniaue values. The values inside the list can be either numbers or strings. Strings can be put into quotes if you need to include a comma inside of them. Example: `[1, 2]`, `[abc, def]`, `["abc","a,b",c]`.
()
| 95 | /// Strings can be put into quotes if you need to include a comma inside of them. |
| 96 | /// Example: `[1, 2]`, `[abc, def]`, `["abc","a,b",c]`. |
| 97 | fn parse_resource_list() -> impl CharParser<ResourceDescriptorKind> { |
| 98 | parse_individual_resources().try_map(|indices, span| { |
| 99 | if indices.is_empty() { |
| 100 | Err(ParseError::custom( |
| 101 | span, |
| 102 | "List has to contain at least a single element", |
| 103 | )) |
| 104 | } else { |
| 105 | ResourceDescriptorKind::list(indices).map_err(|error| match error { |
| 106 | DescriptorError::ResourceListItemsNotUnique => { |
| 107 | ParseError::custom(span, "List items have to be unique") |
| 108 | } |
| 109 | error => ParseError::custom(span, error.to_string()), |
| 110 | }) |
| 111 | } |
| 112 | }) |
| 113 | } |
| 114 | |
| 115 | /// Parses a range resource. |
| 116 | /// The start of the range must be smaller or equal to the end. |
no test coverage detected