Make RelationLabel independent of map type and reduce trait bounds

This commit is contained in:
2026-05-05 16:10:04 -06:00
parent a8f7f93c78
commit 5dcbcbe522

View File

@@ -23,7 +23,6 @@
#![warn(missing_docs)]
use std::{
collections::BTreeMap,
fmt::{self, Debug},
hash::Hash,
str::FromStr,
@@ -52,7 +51,14 @@ use serde::{Deserialize, Serialize};
#[derive_where(Hash; T: HashProgramInfo)]
#[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))]
pub struct Program<T: ProgramInfo> {
pub relations: BTreeMap<T::RelationLabel, Relation<T>>,
/// A list of all relations defined in the program.
///
/// The relations are identified by [ProgramInfo::RelationLabel], although
/// the [Program] type does not commit to using one particular structure
/// over another for mapping relation labels to their entries. This allows
/// flexibility in deferring trait bounds to when an efficient index is
/// actually needed.
pub relations: Vec<Relation<T>>,
/// The list of assumptions in this program.
pub assumptions: Vec<Assumption<T>>,
@@ -418,7 +424,7 @@ pub trait ProgramInfo {
/// The type of relation identifiers.
///
/// These labels discriminate relation entries in a [Program].
type RelationLabel: Ord + Info;
type RelationLabel: Info;
/// Metadata for an assumption.
type AssumptionMeta: Info;