~repos /rust-embed

#rust#proc-macro#http

git clone https://pyrossh.dev/repos/rust-embed.git
Discussions: https://groups.google.com/g/rust-embed-devs

rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.


Files changed (1) hide show
  1. utils/src/lib.rs +11 -12
utils/src/lib.rs CHANGED
@@ -146,18 +146,17 @@ pub fn read_file_from_fs(file_path: &Path) -> io::Result<EmbeddedFile> {
146
146
  };
147
147
 
148
148
  let metadata = fs::metadata(file_path)?;
149
- let last_modified = metadata.modified().ok().map(|last_modified| {
149
+ let last_modified = metadata
150
- last_modified
150
+ .modified()
151
+ .ok()
151
- .duration_since(SystemTime::UNIX_EPOCH)
152
+ .and_then(|modified| modified.duration_since(SystemTime::UNIX_EPOCH).ok())
152
- .expect("Time before the UNIX epoch is unsupported")
153
- .as_secs()
153
+ .map(|secs| secs.as_secs());
154
- });
154
+
155
- let created = metadata.created().ok().map(|created| {
155
+ let created = metadata
156
- created
156
+ .created()
157
+ .ok()
157
- .duration_since(SystemTime::UNIX_EPOCH)
158
+ .and_then(|created| created.duration_since(SystemTime::UNIX_EPOCH).ok())
158
- .expect("Time before the UNIX epoch is unsupported")
159
- .as_secs()
159
+ .map(|secs| secs.as_secs());
160
- });
161
160
 
162
161
  #[cfg(feature = "mime-guess")]
163
162
  let mimetype = mime_guess::from_path(file_path).first_or_octet_stream().to_string();