Skip to content

Commit c5fe83a

Browse files
committed
fixes "doctest"
1 parent 1c4c381 commit c5fe83a

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

rustler/src/schedule.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,24 @@ where
6969
/// NOTE: can only be used when the `static ref EXTERN_NIF_MAP` created by `rustler_export_nifs!` macro is in scope.
7070
///
7171
/// ## Example:
72-
/// ```
73-
/// rustler_export_nifs!(
74-
/// "Elixir.RustlerTest",
75-
/// ("factorial", 2, test_schedule::factorial),
76-
/// None,
77-
/// )
72+
/// ```rust,no_run
73+
/// mod nif {
74+
/// use rustler::{Decoder, Env, Term, NifResult, rustler_export_nifs, schedule_nif, schedule::NifScheduleResult};
75+
/// rustler_export_nifs!(
76+
/// "Elixir.RustlerTest",
77+
/// [("factorial", 2, factorial)],
78+
/// None
79+
/// );
7880
///
79-
/// pub fn factorial<'a>(_env: Env<'a>, args: &[Term<'a>]) -> NifResult<NifScheduleResult<u32>> {
80-
/// let input: u32 = args[0].decode()?;
81-
/// let result: u32 = args[1].decode::<Option<u32>>()?.unwrap_or(1);
82-
/// if input == 0 {
83-
/// return Ok(result.into());
84-
/// }
81+
/// pub fn factorial<'a>(_env: Env<'a>, args: &[Term<'a>]) -> NifResult<NifScheduleResult<u32>> {
82+
/// let input: u32 = args[0].decode()?;
83+
/// let result: u32 = args[1].decode::<Option<u32>>()?.unwrap_or(1);
84+
/// if input == 0 {
85+
/// return Ok(result.into());
86+
/// }
8587
86-
/// return schedule_nif!("factorial", vec![input - 1, result * input]);
88+
/// return schedule_nif!("factorial", vec![input - 1, result * input]);
89+
/// }
8790
/// }
8891
/// ```
8992
#[macro_export]

0 commit comments

Comments
 (0)