[−][src]Struct lab_grader::criterion::Criterion
A single Criterion
Fields
stub: String
An ID stub used to identify this criterion
name: String
A short (< 30 characters), descriptive name
worth: i16
Point value of this criterion. If it passes, this value
will be added to the Submission
grade.
Can be negative if you wish to subtract points. Be sure to get your logic right. This value is added to the submission grade if the test returns true.
index: i64
An index to sort by when running.
Lowest first. Defaults to 100.
messages: (String, String)
Pass or fail messages, respectively
When printing a criterion, the appropriate message will be printed. Not much use other than that.
desc: Option<String>
An optional description
test: Box<dyn Fn(&TestData) -> bool>
The criterion's test
Determines if the criterion passes or fails. This signature is required.
status: Option<bool>
If the test passed, failed, or hasn't been run.
None
if it hasn't been run, Some(true
) or Some(false
) otherwise.
If this value is Some
, the test has been run.
hide: bool
Renders the criterion unable to be printed
Implementations
impl Criterion
[src]
pub fn new(name: &str) -> CriterionBuilder
[src]
Returns a CriterionBuilder
,
which can be built()
.
Example
A basic criterion
use lab_grader::Criterion; let c = Criterion::new("my crit").build(); assert_eq!(c.name, "my crit");
pub fn success_message(&self) -> &String
[src]
Returns the success message, ie. the first message in the
messages
tuple.
pub fn failure_message(&self) -> &String
[src]
Returns the failure message, ie. the second message in the
messages
tuple.
pub fn attach(&mut self, test: Box<dyn Fn(&TestData) -> bool>)
[src]
Sets the test method of a criterion
pub fn test_with_data(&mut self, data: &TestData) -> bool
[src]
Runs the criterion's test function with the data provided.
This is almost equivilent to calling (criterion.test)(data)
, but this
method also sets the status of the criterion to the result of the test.
You should avoid calling the test directly, and call this or the
test
method instead.
The criterion must be mutable to call this method, as the status is changed to the result of the test.
You shouldn't call this method directly, instead grade an entire
Batch
.
pub fn test(&mut self) -> bool
[src]
Runs the criterions test and assigns the result to criterion.status
.
This is equivilent to running test_with_data
with
an empty TestData
.
You shouldn't call this method directly, instead grade an entire
Batch
.
pub fn print_short(&self)
[src]
Prints the essential criterion information in one line.
Trait Implementations
impl Display for Criterion
[src]
Displays the results of the criterion. You should test the criterion before printing it.
impl FromIterator<Criterion> for Criteria
[src]
fn from_iter<I: IntoIterator<Item = Criterion>>(iter: I) -> Self
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Criterion
impl !Send for Criterion
impl !Sync for Criterion
impl Unpin for Criterion
impl !UnwindSafe for Criterion
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, I> AsResult<T, I> for T where
I: Input,
I: Input,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,