Skip to content

Commit

Permalink
Rename add_module to add_submodule, documentation fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebpuetz committed Sep 4, 2020
1 parent 795c054 commit 4aae523
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion guide/src/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn submodule(_py: Python, module: &PyModule) -> PyResult<()> {

#[pymodule]
fn supermodule(_py: Python, module: &PyModule) -> PyResult<()> {
module.add_module(wrap_pymodule!(submodule))?;
module.add_submodule(wrap_pymodule!(submodule))?;
Ok(())
}

Expand Down
10 changes: 5 additions & 5 deletions src/types/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl PyModule {
/// ```
///
/// **This function will be deprecated in the next release. Please use the specific
/// [add_function] and [add_module] functions instead.**
/// [add_function] and [add_submodule] functions instead.**
pub fn add_wrapped<'a, T>(&'a self, wrapper: &impl Fn(Python<'a>) -> T) -> PyResult<()>
where
T: IntoPyCallbackOutput<PyObject>,
Expand All @@ -207,20 +207,20 @@ impl PyModule {
self.add(name.extract(self.py())?, function)
}

/// Adds a (sub)module to a module.
/// Add a submodule to a module.
///
/// Use this together with `#[pymodule]` and [wrap_pymodule!].
///
/// ```rust,ignore
/// m.add_module(wrap_pymodule!(utils));
/// m.add_submodule(wrap_pymodule!(utils));
/// ```
pub fn add_module<'a>(&'a self, wrapper: &impl Fn(Python<'a>) -> PyObject) -> PyResult<()> {
pub fn add_submodule<'a>(&'a self, wrapper: &impl Fn(Python<'a>) -> PyObject) -> PyResult<()> {
let module = wrapper(self.py());
let name = module.getattr(self.py(), "__name__")?;
self.add(name.extract(self.py())?, module)
}

/// Adds a function to a module, using the functions __name__ as name.
/// Add a function to a module.
///
/// Use this together with the`#[pyfunction]` and [wrap_pyfunction!].
///
Expand Down

0 comments on commit 4aae523

Please sign in to comment.