Skip to content

Commit 25753a5

Browse files
author
Andrew J Westlake
committed
Changed signature of with_runtime to pass a return value instead of restricting it to ()
1 parent 0984311 commit 25753a5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,17 @@ static CREATE_FUTURE: OnceCell<PyObject> = OnceCell::new();
134134
/// })
135135
/// }
136136
/// ```
137-
pub fn with_runtime<F>(py: Python, f: F) -> PyResult<()>
137+
pub fn with_runtime<F, R>(py: Python, f: F) -> PyResult<R>
138138
where
139-
F: FnOnce() -> PyResult<()>,
139+
F: FnOnce() -> PyResult<R>,
140140
{
141141
try_init(py)?;
142142

143-
(f)()?;
143+
let result = (f)()?;
144144

145145
try_close(py)?;
146146

147-
Ok(())
147+
Ok(result)
148148
}
149149

150150
/// Attempt to initialize the Python and Rust event loops

0 commit comments

Comments
 (0)