SHARE
TWEET

fluminurs option access patch

a guest Jan 20th, 2020 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/src/api/mod.rs b/src/api/mod.rs
  2. index c25f608..a3f54de 100644
  3. --- a/src/api/mod.rs
  4. +++ b/src/api/mod.rs
  5. @@ -2,9 +2,9 @@ use std::collections::HashMap;
  6.  use std::sync::Arc;
  7.  
  8.  use reqwest::header::CONTENT_TYPE;
  9. -use reqwest::{Client, RequestBuilder, Response, Url};
  10. -use reqwest::Method;
  11.  use reqwest::redirect::Policy;
  12. +use reqwest::Method;
  13. +use reqwest::{Client, RequestBuilder, Response, Url};
  14.  use serde::de::DeserializeOwned;
  15.  use serde::Deserialize;
  16.  
  17. diff --git a/src/api/module.rs b/src/api/module.rs
  18. index 983bddb..d43c61d 100644
  19. --- a/src/api/module.rs
  20. +++ b/src/api/module.rs
  21. @@ -41,19 +41,23 @@ pub struct Module {
  22.      pub code: String,
  23.      #[serde(rename = "courseName")]
  24.      pub name: String,
  25. -    access: Access,
  26. +    access: Option<Access>,
  27.      pub term: String,
  28.  }
  29.  
  30.  impl Module {
  31.      pub fn is_teaching(&self) -> bool {
  32. -        let access = &self.access;
  33. -        access.full
  34. -            || access.create
  35. -            || access.update
  36. -            || access.delete
  37. -            || access.settings_read
  38. -            || access.settings_update
  39. +        self.access
  40. +            .as_ref()
  41. +            .map(|access| {
  42. +                access.full
  43. +                    || access.create
  44. +                    || access.update
  45. +                    || access.delete
  46. +                    || access.settings_read
  47. +                    || access.settings_update
  48. +            })
  49. +            .unwrap_or(false)
  50.      }
  51.  
  52.      pub fn is_taking(&self) -> bool {
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top