Skip to content

Commit

Permalink
fixes "doctest"
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny-g committed Aug 24, 2019
1 parent 1c4c381 commit c5fe83a
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions rustler/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,24 @@ where
/// NOTE: can only be used when the `static ref EXTERN_NIF_MAP` created by `rustler_export_nifs!` macro is in scope.
///
/// ## Example:
/// ```
/// rustler_export_nifs!(
/// "Elixir.RustlerTest",
/// ("factorial", 2, test_schedule::factorial),
/// None,
/// )
/// ```rust,no_run
/// mod nif {
/// use rustler::{Decoder, Env, Term, NifResult, rustler_export_nifs, schedule_nif, schedule::NifScheduleResult};
/// rustler_export_nifs!(
/// "Elixir.RustlerTest",
/// [("factorial", 2, factorial)],
/// None
/// );
///
/// pub fn factorial<'a>(_env: Env<'a>, args: &[Term<'a>]) -> NifResult<NifScheduleResult<u32>> {
/// let input: u32 = args[0].decode()?;
/// let result: u32 = args[1].decode::<Option<u32>>()?.unwrap_or(1);
/// if input == 0 {
/// return Ok(result.into());
/// }
/// pub fn factorial<'a>(_env: Env<'a>, args: &[Term<'a>]) -> NifResult<NifScheduleResult<u32>> {
/// let input: u32 = args[0].decode()?;
/// let result: u32 = args[1].decode::<Option<u32>>()?.unwrap_or(1);
/// if input == 0 {
/// return Ok(result.into());
/// }

/// return schedule_nif!("factorial", vec![input - 1, result * input]);
/// return schedule_nif!("factorial", vec![input - 1, result * input]);
/// }
/// }
/// ```
#[macro_export]
Expand Down

0 comments on commit c5fe83a

Please sign in to comment.