Skip to content

Commit 72489bb

Browse files
committed
Update docstrings
1 parent ab65a06 commit 72489bb

File tree

4 files changed

+78
-64
lines changed

4 files changed

+78
-64
lines changed

src/async_std.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ where
485485
///
486486
/// ```
487487
/// use std::time::Duration;
488+
/// use std::ffi::CString;
488489
///
489490
/// use pyo3::prelude::*;
490491
///
@@ -498,11 +499,11 @@ where
498499
/// async fn py_sleep(seconds: f32) -> PyResult<()> {
499500
/// let test_mod = Python::with_gil(|py| -> PyResult<PyObject> {
500501
/// Ok(
501-
/// PyModule::from_code_bound(
502+
/// PyModule::from_code(
502503
/// py,
503-
/// PYTHON_CODE,
504-
/// "test_into_future/test_mod.py",
505-
/// "test_mod"
504+
/// &CString::new(PYTHON_CODE).unwrap(),
505+
/// &CString::new("test_into_future/test_mod.py").unwrap(),
506+
/// &CString::new("test_mod").unwrap()
506507
/// )?
507508
/// .into()
508509
/// )
@@ -552,11 +553,11 @@ pub fn into_future(
552553
/// # #[pyo3_async_runtimes::async_std::main]
553554
/// # async fn main() -> PyResult<()> {
554555
/// let stream = Python::with_gil(|py| {
555-
/// let test_mod = PyModule::from_code_bound(
556+
/// let test_mod = PyModule::from_code(
556557
/// py,
557-
/// TEST_MOD,
558-
/// "test_rust_coroutine/test_mod.py",
559-
/// "test_mod",
558+
/// &CString::new(TEST_MOD).unwrap(),
559+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
560+
/// &CString::new("test_mod").unwrap(),
560561
/// )?;
561562
///
562563
/// pyo3_async_runtimes::async_std::into_stream_v1(test_mod.call_method0("gen")?)
@@ -595,6 +596,7 @@ pub fn into_stream_v1(
595596
/// ```
596597
/// use pyo3::prelude::*;
597598
/// use futures::{StreamExt, TryStreamExt};
599+
/// use std::ffi::CString;
598600
///
599601
/// const TEST_MOD: &str = r#"
600602
/// import asyncio
@@ -609,11 +611,11 @@ pub fn into_stream_v1(
609611
/// # #[pyo3_async_runtimes::async_std::main]
610612
/// # async fn main() -> PyResult<()> {
611613
/// let stream = Python::with_gil(|py| {
612-
/// let test_mod = PyModule::from_code_bound(
614+
/// let test_mod = PyModule::from_code(
613615
/// py,
614-
/// TEST_MOD,
615-
/// "test_rust_coroutine/test_mod.py",
616-
/// "test_mod",
616+
/// &CString::new(TEST_MOD).unwrap(),
617+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
618+
/// &CString::new("test_mod").unwrap(),
617619
/// )?;
618620
///
619621
/// pyo3_async_runtimes::async_std::into_stream_with_locals_v1(
@@ -656,6 +658,7 @@ pub fn into_stream_with_locals_v1(
656658
/// ```
657659
/// use pyo3::prelude::*;
658660
/// use futures::{StreamExt, TryStreamExt};
661+
/// use std::ffi::CString;
659662
///
660663
/// const TEST_MOD: &str = r#"
661664
/// import asyncio
@@ -670,11 +673,11 @@ pub fn into_stream_with_locals_v1(
670673
/// # #[pyo3_async_runtimes::async_std::main]
671674
/// # async fn main() -> PyResult<()> {
672675
/// let stream = Python::with_gil(|py| {
673-
/// let test_mod = PyModule::from_code_bound(
676+
/// let test_mod = PyModule::from_code(
674677
/// py,
675-
/// TEST_MOD,
676-
/// "test_rust_coroutine/test_mod.py",
677-
/// "test_mod",
678+
/// &CString::new(TEST_MOD).unwrap(),
679+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
680+
/// &CString::new("test_mod").unwrap(),
678681
/// )?;
679682
///
680683
/// pyo3_async_runtimes::async_std::into_stream_with_locals_v2(
@@ -716,6 +719,7 @@ pub fn into_stream_with_locals_v2(
716719
/// ```
717720
/// use pyo3::prelude::*;
718721
/// use futures::{StreamExt, TryStreamExt};
722+
/// use std::ffi::CString;
719723
///
720724
/// const TEST_MOD: &str = r#"
721725
/// import asyncio
@@ -730,11 +734,11 @@ pub fn into_stream_with_locals_v2(
730734
/// # #[pyo3_async_runtimes::async_std::main]
731735
/// # async fn main() -> PyResult<()> {
732736
/// let stream = Python::with_gil(|py| {
733-
/// let test_mod = PyModule::from_code_bound(
737+
/// let test_mod = PyModule::from_code(
734738
/// py,
735-
/// TEST_MOD,
736-
/// "test_rust_coroutine/test_mod.py",
737-
/// "test_mod",
739+
/// &CString::new(TEST_MOD).unwrap(),
740+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
741+
/// &CString::new("test_mod").unwrap(),
738742
/// )?;
739743
///
740744
/// pyo3_async_runtimes::async_std::into_stream_v2(test_mod.call_method0("gen")?)

src/generic.rs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ fn set_result(
372372
///
373373
/// ```no_run
374374
/// # use std::{any::Any, pin::Pin, future::Future, task::{Context, Poll}, time::Duration};
375+
/// # use std::ffi::CString;
375376
/// #
376377
/// # use pyo3::prelude::*;
377378
/// #
@@ -443,11 +444,11 @@ fn set_result(
443444
/// async fn py_sleep(seconds: f32) -> PyResult<()> {
444445
/// let test_mod = Python::with_gil(|py| -> PyResult<PyObject> {
445446
/// Ok(
446-
/// PyModule::from_code_bound(
447+
/// PyModule::from_code(
447448
/// py,
448-
/// PYTHON_CODE,
449-
/// "test_into_future/test_mod.py",
450-
/// "test_mod"
449+
/// &CString::new(PYTHON_CODE).unwrap(),
450+
/// &CString::new("test_into_future/test_mod.py").unwrap(),
451+
/// &CString::new("test_mod").unwrap(),
451452
/// )?
452453
/// .into()
453454
/// )
@@ -1266,6 +1267,7 @@ where
12661267
///
12671268
/// use pyo3::prelude::*;
12681269
/// use futures::{StreamExt, TryStreamExt};
1270+
/// use std::ffi::CString;
12691271
///
12701272
/// const TEST_MOD: &str = r#"
12711273
/// import asyncio
@@ -1278,11 +1280,11 @@ where
12781280
///
12791281
/// # async fn test_async_gen() -> PyResult<()> {
12801282
/// let stream = Python::with_gil(|py| {
1281-
/// let test_mod = PyModule::from_code_bound(
1283+
/// let test_mod = PyModule::from_code(
12821284
/// py,
1283-
/// TEST_MOD,
1284-
/// "test_rust_coroutine/test_mod.py",
1285-
/// "test_mod",
1285+
/// &CString::new(TEST_MOD).unwrap(),
1286+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
1287+
/// &CString::new("test_mod").unwrap(),
12861288
/// )?;
12871289
///
12881290
/// pyo3_async_runtimes::generic::into_stream_with_locals_v1::<MyCustomRuntime>(
@@ -1414,6 +1416,7 @@ where
14141416
///
14151417
/// use pyo3::prelude::*;
14161418
/// use futures::{StreamExt, TryStreamExt};
1419+
/// use std::ffi::CString;
14171420
///
14181421
/// const TEST_MOD: &str = r#"
14191422
/// import asyncio
@@ -1426,11 +1429,11 @@ where
14261429
///
14271430
/// # async fn test_async_gen() -> PyResult<()> {
14281431
/// let stream = Python::with_gil(|py| {
1429-
/// let test_mod = PyModule::from_code_bound(
1432+
/// let test_mod = PyModule::from_code(
14301433
/// py,
1431-
/// TEST_MOD,
1432-
/// "test_rust_coroutine/test_mod.py",
1433-
/// "test_mod",
1434+
/// &CString::new(TEST_MOD).unwrap(),
1435+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
1436+
/// &CString::new("test_mod").unwrap(),
14341437
/// )?;
14351438
///
14361439
/// pyo3_async_runtimes::generic::into_stream_v1::<MyCustomRuntime>(test_mod.call_method0("gen")?)
@@ -1622,6 +1625,7 @@ async def forward(gen, sender):
16221625
///
16231626
/// use pyo3::prelude::*;
16241627
/// use futures::{StreamExt, TryStreamExt};
1628+
/// use std::ffi::CString;
16251629
///
16261630
/// const TEST_MOD: &str = r#"
16271631
/// import asyncio
@@ -1634,11 +1638,11 @@ async def forward(gen, sender):
16341638
///
16351639
/// # async fn test_async_gen() -> PyResult<()> {
16361640
/// let stream = Python::with_gil(|py| {
1637-
/// let test_mod = PyModule::from_code_bound(
1641+
/// let test_mod = PyModule::from_code(
16381642
/// py,
1639-
/// TEST_MOD,
1640-
/// "test_rust_coroutine/test_mod.py",
1641-
/// "test_mod",
1643+
/// &CString::new(TEST_MOD).unwrap(),
1644+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
1645+
/// &CString::new("test_mod").unwrap(),
16421646
/// )?;
16431647
///
16441648
/// pyo3_async_runtimes::generic::into_stream_with_locals_v2::<MyCustomRuntime>(
@@ -1772,6 +1776,7 @@ where
17721776
///
17731777
/// use pyo3::prelude::*;
17741778
/// use futures::{StreamExt, TryStreamExt};
1779+
/// use std::ffi::CString;
17751780
///
17761781
/// const TEST_MOD: &str = r#"
17771782
/// import asyncio
@@ -1784,11 +1789,11 @@ where
17841789
///
17851790
/// # async fn test_async_gen() -> PyResult<()> {
17861791
/// let stream = Python::with_gil(|py| {
1787-
/// let test_mod = PyModule::from_code_bound(
1792+
/// let test_mod = PyModule::from_code(
17881793
/// py,
1789-
/// TEST_MOD,
1790-
/// "test_rust_coroutine/test_mod.py",
1791-
/// "test_mod",
1794+
/// &CString::new(TEST_MOD).unwrap(),
1795+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
1796+
/// &CString::new("test_mod").unwrap(),
17921797
/// )?;
17931798
///
17941799
/// pyo3_async_runtimes::generic::into_stream_v2::<MyCustomRuntime>(test_mod.call_method0("gen")?)

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,11 @@ fn call_soon_threadsafe<'py>(
619619
/// async fn py_sleep(seconds: f32) -> PyResult<()> {
620620
/// let test_mod = Python::with_gil(|py| -> PyResult<PyObject> {
621621
/// Ok(
622-
/// PyModule::from_code_bound(
622+
/// PyModule::from_code(
623623
/// py,
624-
/// PYTHON_CODE,
625-
/// "test_into_future/test_mod.py",
626-
/// "test_mod"
624+
/// &CString::new(PYTHON_CODE).unwrap(),
625+
/// &CString::new("test_into_future/test_mod.py").unwrap(),
626+
/// &CString::new("test_mod").unwrap(),
627627
/// )?
628628
/// .into()
629629
/// )

src/tokio.rs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ where
559559
///
560560
/// ```
561561
/// use std::time::Duration;
562+
/// use std::ffi::CString;
562563
///
563564
/// use pyo3::prelude::*;
564565
///
@@ -572,11 +573,11 @@ where
572573
/// async fn py_sleep(seconds: f32) -> PyResult<()> {
573574
/// let test_mod = Python::with_gil(|py| -> PyResult<PyObject> {
574575
/// Ok(
575-
/// PyModule::from_code_bound(
576+
/// PyModule::from_code(
576577
/// py,
577-
/// PYTHON_CODE,
578-
/// "test_into_future/test_mod.py",
579-
/// "test_mod"
578+
/// &CString::new(PYTHON_CODE).unwrap(),
579+
/// &CString::new("test_into_future/test_mod.py").unwrap(),
580+
/// &CString::new("test_mod").unwrap(),
580581
/// )?
581582
/// .into()
582583
/// )
@@ -613,6 +614,7 @@ pub fn into_future(
613614
/// ```
614615
/// use pyo3::prelude::*;
615616
/// use futures::{StreamExt, TryStreamExt};
617+
/// use std::ffi::CString;
616618
///
617619
/// const TEST_MOD: &str = r#"
618620
/// import asyncio
@@ -627,11 +629,11 @@ pub fn into_future(
627629
/// # #[pyo3_async_runtimes::tokio::main]
628630
/// # async fn main() -> PyResult<()> {
629631
/// let stream = Python::with_gil(|py| {
630-
/// let test_mod = PyModule::from_code_bound(
632+
/// let test_mod = PyModule::from_code(
631633
/// py,
632-
/// TEST_MOD,
633-
/// "test_rust_coroutine/test_mod.py",
634-
/// "test_mod",
634+
/// &CString::new(TEST_MOD).unwrap(),
635+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
636+
/// &CString::new("test_mod").unwrap(),
635637
/// )?;
636638
///
637639
/// pyo3_async_runtimes::tokio::into_stream_with_locals_v1(
@@ -673,6 +675,7 @@ pub fn into_stream_with_locals_v1(
673675
/// ```
674676
/// use pyo3::prelude::*;
675677
/// use futures::{StreamExt, TryStreamExt};
678+
/// use std::ffi::CString;
676679
///
677680
/// const TEST_MOD: &str = r#"
678681
/// import asyncio
@@ -687,11 +690,11 @@ pub fn into_stream_with_locals_v1(
687690
/// # #[pyo3_async_runtimes::tokio::main]
688691
/// # async fn main() -> PyResult<()> {
689692
/// let stream = Python::with_gil(|py| {
690-
/// let test_mod = PyModule::from_code_bound(
693+
/// let test_mod = PyModule::from_code(
691694
/// py,
692-
/// TEST_MOD,
693-
/// "test_rust_coroutine/test_mod.py",
694-
/// "test_mod",
695+
/// &CString::new(TEST_MOD).unwrap(),
696+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
697+
/// &CString::new("test_mod").unwrap(),
695698
/// )?;
696699
///
697700
/// pyo3_async_runtimes::tokio::into_stream_v1(test_mod.call_method0("gen")?)
@@ -730,6 +733,7 @@ pub fn into_stream_v1(
730733
/// ```
731734
/// use pyo3::prelude::*;
732735
/// use futures::{StreamExt, TryStreamExt};
736+
/// use std::ffi::CString;
733737
///
734738
/// const TEST_MOD: &str = r#"
735739
/// import asyncio
@@ -744,11 +748,11 @@ pub fn into_stream_v1(
744748
/// # #[pyo3_async_runtimes::tokio::main]
745749
/// # async fn main() -> PyResult<()> {
746750
/// let stream = Python::with_gil(|py| {
747-
/// let test_mod = PyModule::from_code_bound(
751+
/// let test_mod = PyModule::from_code(
748752
/// py,
749-
/// TEST_MOD,
750-
/// "test_rust_coroutine/test_mod.py",
751-
/// "test_mod",
753+
/// &CString::new(TEST_MOD).unwrap(),
754+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
755+
/// &CString::new("test_mod").unwrap(),
752756
/// )?;
753757
///
754758
/// pyo3_async_runtimes::tokio::into_stream_with_locals_v2(
@@ -790,6 +794,7 @@ pub fn into_stream_with_locals_v2(
790794
/// ```
791795
/// use pyo3::prelude::*;
792796
/// use futures::{StreamExt, TryStreamExt};
797+
/// use std::ffi::CString;
793798
///
794799
/// const TEST_MOD: &str = r#"
795800
/// import asyncio
@@ -804,11 +809,11 @@ pub fn into_stream_with_locals_v2(
804809
/// # #[pyo3_async_runtimes::tokio::main]
805810
/// # async fn main() -> PyResult<()> {
806811
/// let stream = Python::with_gil(|py| {
807-
/// let test_mod = PyModule::from_code_bound(
812+
/// let test_mod = PyModule::from_code(
808813
/// py,
809-
/// TEST_MOD,
810-
/// "test_rust_coroutine/test_mod.py",
811-
/// "test_mod",
814+
/// &CString::new(TEST_MOD).unwrap(),
815+
/// &CString::new("test_rust_coroutine/test_mod.py").unwrap(),
816+
/// &CString::new("test_mod").unwrap(),
812817
/// )?;
813818
///
814819
/// pyo3_async_runtimes::tokio::into_stream_v2(test_mod.call_method0("gen")?)

0 commit comments

Comments
 (0)