1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-22 17:41:11 +00:00

remove useless doctest main fns

This commit is contained in:
Rob Ede 2022-02-22 12:32:06 +00:00
parent ce00c88963
commit 10ef9b0751
No known key found for this signature in database
GPG key ID: 97C636207D3EF933
5 changed files with 43 additions and 54 deletions

View file

@ -96,18 +96,18 @@ impl NamedFile {
/// ///
/// # Examples /// # Examples
/// ```ignore /// ```ignore
/// use std::{
/// io::{self, Write as _},
/// env,
/// fs::File
/// };
/// use actix_files::NamedFile; /// use actix_files::NamedFile;
/// use std::io::{self, Write};
/// use std::env;
/// use std::fs::File;
/// ///
/// fn main() -> io::Result<()> {
/// let mut file = File::create("foo.txt")?; /// let mut file = File::create("foo.txt")?;
/// file.write_all(b"Hello, world!")?; /// file.write_all(b"Hello, world!")?;
/// let named_file = NamedFile::from_file(file, "bar.txt")?; /// let named_file = NamedFile::from_file(file, "bar.txt")?;
/// # std::fs::remove_file("foo.txt"); /// # std::fs::remove_file("foo.txt");
/// Ok(()) /// Ok(())
/// }
/// ``` /// ```
pub fn from_file<P: AsRef<Path>>(file: File, path: P) -> io::Result<NamedFile> { pub fn from_file<P: AsRef<Path>>(file: File, path: P) -> io::Result<NamedFile> {
let path = path.as_ref().to_path_buf(); let path = path.as_ref().to_path_buf();

View file

@ -290,12 +290,10 @@ where
/// Ok(HttpResponse::Ok().into()) /// Ok(HttpResponse::Ok().into())
/// } /// }
/// ///
/// fn main() {
/// let app = App::new() /// let app = App::new()
/// .service(web::resource("/index.html").route( /// .service(web::resource("/index.html").route(
/// web::get().to(index))) /// web::get().to(index)))
/// .external_resource("youtube", "https://youtube.com/watch/{video_id}"); /// .external_resource("youtube", "https://youtube.com/watch/{video_id}");
/// }
/// ``` /// ```
pub fn external_resource<N, U>(mut self, name: N, url: U) -> Self pub fn external_resource<N, U>(mut self, name: N, url: U) -> Self
where where

View file

@ -118,12 +118,10 @@ pub trait FromRequest: Sized {
/// } /// }
/// } /// }
/// ///
/// fn main() {
/// let app = App::new().service( /// let app = App::new().service(
/// web::resource("/users/:first").route( /// web::resource("/users/:first").route(
/// web::post().to(index)) /// web::post().to(index))
/// ); /// );
/// }
/// ``` /// ```
impl<T> FromRequest for Option<T> impl<T> FromRequest for Option<T>
where where
@ -205,11 +203,9 @@ where
/// } /// }
/// } /// }
/// ///
/// fn main() {
/// let app = App::new().service( /// let app = App::new().service(
/// web::resource("/users/:first").route(web::post().to(index)) /// web::resource("/users/:first").route(web::post().to(index))
/// ); /// );
/// }
/// ``` /// ```
impl<T, E> FromRequest for Result<T, E> impl<T, E> FromRequest for Result<T, E>
where where

View file

@ -407,12 +407,10 @@ impl Drop for HttpRequest {
/// format!("Got thing: {:?}", req) /// format!("Got thing: {:?}", req)
/// } /// }
/// ///
/// fn main() {
/// let app = App::new().service( /// let app = App::new().service(
/// web::resource("/users/{first}").route( /// web::resource("/users/{first}").route(
/// web::get().to(index)) /// web::get().to(index))
/// ); /// );
/// }
/// ``` /// ```
impl FromRequest for HttpRequest { impl FromRequest for HttpRequest {
type Error = Error; type Error = Error;

View file

@ -93,7 +93,6 @@ where
/// "Welcome!" /// "Welcome!"
/// } /// }
/// ///
/// fn main() {
/// let app = App::new() /// let app = App::new()
/// .service( /// .service(
/// web::resource("/app") /// web::resource("/app")
@ -105,7 +104,6 @@ where
/// .guard(guard::Header("content-type", "text/json")) /// .guard(guard::Header("content-type", "text/json"))
/// .route(web::get().to(|| HttpResponse::MethodNotAllowed())) /// .route(web::get().to(|| HttpResponse::MethodNotAllowed()))
/// ); /// );
/// }
/// ``` /// ```
pub fn guard<G: Guard + 'static>(mut self, guard: G) -> Self { pub fn guard<G: Guard + 'static>(mut self, guard: G) -> Self {
self.guards.push(Box::new(guard)); self.guards.push(Box::new(guard));
@ -137,14 +135,13 @@ where
/// ``` /// ```
/// use actix_web::{web, guard, App}; /// use actix_web::{web, guard, App};
/// ///
/// fn main() {
/// let app = App::new().service( /// let app = App::new().service(
/// web::resource("/container/") /// web::resource("/container/")
/// .route(web::get().to(get_handler)) /// .route(web::get().to(get_handler))
/// .route(web::post().to(post_handler)) /// .route(web::post().to(post_handler))
/// .route(web::delete().to(delete_handler)) /// .route(web::delete().to(delete_handler))
/// ); /// );
/// } ///
/// # async fn get_handler() -> impl actix_web::Responder { actix_web::HttpResponse::Ok() } /// # async fn get_handler() -> impl actix_web::Responder { actix_web::HttpResponse::Ok() }
/// # async fn post_handler() -> impl actix_web::Responder { actix_web::HttpResponse::Ok() } /// # async fn post_handler() -> impl actix_web::Responder { actix_web::HttpResponse::Ok() }
/// # async fn delete_handler() -> impl actix_web::Responder { actix_web::HttpResponse::Ok() } /// # async fn delete_handler() -> impl actix_web::Responder { actix_web::HttpResponse::Ok() }