Skip to content

Commit db10f0a

Browse files
committed
fix doc tests
includes a workaround for rust-lang/rust#41401
1 parent e136b7e commit db10f0a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

derive_builder/src/lib.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//! ## What you write
1313
//!
1414
//! ```rust
15+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
1516
//! #[macro_use]
1617
//! extern crate derive_builder;
1718
//!
@@ -25,7 +26,10 @@
2526
//!
2627
//! ## What you get
2728
//!
29+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
30+
//!
2831
//! ```rust
32+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
2933
//! # #[macro_use]
3034
//! # extern crate derive_builder;
3135
//! #
@@ -71,7 +75,10 @@
7175
//!
7276
//! Let's look again at the example above. You can now build structs like this:
7377
//!
78+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
79+
//!
7480
//! ```rust
81+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
7582
//! # #[macro_use] extern crate derive_builder;
7683
//! # #[derive(Builder)] struct Lorem { ipsum: u32 }
7784
//! # fn try_main() -> Result<(), String> {
@@ -84,7 +91,10 @@
8491
//!
8592
//! So let's make this call conditional
8693
//!
94+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
95+
//!
8796
//! ```rust
97+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
8898
//! # #[macro_use] extern crate derive_builder;
8999
//! # #[derive(Builder)] struct Lorem { ipsum: u32 }
90100
//! # fn try_main() -> Result<(), String> {
@@ -157,7 +167,10 @@
157167
//!
158168
//! The types of skipped fields must implement `Default`.
159169
//!
170+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
171+
//!
160172
//! ```rust
173+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
161174
//! # #[macro_use]
162175
//! # extern crate derive_builder;
163176
//! #
@@ -200,7 +213,10 @@
200213
//! You can make each setter generic over the `Into`-trait. It's as simple as adding
201214
//! `#[builder(setter(into))]` to either a field or the whole struct.
202215
//!
216+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
217+
//!
203218
//! ```rust
219+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
204220
//! # #[macro_use]
205221
//! # extern crate derive_builder;
206222
//! #
@@ -231,7 +247,10 @@
231247
//! You can only declare the `try_setter` attribute today if you're targeting nightly, and you have
232248
//! to add `#![feature(try_from)]` to your crate to use it.
233249
//!
250+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
251+
//!
234252
//! ```rust
253+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
235254
//! // #![feature(try_from)]
236255
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
237256
//! # #[cfg(feature = "nightlytests")]
@@ -279,7 +298,10 @@
279298
//!
280299
//! The expression will be evaluated with each call to `build`.
281300
//!
301+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
302+
//!
282303
//! ```rust
304+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
283305
//! # #[macro_use]
284306
//! # extern crate derive_builder;
285307
//! #
@@ -310,7 +332,10 @@
310332
//!
311333
//! [`Default`]: https://doc.rust-lang.org/std/default/trait.Default.html
312334
//!
335+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
336+
//!
313337
//! ```rust
338+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
314339
//! # #[macro_use]
315340
//! # extern crate derive_builder;
316341
//! #
@@ -351,7 +376,10 @@
351376
//!
352377
//! ## Generic Structs
353378
//!
379+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
380+
//!
354381
//! ```rust
382+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
355383
//! # #[macro_use]
356384
//! # extern crate derive_builder;
357385
//! #
@@ -380,7 +408,10 @@
380408
//! The whitelisting minimizes interference with other custom attributes like
381409
//! those used by Serde, Diesel, or others.
382410
//!
411+
//! <!-- this comment is a workaround for https://github.com/rust-lang/rust/issues/41401 -->
412+
//!
383413
//! ```rust
414+
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
384415
//! # #[macro_use]
385416
//! # extern crate derive_builder;
386417
//! #

0 commit comments

Comments
 (0)