tokio-rs / tokio

A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
https://tokio.rs
MIT License
26.59k stars 2.45k forks source link

codec: docs: fix length_delimited doc description and make examples testable #6638

Closed name1e5s closed 3 months ago

name1e5s commented 3 months ago

Motivation

According to comment in #6604, some examples for length_delimited do not fit the real behavior. This PR fix the document and add tests to the examples.

Close #6604

Solution

Fix the docs.

Swap the order of example 1 and 2 to make it more easier to understand.