Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Select accessors public #2528

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions crate_universe/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fmt::Debug;

use serde::{de::DeserializeOwned, Deserialize, Deserializer, Serialize};

/// A wrapper around values where some values may be conditionally included (e.g. only on a certain platform), and others are unconditional.
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct Select<T>
where
Expand Down Expand Up @@ -78,19 +79,23 @@ where
}
}

pub(crate) fn is_empty(&self) -> bool {
/// Whether there zero values in this collection, common or configuration-specific.
pub fn is_empty(&self) -> bool {
T::is_empty(self)
}

pub(crate) fn configurations(&self) -> BTreeSet<String> {
/// A list of the configurations which have some configuration-specific value associated.
pub fn configurations(&self) -> BTreeSet<String> {
self.selects.keys().cloned().collect()
}

pub(crate) fn items(&self) -> Vec<(Option<String>, T::ItemType)> {
/// All values and their associated configurations, if any.
pub fn items(&self) -> Vec<(Option<String>, T::ItemType)> {
T::items(self)
}

pub(crate) fn values(&self) -> Vec<T::ItemType> {
/// All values, whether common or configured.
pub fn values(&self) -> Vec<T::ItemType> {
T::values(self)
}

Expand Down
Loading