cartulary 0.3.0-alpha.1

The knowledge layer of your project — decisions, issues, docs, all in one place.
Documentation
/// Short, human-facing label for a query. Carried as data alongside the
/// script: the script's format is the adapter's concern, the domain only
/// sees the extracted text.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct QueryDescription(String);

impl QueryDescription {
    pub fn new(s: impl Into<String>) -> Self {
        Self(s.into())
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl std::fmt::Display for QueryDescription {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}

#[cfg(test)]
pub mod strategy {
    use super::QueryDescription;
    use proptest::prelude::*;

    pub fn query_description() -> impl Strategy<Value = QueryDescription> {
        ".{0,80}".prop_map(QueryDescription::new)
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use proptest::prelude::*;

    proptest! {
        #[test]
        fn as_str_returns_the_string_passed_to_new(text in ".{0,80}") {
            let d = QueryDescription::new(&text);
            prop_assert_eq!(d.as_str().to_string(), text);
        }
    }

    #[test]
    fn round_trips_through_as_str() {
        let d = QueryDescription::new("count issues");
        assert_eq!(d.as_str(), "count issues");
    }
}