From 3e9c53eccaff342ad07ae2198f22f2b92cd91861 Mon Sep 17 00:00:00 2001 From: Daan de Graaf Date: Sun, 27 Jan 2019 11:44:13 +0100 Subject: [PATCH] Mark examples as `no_run`, add to CHANGES.md. --- CHANGES.md | 6 ++++++ src/fs.rs | 42 ++++++++---------------------------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e40bad5bd..83803abb0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Changes +## [x.x.xx] - xxxx-xx-xx + +### Added + +* Add `from_file` and `from_file_with_config` to `NamedFile` to allow sending files without a known path. #670 + ## [0.7.18] - 2019-01-10 ### Added diff --git a/src/fs.rs b/src/fs.rs index 814f2d96a..43cb13844 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -127,31 +127,18 @@ impl NamedFile { /// /// # Examples /// - /// ```rust + /// ```no_run /// extern crate actix_web; /// /// use actix_web::fs::NamedFile; /// use std::io::{self, Write}; /// use std::env; - /// # use std::fs::{self, File}; - /// # use std::path::PathBuf; - /// # - /// # fn path() -> PathBuf { - /// # let mut path = env::temp_dir(); - /// # path.push("actix-web-named-file-test-from-file"); - /// # path - /// # } - /// # - /// # fn tempfile() -> Result { - /// # let file = File::create(path())?; - /// # Ok(file) - /// # } + /// use std::fs::File; /// /// fn main() -> io::Result<()> { - /// let mut file = tempfile()?; + /// let mut file = File::create("foo.txt")?; /// file.write_all(b"Hello, world!")?; - /// let named_file = NamedFile::from_file(file, "foo.txt")?; - /// # fs::remove_file(path())?; + /// let named_file = NamedFile::from_file(file, "bar.txt")?; /// Ok(()) /// } /// ``` @@ -181,31 +168,18 @@ impl NamedFile { /// /// # Examples /// - /// ```rust + /// ```no_run /// extern crate actix_web; /// /// use actix_web::fs::{DefaultConfig, NamedFile}; /// use std::io::{self, Write}; /// use std::env; - /// # use std::fs::{self, File}; - /// # use std::path::PathBuf; - /// # - /// # fn path() -> PathBuf { - /// # let mut path = env::temp_dir(); - /// # path.push("actix-web-named-file-test-from-file-with-config"); - /// # path - /// # } - /// # - /// # fn tempfile() -> Result { - /// # let file = File::create(path())?; - /// # Ok(file) - /// # } + /// use std::fs::File; /// /// fn main() -> io::Result<()> { - /// let mut file = tempfile()?; + /// let mut file = File::create("foo.txt")?; /// file.write_all(b"Hello, world!")?; - /// let named_file = NamedFile::from_file_with_config(file, "foo.txt", DefaultConfig)?; - /// # fs::remove_file(path())?; + /// let named_file = NamedFile::from_file_with_config(file, "bar.txt", DefaultConfig)?; /// Ok(()) /// } /// ```