rust/hg-pyo3/src/lib.rs
changeset 52407 c5128c541021
parent 52403 b61c259c5457
child 52408 20c0472b2ab7
equal deleted inserted replaced
52406:c28ba6fb3fae 52407:c5128c541021
     1 use pyo3::prelude::*;
     1 use pyo3::prelude::*;
     2 
     2 
       
     3 mod dagops;
       
     4 mod util;
       
     5 
     3 #[pymodule]
     6 #[pymodule]
     4 fn pyo3_rustext(_py: Python<'_>, _m: &Bound<'_, PyModule>) -> PyResult<()> {
     7 fn pyo3_rustext(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
       
     8     m.add(
       
     9         "__doc__",
       
    10         "Mercurial core concepts - Rust implementation exposed via PyO3",
       
    11     )?;
       
    12     // the module's __name__ is pyo3_rustext, not mercurial.pyo3_rustext
       
    13     // (at least at this point).
       
    14     let name: String = m.getattr("__name__")?.extract()?;
       
    15     let dotted_name = format!("mercurial.{}", name);
       
    16 
       
    17     m.add_submodule(&dagops::init_module(py, &dotted_name)?)?;
     5     Ok(())
    18     Ok(())
     6 }
    19 }