Skip to main content

scientific_method/
hypothesis.rs

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