Fix wording in 'config' docs.

This commit is contained in:
Sergio Benitez 2021-06-26 16:42:07 -07:00
parent b00c89c22f
commit 686a0ed964
2 changed files with 17 additions and 18 deletions

View File

@ -6,9 +6,8 @@
//! //!
//! ## Extracting Configuration Parameters //! ## Extracting Configuration Parameters
//! //!
//! Rocket exposes the active [`Figment`] via [`Rocket::figment()`] and //! Rocket exposes the active [`Figment`] via [`Rocket::figment()`]. Any value
//! [`Rocket::figment()`]. Any value that implements [`Deserialize`] can be //! that implements [`Deserialize`] can be extracted from the figment:
//! extracted from the figment:
//! //!
//! ```rust //! ```rust
//! use rocket::fairing::AdHoc; //! use rocket::fairing::AdHoc;

View File

@ -3,8 +3,8 @@ use rocket::{*, error::ErrorKind::SentinelAborts};
#[get("/two")] #[get("/two")]
fn two_states(_one: &State<u32>, _two: &State<String>) {} fn two_states(_one: &State<u32>, _two: &State<String>) {}
#[get("/one")] #[post("/one", data = "<s>")]
fn one_state(_three: &State<u8>) {} fn one_state<'r>(_three: &'r State<u8>, s: &'r str) -> &'r str { s }
#[async_test] #[async_test]
async fn state_sentinel_works() { async fn state_sentinel_works() {
@ -242,27 +242,27 @@ async fn known_macro_sentinel_works() {
use rocket::tokio::io::AsyncRead; use rocket::tokio::io::AsyncRead;
#[derive(Responder)] #[derive(Responder)]
struct TextSentinel(&'static str); struct TextSentinel<'r>(&'r str);
impl Sentinel for TextSentinel { impl Sentinel for TextSentinel<'_> {
fn abort(_: &Rocket<Ignite>) -> bool { fn abort(_: &Rocket<Ignite>) -> bool {
true true
} }
} }
impl AsRef<str> for TextSentinel { impl AsRef<str> for TextSentinel<'_> {
fn as_ref(&self) -> &str { fn as_ref(&self) -> &str {
self.0 self.0
} }
} }
impl AsRef<[u8]> for TextSentinel { impl AsRef<[u8]> for TextSentinel<'_> {
fn as_ref(&self) -> &[u8] { fn as_ref(&self) -> &[u8] {
self.0.as_bytes() self.0.as_bytes()
} }
} }
impl AsyncRead for TextSentinel { impl AsyncRead for TextSentinel<'_> {
fn poll_read( fn poll_read(
self: std::pin::Pin<&mut Self>, self: std::pin::Pin<&mut Self>,
_: &mut futures::task::Context<'_>, _: &mut futures::task::Context<'_>,
@ -273,18 +273,18 @@ async fn known_macro_sentinel_works() {
} }
#[get("/text")] #[get("/text")]
fn text() -> TextStream![TextSentinel] { fn text<'r>() -> TextStream![TextSentinel<'r>] {
TextStream!(yield TextSentinel("hi");) TextStream!(yield TextSentinel("hi");)
} }
#[get("/bytes")] #[get("/<a>")]
fn byte() -> ByteStream![TextSentinel] { fn byte(a: &str) -> ByteStream![TextSentinel<'_>] {
ByteStream!(yield TextSentinel("hi");) ByteStream!(yield TextSentinel(a);)
} }
#[get("/reader")] #[get("/<_a>/<b>")]
fn reader() -> ReaderStream![TextSentinel] { fn reader<'a, 'b>(_a: &'a str, b: &'b str) -> ReaderStream![TextSentinel<'b>] {
ReaderStream!(yield TextSentinel("hi");) ReaderStream!(yield TextSentinel(b);)
} }
macro_rules! UnknownStream { macro_rules! UnknownStream {
@ -292,7 +292,7 @@ async fn known_macro_sentinel_works() {
} }
#[get("/ignore")] #[get("/ignore")]
fn ignore() -> UnknownStream![TextSentinel] { fn ignore() -> UnknownStream![TextSentinel<'static>] {
ReaderStream!(yield TextSentinel("hi");) ReaderStream!(yield TextSentinel("hi");)
} }