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

feat: topological sort of PackageRecords #218

Merged
merged 2 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions crates/rattler_conda_types/src/repo_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! of a channel. It provides indexing functionality.

pub mod patches;
mod topological_sort;

use std::collections::{BTreeMap, BTreeSet};
use std::fmt::{Display, Formatter};
Expand Down Expand Up @@ -180,6 +181,16 @@ impl RepoData {
}
}

impl PackageRecord {
/// Sorts the records topologically.
///
/// This function is deterministic, meaning that it will return the same result regardless of
/// the order of `records` and of the `depends` vector inside the records.
pub fn sort_topologically<T: AsRef<PackageRecord>>(records: Vec<T>) -> Vec<T> {
topological_sort::sort_topologically(records)
}
}

/// An error that can occur when parsing a platform from a string.
#[derive(Debug, Error, Clone, Eq, PartialEq)]
pub enum ConvertSubdirError {
Expand Down
Loading