diff --git a/ffi/README.md b/ffi/README.md index 93b6385bf..3538bd8f4 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -45,7 +45,7 @@ exclude = ["track::Producer::poll_closed"] # Another package exported into the same library, which the package builds with: its # own `exclude` and `rename`, by paths from its crate root. [crates.moq-pattern] -exclude = ["Patterns::iter"] +exclude = ["Pattern::new"] ``` ## Rules @@ -78,6 +78,7 @@ export's, and adds nothing; another crate's type is refused. | `url::Url` | an object `_url`, made by `_url_parse`, which fails with the parse error's message, and printed by `_to_string` | | `serde_json::Value` | an object `_json`, made by `_json_parse` from JSON text, which fails with serde_json's message, and read back by `_to_text`; its contents are the caller's JSON library's to read | | `Vec` and `&[T]` of any other `T` | `_vec_`: an array of `T`'s C values, viewed passed in and owned returned, a slice as a clone; of references only returned | +| a returned iterator, such as `slice::Iter` or an `impl Iterator`, that no other rule maps, outside a future, made of core's and alloc's iterators over a slice, string, `Option`, `Result`, or collection, through `rev`, `chain`, `flatten`, `fuse`, `enumerate`, `peekable`, `copied`, or `cloned`, with no closure, function, or trait object inside | what `collect::>()` makes of it: every item, taken at the call | | `Waker`, taken by value | `_waker`, as a future's poll takes it | | `Range`, `Bound` of an integer | `_range_`, `_bound_`: a `_bound` kind and a value | | `impl RangeBounds` of an integer | `_bounds_`: its start and end bounds | diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index 87c8f301a..6e233edab 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -397,6 +397,23 @@ fn main() { &["a".to_string(), "b".to_string()], ); println!("trail {:?} {:?}", trail.points(), trail.labels()); + // Returned iterators, each collected at the call: drained labels are gone after. + let mut trail = trail; + println!( + "iterated {:?} {:?} {:?}", + trail.iter().collect::>(), + trail.names().collect::>(), + trail.bytes().collect::>() + ); + println!( + "drained {:?} then {:?}", + trail.drain().collect::>(), + trail.labels() + ); + let numbered: Vec = api_lib::numbered(vec!["p".to_string(), "q".to_string()]) + .map(|c| format!("{} {}", c.name(), c.get())) + .collect(); + println!("numbered {}", numbered.join(", ")); let (v4, v6) = api_lib::nexts("127.0.0.1:8080".parse().unwrap(), "[::1%3]:443".parse().unwrap()); println!("nexts {} {} {} {}", v4.ip(), v4.port(), v6.port(), v6.scope_id()); } diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index 1f0fef4b1..b12eb69af 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -1096,6 +1096,7 @@ pub const GREETINGS: &[&str] = &["hi", "hello"]; pub struct Trail { points: Vec, labels: Vec