pub struct SubmissionList {
pub submissions: Vec<Submission>,
pub success: u8,
}
Expand description
List of submissions by a user for a task
Fields§
§submissions: Vec<Submission>
§success: u8
Implementations§
Source§impl SubmissionList
impl SubmissionList
Sourcepub fn best_score(&self) -> f64
pub fn best_score(&self) -> f64
get the best score achieved among all submissions
Sourcepub fn get_last_high(&self) -> Option<&Submission>
pub fn get_last_high(&self) -> Option<&Submission>
get the last submission among those with highest score
Sourcepub fn get_fastest_high(&self, client: &Client) -> Option<&Submission>
pub fn get_fastest_high(&self, client: &Client) -> Option<&Submission>
get the fastest submission among those with highest score
in case of parity, the latest is returned
Examples found in repository?
examples/resubmit_all.rs (line 13)
3fn main(){
4 let username = String::from("user");
5 let password = "password";
6 let mut client = Client::new(username.clone());
7 client.login(password).unwrap();
8 let user = client.get_user(&username).unwrap();
9 for sc in user.scores.unwrap() {
10 if sc.score == 100.0 {
11 println!("{} has score 100", sc.title);
12 let sub_list = client.get_submission_list(&sc.name).unwrap();
13 let best_sub = sub_list.get_fastest_high(&client).unwrap();
14 let files = &best_sub.files;
15 if files.len() == 1 { // if it is not an output-only
16 let mut submitted: bool = false;
17 print!("Resubmitting {}", sc.name.clone());
18 while !submitted { // because cmsocial has a limit to submission rate
19 print!(".");
20 if client
21 .submit_normal(
22 &sc.name,
23 &client.get_file(&files[0]).unwrap(),
24 files[0].name.split(".").collect::<Vec<&str>>().last().unwrap(),
25 )
26 .is_ok()
27 {
28 submitted = true;
29 }
30 }
31 println!("");
32 }
33 }
34 }
35}
Trait Implementations§
Source§impl Clone for SubmissionList
impl Clone for SubmissionList
Source§fn clone(&self) -> SubmissionList
fn clone(&self) -> SubmissionList
Returns a copy of the value. Read more
1.0.0 · 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 SubmissionList
impl Debug for SubmissionList
Source§impl<'de> Deserialize<'de> for SubmissionList
impl<'de> Deserialize<'de> for SubmissionList
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SubmissionList
impl RefUnwindSafe for SubmissionList
impl Send for SubmissionList
impl Sync for SubmissionList
impl Unpin for SubmissionList
impl UnwindSafe for SubmissionList
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more