Creates a new instance from the given alternatives. If an empty list of alternatives are given, returns `None`.
(
alternatives: impl IntoIterator<Item = LexRequirement>,
soft: bool,
)
| 713 | /// Creates a new instance from the given alternatives. If an empty list of |
| 714 | /// alternatives are given, returns `None`. |
| 715 | pub fn new_alternatives( |
| 716 | alternatives: impl IntoIterator<Item = LexRequirement>, |
| 717 | soft: bool, |
| 718 | ) -> Option<Self> { |
| 719 | let alternatives = alternatives.into_iter().collect::<Vec<_>>(); |
| 720 | (!alternatives.is_empty()).then(|| { |
| 721 | if soft { |
| 722 | Self::Soft(alternatives) |
| 723 | } else { |
| 724 | Self::Hard(alternatives) |
| 725 | } |
| 726 | }) |
| 727 | } |
| 728 | |
| 729 | /// Creates a new instance with a single hard requirement. |
| 730 | pub fn new(requirement: LexRequirement) -> Self { |