Struct Task

Source
pub struct Task {
    pub tests_path: PathBuf,
    pub solution_path: PathBuf,
    pub time_limit: f32,
    pub tests_archive_path: PathBuf,
    pub cps_tests_archive_path: PathBuf,
    pub get_input_file_name: Box<dyn Fn(i32, i32, i32) -> String>,
    pub get_output_file_name: Box<dyn Fn(i32, i32, i32) -> String>,
    /* private fields */
}
Expand description

This struct represents an entire task. You can add subtasks, partial solutions and set the time limit. Once you are done, you can create tests for the task.

Fields§

§tests_path: PathBuf§solution_path: PathBuf§time_limit: f32§tests_archive_path: PathBuf§cps_tests_archive_path: PathBuf§get_input_file_name: Box<dyn Fn(i32, i32, i32) -> String>§get_output_file_name: Box<dyn Fn(i32, i32, i32) -> String>

Implementations§

Source§

impl Task

Source

pub fn new(name: &str, path: &Path) -> Self

This function creates a new task with the given name and path. The path should be a relative path to the task folder in which the tests will be generated. The solution should be at solution_path which is path/solution.cpp by default but can be changed.

Source

pub fn add_subtask(&mut self, subtask: Subtask) -> usize

This function adds a subtask to the task. The subtask must be ready as it cannot be modified after it is added to the task. The function returns the index of the subtask.

Source

pub fn add_subtask_dependency(&mut self, subtask: usize, dependency: usize)

This function adds a dependency between two subtasks. A dependency means, that the first subtask must be solved before the second subtask. In practice that means that all the tests from the dependency subtask will be added before the tests from the subtask. Dependencies apply recursively but do not duplicate tests. The subtask must be added to the task before this function is called.

Source

pub fn add_partial_solution( &mut self, solution_path: &str, passes_subtasks: &[usize], )

This function adds a partial solution to the task. A partial solution is a solution that only solves a subset of subtasks. When the task is generated, the partial solution will be run on all tests of the subtasks it solves. If the partial solution does not solve the exact subtasks it should, an error will be thrown.

Source

pub fn create_tests(&mut self) -> Result<()>

This function does all the work. It builds the solution and all partial solutions, generates tests and checks them.

Source

pub fn create_tests_no_print(&mut self) -> Result<()>

This is the same as create_tests but it doesn’t print anything.

Source

pub fn create_tests_for_cps(&mut self) -> Result<()>

This also generates a CPS file.

Auto Trait Implementations§

§

impl Freeze for Task

§

impl !RefUnwindSafe for Task

§

impl !Send for Task

§

impl !Sync for Task

§

impl Unpin for Task

§

impl !UnwindSafe for Task

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V