pub enum ExampleRequirement {
Required,
NotApplicable {
reason: &'static str,
},
}Expand description
Whether an item owes an executable example, and when it does not, why not.
Variants§
Required
It owes one.
NotApplicable
It does not, for this reason. The reason is printed in the report, so that what the policy does not ask for is as visible as what it does.
Implementations§
Source§impl ExampleRequirement
impl ExampleRequirement
Sourcepub fn of(item: &Item) -> Self
pub fn of(item: &Item) -> Self
Classify an item. Derived from the item’s kind and shape; nothing declares this.
use majordomus_cli::quality::policy::ExampleRequirement;
use majordomus_cli::quality::source::Inventory;
let dir = tempfile::tempdir().unwrap();
let src = dir.path().join("src");
std::fs::create_dir_all(&src).unwrap();
std::fs::write(src.join("lib.rs"), r#"//! Root.
/// A limit that matters.
pub const LIMIT: usize = 10;
/// Counts.
pub fn count() -> usize { LIMIT }
"#).unwrap();
let inv = Inventory::of_crate(dir.path()).unwrap();
let f = ExampleRequirement::of(inv.item("majordomus_cli::count").unwrap());
assert_eq!(f, ExampleRequirement::Required);
let c = ExampleRequirement::of(inv.item("majordomus_cli::LIMIT").unwrap());
assert!(matches!(c, ExampleRequirement::NotApplicable { .. }));Sourcepub fn is_required(&self) -> bool
pub fn is_required(&self) -> bool
Does this item owe an example?
use majordomus_cli::quality::policy::ExampleRequirement;
assert!(ExampleRequirement::Required.is_required());
assert!(!ExampleRequirement::NotApplicable { reason: "x" }.is_required());Trait Implementations§
Source§impl Clone for ExampleRequirement
impl Clone for ExampleRequirement
Source§fn clone(&self) -> ExampleRequirement
fn clone(&self) -> ExampleRequirement
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ExampleRequirement
impl Debug for ExampleRequirement
Source§impl Deserialize<'static> for ExampleRequirement
impl Deserialize<'static> for ExampleRequirement
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'static>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'static>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ExampleRequirement
Source§impl JsonSchema for ExampleRequirement
impl JsonSchema for ExampleRequirement
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for ExampleRequirement
impl PartialEq for ExampleRequirement
Source§fn eq(&self, other: &ExampleRequirement) -> bool
fn eq(&self, other: &ExampleRequirement) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for ExampleRequirement
impl Serialize for ExampleRequirement
impl StructuralPartialEq for ExampleRequirement
Auto Trait Implementations§
impl Freeze for ExampleRequirement
impl RefUnwindSafe for ExampleRequirement
impl Send for ExampleRequirement
impl Sync for ExampleRequirement
impl Unpin for ExampleRequirement
impl UnsafeUnpin for ExampleRequirement
impl UnwindSafe for ExampleRequirement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.