Struct leetcode_rust::common::Case

source ·
pub struct Case<T, G, P> {
    pub inputs: Vec<T>,
    pub params: Vec<P>,
    pub values: Vec<G>,
    /* private fields */
}
Expand description

Test case wrapper struct

Generics

  • T - type of test inputs
  • G - type of expectations, must implement PartialEq and Display traits
  • P - type of optional parameters

Fields§

§inputs: Vec<T>

Input values of test case

§params: Vec<P>

Optional parameters when executing test case

§values: Vec<G>

Expected values of given input

Implementations§

Create new test case with no parameters

Arguments
  • input - test input
  • values - expected values, accept single- or multi-value vector

Create new test case with no parameters but multiple inputs

Arguments
  • inputs - test input, accept single- or multi-value vector
  • values - expected values, accept single- or multi-value vector

Create new test case with parameters

Arguments
  • input - test input
  • params - test parameters that vary among different cases
  • values - expected values, accept single- or multi-value vector

Create new test case with parameters and multi input

Arguments
  • inputs - test input, accept single- or multi-value vector
  • params - test parameters that vary among different cases
  • values - expected values, accept single- or multi-value vector

Check if solution output matches any expectations

Arguments
  • &self - inmutable borrow to object itself
  • result - solution output
use leetcode_rust::common::Case;
let case:Case<String, String, i32> = Case::new(String::from("A"), vec![String::from("A")]);
case.is_valid(String::from("A"))

Returns the index value in String form.

Returns the first element of inputs

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.