Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7f969ec

Browse files
committedAug 21, 2024··
Fix doc-test by adding dyn_templates fake
1 parent a49e11d commit 7f969ec

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed
 

‎core/lib/src/rocket.rs

+20-6
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,20 @@ impl Rocket<Build> {
493493
///
494494
/// ```rust,no_run
495495
/// # #[macro_use] extern crate rocket;
496-
/// # extern crate rocket_dyn_templates;
496+
/// # fn some_function() {}
497+
/// # mod rocket_dyn_templates {
498+
/// # use rocket::fairing::{Fairing, Info, Kind};
499+
/// # #[derive(Default)]
500+
/// # pub struct Templates;
501+
/// # impl Fairing for Templates {
502+
/// # fn info(&self) -> Info {
503+
/// # Info { name: "", kind: Kind::Ignite }
504+
/// # }
505+
/// # }
506+
/// # impl Templates {
507+
/// # pub fn register_function(&mut self, _name: &str, _f: impl Fn()) {}
508+
/// # }
509+
/// # }
497510
/// use rocket::Rocket;
498511
/// use rocket::fairing::AdHoc;
499512
/// use rocket_dyn_templates::Templates;
@@ -502,11 +515,12 @@ impl Rocket<Build> {
502515
/// fn rocket() -> _ {
503516
/// rocket::build()
504517
/// .attach(Templates::default())
505-
/// .attach(AdHoc::on_ignite("Register new template function", |r| {
506-
/// r.modify_fairing(|f: &mut Templates| {
507-
/// f.register_function("some_function", some_function)
508-
/// })
509-
/// })))
518+
/// .attach(AdHoc::on_ignite("Register new template function", |r| async move {
519+
/// r.modify_fairings(|f: &mut Templates| {
520+
/// f.register_function("some_function", some_function);
521+
/// Ok::<(), ()>(())
522+
/// }).unwrap()
523+
/// }))
510524
/// }
511525
/// ```
512526
///

0 commit comments

Comments
 (0)
Please sign in to comment.