diff src/user.rs @ 41:63e77a9de3ab

...
author AnaTofuZ <anatofuz@gmail.com>
date Sun, 22 Nov 2020 16:48:05 +0900
parents afec42bdd5ab
children
line wrap: on
line diff
--- a/src/user.rs	Sun Nov 22 15:57:31 2020 +0900
+++ b/src/user.rs	Sun Nov 22 16:48:05 2020 +0900
@@ -6,7 +6,8 @@
 
 pub struct UserDetail<'a> {
     pub user: &'a User,
-    pub grade: String,
+    pub year: String,
+    pub affilication: String,
 }
 
 impl<'a> UserDetail<'a> {
@@ -14,16 +15,20 @@
         // e195730 -> 19
         let year = user.name.chars().skip(1).take(2).collect::<String>();
         // e195730 -> e19, tnal -> teacher
-        let grade = if year.parse::<u8>().is_ok() {
+        let affilication = if year.parse::<u8>().is_ok() {
             user.name.chars().take(3).collect::<String>()
         } else {
             "teacher".to_string()
         };
-        UserDetail { user, grade }
+        UserDetail {
+            user,
+            year,
+            affilication,
+        }
     }
 
     pub fn getpass(self) -> String {
-        format!("{}/{}", self.grade, &self.user.name)
+        format!("{}/{}", self.affilication, &self.user.name)
     }
 }