artichoke_backend/extn/core/enumerable/
mod.rs

1use std::ffi::CStr;
2
3use crate::extn::prelude::*;
4
5const ENUMERABLE_CSTR: &CStr = c"Enumerable";
6static ENUMERABLE_RUBY_SOURCE: &[u8] = include_bytes!("enumerable.rb");
7
8pub fn init(interp: &mut Artichoke) -> InitializeResult<()> {
9    if interp.is_module_defined::<Enumerable>() {
10        return Ok(());
11    }
12
13    let spec = module::Spec::new(interp, "Enumerable", ENUMERABLE_CSTR, None)?;
14    module::Builder::for_spec(interp, &spec).define()?;
15    interp.def_module::<Enumerable>(spec)?;
16    interp.eval(ENUMERABLE_RUBY_SOURCE)?;
17
18    Ok(())
19}
20
21#[derive(Debug, Clone, Copy)]
22pub struct Enumerable;