pub enum Verdict {
Counts,
Placeholder,
DoesNotNameSubject,
NotExecutable,
}Expand description
What one fenced block is worth as evidence about one item.
The variants are ordered by how far the block is from counting, and the report turns the best verdict among an item’s blocks into the finding it raises — so an item with one real example and three diagrams is clean, and an item with three ignored blocks is told which of its problems to fix first.
Variants§
Counts
Evidence: compiled by the toolchain, names the item, asserts something real.
Placeholder
Compiled and names the item, and asserts nothing, or nothing that could be false.
DoesNotNameSubject
Compiled, asserts something, and never mentions the item it documents.
NotExecutable
ignored, or a fenced box of prose: compiled by nobody.
Implementations§
Source§impl Verdict
impl Verdict
Sourcepub fn of(example: &Example, subject: &str) -> Verdict
pub fn of(example: &Example, subject: &str) -> Verdict
Judge one block as evidence about the item named subject.
subject is the item’s own name — Capability, classify, parse — because that
is what a caller writes. A method’s example may name the method or the type it is
on; both are the caller naming the thing being documented.
use majordomus_cli::quality::policy::Verdict;
use majordomus_cli::quality::source::Example;
let e = Example::parse("", &[
"let id = CapabilityId::parse(\"a.b\").unwrap();".into(),
"assert_eq!(id.namespace(), \"a\");".into(),
]);
assert_eq!(Verdict::of(&e, "CapabilityId"), Verdict::Counts);Sourcepub fn best(examples: &[&Example], subject: &str) -> Option<Verdict>
pub fn best(examples: &[&Example], subject: &str) -> Option<Verdict>
The best verdict among an item’s blocks: what the report acts on.
An item with no block at all has no verdict, which the caller reports as the missing example it is.
use majordomus_cli::quality::policy::Verdict;
use majordomus_cli::quality::source::Example;
let diagram = Example::parse("text", &["a picture".into()]);
let real = Example::parse("", &["assert!(Thing::new().ready());".into()]);
assert_eq!(Verdict::best(&[&diagram, &real], "Thing"), Some(Verdict::Counts));
assert_eq!(Verdict::best(&[], "Thing"), None);Sourcepub fn code(self) -> Option<ViolationCode>
pub fn code(self) -> Option<ViolationCode>
The finding this verdict raises, or None when the example counts.
use majordomus_cli::quality::policy::Verdict;
use majordomus_cli::quality::ViolationCode;
assert_eq!(Verdict::Counts.code(), None);
assert_eq!(Verdict::Placeholder.code(), Some(ViolationCode::RustExamplePlaceholder));Trait Implementations§
impl Copy for Verdict
Source§impl<'de> Deserialize<'de> for Verdict
impl<'de> Deserialize<'de> for Verdict
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Verdict
Source§impl JsonSchema for Verdict
impl JsonSchema for Verdict
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for Verdict
impl Ord for Verdict
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Verdict
impl PartialOrd for Verdict
impl StructuralPartialEq for Verdict
Auto Trait Implementations§
impl Freeze for Verdict
impl RefUnwindSafe for Verdict
impl Send for Verdict
impl Sync for Verdict
impl Unpin for Verdict
impl UnsafeUnpin for Verdict
impl UnwindSafe for Verdict
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
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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
key and return true if they are equal.