Prechádzať zdrojové kódy

Make all fields of Dir private

Ben S 11 rokov pred
rodič
commit
e835fe8fe3
2 zmenil súbory, kde vykonal 8 pridanie a 3 odobranie
  1. 7 2
      src/dir.rs
  2. 1 1
      src/file.rs

+ 7 - 2
src/dir.rs

@@ -8,8 +8,8 @@ use file::File;
 /// check the existence of surrounding files, then highlight themselves
 /// check the existence of surrounding files, then highlight themselves
 /// accordingly. (See `File#get_source_files`)
 /// accordingly. (See `File#get_source_files`)
 pub struct Dir {
 pub struct Dir {
-    pub contents: Vec<Path>,
-    pub path: Path,
+    contents: Vec<Path>,
+    path: Path,
 }
 }
 
 
 impl Dir {
 impl Dir {
@@ -42,4 +42,9 @@ impl Dir {
     pub fn contains(&self, path: &Path) -> bool {
     pub fn contains(&self, path: &Path) -> bool {
         self.contents.contains(path)
         self.contents.contains(path)
     }
     }
+
+    /// Append a path onto the path specified by this directory.
+    pub fn join(&self, child: Path) -> Path {
+        self.path.join(child)
+    }
 }
 }

+ 1 - 1
src/file.rs

@@ -113,7 +113,7 @@ impl<'a> File<'a> {
 
 
         if let Ok(path) = fs::readlink(&self.path) {
         if let Ok(path) = fs::readlink(&self.path) {
             let target_path = match self.dir {
             let target_path = match self.dir {
-                Some(dir) => dir.path.join(path),
+                Some(dir) => dir.join(path),
                 None => path,
                 None => path,
             };
             };