Bug 1488006: mozprofile: avoid redundant field names in struct init; r=jgraham
authorAndreas Tolfsen <ato@sny.no>
Sat, 01 Sep 2018 16:35:36 +0100
changeset 482892 a680beaf94c4c84662e7a9028fd3471a1d16cef2
parent 482891 03fde1788da9380ac3e17a7772920cf686f16fb0
child 482893 86af1d4f044ef6bdf6a3ded40171c47024d18ce8
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersjgraham
bugs1488006
milestone63.0a1
Bug 1488006: mozprofile: avoid redundant field names in struct init; r=jgraham
testing/mozbase/rust/mozprofile/src/prefreader.rs
testing/mozbase/rust/mozprofile/src/profile.rs
--- a/testing/mozbase/rust/mozprofile/src/prefreader.rs
+++ b/testing/mozbase/rust/mozprofile/src/prefreader.rs
@@ -12,19 +12,19 @@ use std::str;
 
 impl PrefReaderError {
     fn new(
         message: &'static str,
         position: Position,
         parent: Option<Box<Error>>,
     ) -> PrefReaderError {
         PrefReaderError {
-            message: message,
-            position: position,
-            parent: parent,
+            message,
+            position,
+            parent,
         }
     }
 }
 
 impl fmt::Display for PrefReaderError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(
             f,
@@ -152,21 +152,21 @@ struct TokenData<'a> {
     position: Position,
     data: Cow<'a, str>,
     start_pos: usize,
 }
 
 impl<'a> TokenData<'a> {
     fn new(token_type: TokenType, position: Position, start_pos: usize) -> TokenData<'a> {
         TokenData {
-            token_type: token_type,
+            token_type,
             complete: false,
-            position: position,
+            position,
             data: Cow::Borrowed(""),
-            start_pos: start_pos,
+            start_pos,
         }
     }
 
     fn start(&mut self, tokenizer: &PrefTokenizer, token_type: TokenType) {
         self.token_type = token_type;
         self.position = tokenizer.position;
         self.start_pos = tokenizer.pos;
     }
@@ -208,17 +208,17 @@ pub struct PrefTokenizer<'a> {
     position: Position,
     state: TokenizerState,
     next_state: Option<TokenizerState>,
 }
 
 impl<'a> PrefTokenizer<'a> {
     pub fn new(data: &'a [u8]) -> PrefTokenizer<'a> {
         PrefTokenizer {
-            data: data,
+            data,
             pos: 0,
             cur: None,
             position: Position::new(),
             state: TokenizerState::Junk,
             next_state: Some(TokenizerState::FunctionName),
         }
     }
 
--- a/testing/mozbase/rust/mozprofile/src/profile.rs
+++ b/testing/mozbase/rust/mozprofile/src/profile.rs
@@ -24,18 +24,18 @@ impl Profile {
                 let dir = TempDir::new("rust_mozprofile")?;
                 let temp_path = dir.path().to_path_buf();
                 temp_dir = Some(dir);
                 temp_path
             }
         };
 
         Ok(Profile {
-            path: path,
-            temp_dir: temp_dir,
+            path,
+            temp_dir,
             prefs: None,
             user_prefs: None,
         })
     }
 
     pub fn prefs(&mut self) -> Result<&mut PrefFile, PrefReaderError> {
         if self.prefs.is_none() {
             let mut pref_path = PathBuf::from(&self.path);
@@ -69,20 +69,17 @@ impl PrefFile {
             Preferences::new()
         } else {
             let mut f = File::open(&path)?;
             let mut buf = String::with_capacity(4096);
             f.read_to_string(&mut buf)?;
             parse(buf.as_bytes())?
         };
 
-        Ok(PrefFile {
-            path: path,
-            prefs: prefs,
-        })
+        Ok(PrefFile { path, prefs })
     }
 
     pub fn write(&self) -> IoResult<()> {
         let mut f = File::create(&self.path)?;
         serialize(&self.prefs, &mut f)
     }
 
     pub fn insert_slice<K>(&mut self, preferences: &[(K, Pref)])