Skip to content

Commit 4704be0

Browse files
committed
Fix doctests failing on Rust 1.25.0
Turns out there was an issue with doctest imports that was fixed in 1.26: rust-lang/rust#48106 Signed-off-by: Eliza Weisman <[email protected]>
1 parent 09258b2 commit 4704be0

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

src/length_delimited.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ impl Builder {
583583
/// .num_skip(0)
584584
/// .new_read(io);
585585
/// # }
586+
/// # pub fn main() {}
586587
/// ```
587588
pub fn new() -> Builder {
588589
Builder {
@@ -624,6 +625,7 @@ impl Builder {
624625
/// .big_endian()
625626
/// .new_read(io);
626627
/// # }
628+
/// # pub fn main() {}
627629
/// ```
628630
pub fn big_endian(&mut self) -> &mut Self {
629631
self.length_field_is_big_endian = true;
@@ -648,6 +650,7 @@ impl Builder {
648650
/// .little_endian()
649651
/// .new_read(io);
650652
/// # }
653+
/// # pub fn main() {}
651654
/// ```
652655
pub fn little_endian(&mut self) -> &mut Self {
653656
self.length_field_is_big_endian = false;
@@ -672,6 +675,7 @@ impl Builder {
672675
/// .native_endian()
673676
/// .new_read(io);
674677
/// # }
678+
/// # pub fn main() {}
675679
/// ```
676680
pub fn native_endian(&mut self) -> &mut Self {
677681
if cfg!(target_endian = "big") {
@@ -706,6 +710,7 @@ impl Builder {
706710
/// .max_frame_length(8 * 1024)
707711
/// .new_read(io);
708712
/// # }
713+
/// # pub fn main() {}
709714
/// ```
710715
pub fn max_frame_length(&mut self, val: usize) -> &mut Self {
711716
self.max_frame_len = val;
@@ -730,6 +735,7 @@ impl Builder {
730735
/// .length_field_length(4)
731736
/// .new_read(io);
732737
/// # }
738+
/// # pub fn main() {}
733739
/// ```
734740
pub fn length_field_length(&mut self, val: usize) -> &mut Self {
735741
assert!(val > 0 && val <= 8, "invalid length field length");
@@ -753,6 +759,7 @@ impl Builder {
753759
/// .length_field_offset(1)
754760
/// .new_read(io);
755761
/// # }
762+
/// # pub fn main() {}
756763
/// ```
757764
pub fn length_field_offset(&mut self, val: usize) -> &mut Self {
758765
self.length_field_offset = val;
@@ -774,6 +781,7 @@ impl Builder {
774781
/// .length_adjustment(-2)
775782
/// .new_read(io);
776783
/// # }
784+
/// # pub fn main() {}
777785
/// ```
778786
pub fn length_adjustment(&mut self, val: isize) -> &mut Self {
779787
self.length_adjustment = val;
@@ -798,6 +806,7 @@ impl Builder {
798806
/// .num_skip(4)
799807
/// .new_read(io);
800808
/// # }
809+
/// # pub fn main() {}
801810
/// ```
802811
pub fn num_skip(&mut self, val: usize) -> &mut Self {
803812
self.num_skip = Some(val);
@@ -821,6 +830,7 @@ impl Builder {
821830
/// .num_skip(0)
822831
/// .new_read(io);
823832
/// # }
833+
/// # pub fn main() {}
824834
/// ```
825835
pub fn new_read<T>(&self, upstream: T) -> FramedRead<T>
826836
where T: AsyncRead,

src/lib.rs

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,16 @@ pub mod codec {
140140
//! configuration values.
141141
//!
142142
//! ```
143-
//! # extern crate tokio_io;
144-
//! use tokio_io::{AsyncRead, AsyncWrite};
145-
//! use tokio_io::codec::length_delimited;
143+
//! # extern crate tokio;
144+
//! use tokio::io::{AsyncRead, AsyncWrite};
145+
//! use tokio::codec::length_delimited;
146146
//!
147147
//! fn bind_transport<T: AsyncRead + AsyncWrite>(io: T)
148148
//! -> length_delimited::Framed<T>
149149
//! {
150150
//! length_delimited::Framed::new(io)
151151
//! }
152+
//! # pub fn main() {}
152153
//! ```
153154
//!
154155
//! The returned transport implements `Sink + Stream` for `BytesMut`. It
@@ -164,12 +165,12 @@ pub mod codec {
164165
//! Specifically, given the following:
165166
//!
166167
//! ```
167-
//! # extern crate tokio_io;
168+
//! # extern crate tokio;
168169
//! # extern crate bytes;
169170
//! # extern crate futures;
170171
//! #
171-
//! use tokio_io::{AsyncRead, AsyncWrite};
172-
//! use tokio_io::codec::length_delimited;
172+
//! use tokio::io::{AsyncRead, AsyncWrite};
173+
//! use tokio::codec::length_delimited;
173174
//! use bytes::BytesMut;
174175
//! use futures::{Sink, Future};
175176
//!
@@ -205,9 +206,9 @@ pub mod codec {
205206
//! frame head in the yielded `BytesMut`.
206207
//!
207208
//! ```
208-
//! # extern crate tokio_io;
209-
//! # use tokio_io::AsyncRead;
210-
//! # use tokio_io::codec::length_delimited;
209+
//! # extern crate tokio;
210+
//! # use tokio::io::AsyncRead;
211+
//! # use tokio::codec::length_delimited;
211212
//! # fn bind_read<T: AsyncRead>(io: T) {
212213
//! length_delimited::Builder::new()
213214
//! .length_field_offset(0) // default value
@@ -216,6 +217,7 @@ pub mod codec {
216217
//! .num_skip(0) // Do not strip frame header
217218
//! .new_read(io);
218219
//! # }
220+
//! # pub fn main() {}
219221
//! ```
220222
//!
221223
//! The following frame will be decoded as such:
@@ -239,9 +241,9 @@ pub mod codec {
239241
//! frame head in the yielded `BytesMut`.
240242
//!
241243
//! ```
242-
//! # extern crate tokio_io;
243-
//! # use tokio_io::AsyncRead;
244-
//! # use tokio_io::codec::length_delimited;
244+
//! # extern crate tokio;
245+
//! # use tokio::io::AsyncRead;
246+
//! # use tokio::codec::length_delimited;
245247
//! # fn bind_read<T: AsyncRead>(io: T) {
246248
//! length_delimited::Builder::new()
247249
//! .length_field_offset(0) // default value
@@ -250,6 +252,7 @@ pub mod codec {
250252
//! // `num_skip` is not needed, the default is to skip
251253
//! .new_read(io);
252254
//! # }
255+
//! # pub fn main() {}
253256
//! ```
254257
//!
255258
//! The following frame will be decoded as such:
@@ -271,9 +274,9 @@ pub mod codec {
271274
//! **includes** the frame head length.
272275
//!
273276
//! ```
274-
//! # extern crate tokio_io;
275-
//! # use tokio_io::AsyncRead;
276-
//! # use tokio_io::codec::length_delimited;
277+
//! # extern crate tokio;
278+
//! # use tokio::io::AsyncRead;
279+
//! # use tokio::codec::length_delimited;
277280
//! # fn bind_read<T: AsyncRead>(io: T) {
278281
//! length_delimited::Builder::new()
279282
//! .length_field_offset(0) // default value
@@ -282,6 +285,7 @@ pub mod codec {
282285
//! .num_skip(0)
283286
//! .new_read(io);
284287
//! # }
288+
//! # pub fn main() {}
285289
//! ```
286290
//!
287291
//! The following frame will be decoded as such:
@@ -305,9 +309,9 @@ pub mod codec {
305309
//! frame head, including the frame head in the yielded `BytesMut`.
306310
//!
307311
//! ```
308-
//! # extern crate tokio_io;
309-
//! # use tokio_io::AsyncRead;
310-
//! # use tokio_io::codec::length_delimited;
312+
//! # extern crate tokio;
313+
//! # use tokio::io::AsyncRead;
314+
//! # use tokio::codec::length_delimited;
311315
//! # fn bind_read<T: AsyncRead>(io: T) {
312316
//! length_delimited::Builder::new()
313317
//! .length_field_offset(0) // default value
@@ -316,6 +320,7 @@ pub mod codec {
316320
//! .num_skip(0)
317321
//! .new_read(io);
318322
//! # }
323+
//! # pub fn main() {}
319324
//! ```
320325
//!
321326
//! The following frame will be decoded as such:
@@ -349,9 +354,9 @@ pub mod codec {
349354
//! included.
350355
//!
351356
//! ```
352-
//! # extern crate tokio_io;
353-
//! # use tokio_io::AsyncRead;
354-
//! # use tokio_io::codec::length_delimited;
357+
//! # extern crate tokio;
358+
//! # use tokio::io::AsyncRead;
359+
//! # use tokio::codec::length_delimited;
355360
//! # fn bind_read<T: AsyncRead>(io: T) {
356361
//! length_delimited::Builder::new()
357362
//! .length_field_offset(1) // length of hdr1
@@ -360,6 +365,7 @@ pub mod codec {
360365
//! .num_skip(3) // length of hdr1 + LEN
361366
//! .new_read(io);
362367
//! # }
368+
//! # pub fn main() {}
363369
//! ```
364370
//!
365371
//! The following frame will be decoded as such:
@@ -395,9 +401,9 @@ pub mod codec {
395401
//! length.
396402
//!
397403
//! ```
398-
//! # extern crate tokio_io;
399-
//! # use tokio_io::AsyncRead;
400-
//! # use tokio_io::codec::length_delimited;
404+
//! # extern crate tokio;
405+
//! # use tokio::io::AsyncRead;
406+
//! # use tokio::codec::length_delimited;
401407
//! # fn bind_read<T: AsyncRead>(io: T) {
402408
//! length_delimited::Builder::new()
403409
//! .length_field_offset(1) // length of hdr1
@@ -406,6 +412,7 @@ pub mod codec {
406412
//! .num_skip(3)
407413
//! .new_read(io);
408414
//! # }
415+
//! # pub fn main() {}
409416
//! ```
410417
//!
411418
//! The following frame will be decoded as such:
@@ -441,10 +448,10 @@ pub mod codec {
441448
//! configuration:
442449
//!
443450
//! ```
444-
//! # extern crate tokio_io;
451+
//! # extern crate tokio;
445452
//! # extern crate bytes;
446-
//! # use tokio_io::AsyncWrite;
447-
//! # use tokio_io::codec::length_delimited;
453+
//! # use tokio::io::AsyncWrite;
454+
//! # use tokio::codec::length_delimited;
448455
//! # use bytes::BytesMut;
449456
//! # fn write_frame<T: AsyncWrite>(io: T) {
450457
//! # let _: length_delimited::FramedWrite<T, BytesMut> =

0 commit comments

Comments
 (0)