Skip to main content

scientific_method/
control.rs

1// Copyright © 2026 James Hunt. All rights reserved.
2
3/// A condition held fixed while an experiment is performed.
4#[derive(Debug, Clone, PartialEq, Eq)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub struct Control {
7    pub name: String,
8    pub description: Option<String>,
9}
10
11impl Control {
12    pub fn new(name: impl Into<String>) -> Self {
13        Self {
14            name: name.into(),
15            description: None,
16        }
17    }
18
19    pub fn with_description(mut self, description: impl Into<String>) -> Self {
20        self.description = Some(description.into());
21        self
22    }
23}