1#![cfg_attr(
36 all(
37 feature = "add",
38 feature = "display",
39 feature = "from",
40 feature = "into"
41 ),
42 doc = include_str!("../README.md")
43)]
44#![cfg_attr(not(feature = "std"), no_std)]
45#![cfg_attr(docsrs, feature(doc_auto_cfg))]
46#![cfg_attr(any(not(docsrs), ci), deny(rustdoc::all))]
47#![forbid(non_ascii_idents, unsafe_code)]
48#![warn(clippy::nonstandard_macro_braces)]
49
50#[doc(hidden)]
54pub use core;
55
56#[doc(hidden)]
58pub mod __private {
59 #[cfg(feature = "as_ref")]
60 pub use crate::r#as::{Conv, ExtractRef};
61
62 #[cfg(feature = "debug")]
63 pub use crate::fmt::{debug_tuple, DebugTuple};
64
65 #[cfg(feature = "error")]
66 pub use crate::vendor::thiserror::aserror::AsDynError;
67}
68
69#[cfg(feature = "add")]
72mod add;
73#[cfg(feature = "add")]
74pub use crate::add::{BinaryError, WrongVariantError};
75
76#[cfg(any(feature = "add", feature = "not"))]
77mod ops;
78#[cfg(any(feature = "add", feature = "not"))]
79pub use crate::ops::UnitError;
80
81#[cfg(feature = "as_ref")]
82mod r#as;
83
84#[cfg(feature = "debug")]
85mod fmt;
86
87#[cfg(feature = "error")]
88mod vendor;
89
90#[cfg(feature = "from_str")]
91mod r#str;
92#[cfg(feature = "from_str")]
93#[doc(inline)]
94pub use crate::r#str::FromStrError;
95
96#[cfg(any(feature = "try_into", feature = "try_from"))]
97mod convert;
98#[cfg(feature = "try_from")]
99#[doc(inline)]
100pub use crate::convert::TryFromReprError;
101#[cfg(feature = "try_into")]
102#[doc(inline)]
103pub use crate::convert::TryIntoError;
104
105#[cfg(feature = "try_unwrap")]
106mod try_unwrap;
107#[cfg(feature = "try_unwrap")]
108#[doc(inline)]
109pub use crate::try_unwrap::TryUnwrapError;
110
111#[allow(unused_imports)]
114#[doc(inline)]
115pub use derive_more_impl::*;
116
117pub mod derive {
121 #[allow(unused_imports)]
124 #[doc(inline)]
125 pub use derive_more_impl::*;
126}
127
128pub mod with_trait {
132 macro_rules! re_export_traits((
143 $feature:literal, $new_module_name:ident, $module:path $(, $traits:ident)* $(,)?) => {
144 #[cfg(all(feature = $feature, any(not(docsrs), ci)))]
145 mod $new_module_name {
146 #[doc(hidden)]
147 pub use $module::{$($traits),*};
148 }
149
150 #[cfg(all(feature = $feature, any(not(docsrs), ci)))]
151 #[doc(hidden)]
152 pub use crate::with_trait::all_traits_and_derives::$new_module_name::*;
153 }
154 );
155
156 mod all_traits_and_derives {
157 re_export_traits!(
158 "add",
159 add_traits,
160 core::ops,
161 Add,
162 BitAnd,
163 BitOr,
164 BitXor,
165 Sub,
166 );
167 re_export_traits!(
168 "add_assign",
169 add_assign_traits,
170 core::ops,
171 AddAssign,
172 BitAndAssign,
173 BitOrAssign,
174 BitXorAssign,
175 SubAssign,
176 );
177 re_export_traits!("as_ref", as_ref_traits, core::convert, AsMut, AsRef);
178 re_export_traits!("debug", debug_traits, core::fmt, Debug);
179 re_export_traits!("deref", deref_traits, core::ops, Deref);
180 re_export_traits!("deref_mut", deref_mut_traits, core::ops, DerefMut);
181 re_export_traits!(
182 "display",
183 display_traits,
184 core::fmt,
185 Binary,
186 Display,
187 LowerExp,
188 LowerHex,
189 Octal,
190 Pointer,
191 UpperExp,
192 UpperHex,
193 );
194
195 #[cfg(not(feature = "std"))]
196 re_export_traits!("error", error_traits, core::error, Error);
197 #[cfg(feature = "std")]
198 re_export_traits!("error", error_traits, std::error, Error);
199
200 re_export_traits!("from", from_traits, core::convert, From);
201
202 re_export_traits!("from_str", from_str_traits, core::str, FromStr);
203
204 re_export_traits!("index", index_traits, core::ops, Index);
205
206 re_export_traits!("index_mut", index_mut_traits, core::ops, IndexMut);
207
208 re_export_traits!("into", into_traits, core::convert, Into);
209
210 re_export_traits!(
211 "into_iterator",
212 into_iterator_traits,
213 core::iter,
214 IntoIterator,
215 );
216
217 re_export_traits!("mul", mul_traits, core::ops, Div, Mul, Rem, Shl, Shr);
218
219 #[cfg(feature = "mul_assign")]
220 re_export_traits!(
221 "mul_assign",
222 mul_assign_traits,
223 core::ops,
224 DivAssign,
225 MulAssign,
226 RemAssign,
227 ShlAssign,
228 ShrAssign,
229 );
230
231 re_export_traits!("not", not_traits, core::ops, Neg, Not);
232
233 re_export_traits!("sum", sum_traits, core::iter, Product, Sum);
234
235 re_export_traits!("try_from", try_from_traits, core::convert, TryFrom);
236
237 re_export_traits!("try_into", try_into_traits, core::convert, TryInto);
238
239 #[cfg(feature = "add")]
242 pub use derive_more_impl::{Add, BitAnd, BitOr, BitXor, Sub};
243
244 #[cfg(feature = "add_assign")]
245 pub use derive_more_impl::{
246 AddAssign, BitAndAssign, BitOrAssign, BitXorAssign, SubAssign,
247 };
248
249 #[cfg(feature = "as_ref")]
250 pub use derive_more_impl::{AsMut, AsRef};
251
252 #[cfg(feature = "constructor")]
253 pub use derive_more_impl::Constructor;
254
255 #[cfg(feature = "debug")]
256 pub use derive_more_impl::Debug;
257
258 #[cfg(feature = "deref")]
259 pub use derive_more_impl::Deref;
260
261 #[cfg(feature = "deref_mut")]
262 pub use derive_more_impl::DerefMut;
263
264 #[cfg(feature = "display")]
265 pub use derive_more_impl::{
266 Binary, Display, LowerExp, LowerHex, Octal, Pointer, UpperExp, UpperHex,
267 };
268
269 #[cfg(feature = "error")]
270 pub use derive_more_impl::Error;
271
272 #[cfg(feature = "from")]
273 pub use derive_more_impl::From;
274
275 #[cfg(feature = "from_str")]
276 pub use derive_more_impl::FromStr;
277
278 #[cfg(feature = "index")]
279 pub use derive_more_impl::Index;
280
281 #[cfg(feature = "index_mut")]
282 pub use derive_more_impl::IndexMut;
283
284 #[cfg(feature = "into")]
285 pub use derive_more_impl::Into;
286
287 #[cfg(feature = "into_iterator")]
288 pub use derive_more_impl::IntoIterator;
289
290 #[cfg(feature = "is_variant")]
291 pub use derive_more_impl::IsVariant;
292
293 #[cfg(feature = "mul")]
294 pub use derive_more_impl::{Div, Mul, Rem, Shl, Shr};
295
296 #[cfg(feature = "mul_assign")]
297 pub use derive_more_impl::{
298 DivAssign, MulAssign, RemAssign, ShlAssign, ShrAssign,
299 };
300
301 #[cfg(feature = "not")]
302 pub use derive_more_impl::{Neg, Not};
303
304 #[cfg(feature = "sum")]
305 pub use derive_more_impl::{Product, Sum};
306
307 #[cfg(feature = "try_from")]
308 pub use derive_more_impl::TryFrom;
309
310 #[cfg(feature = "try_into")]
311 pub use derive_more_impl::TryInto;
312
313 #[cfg(feature = "try_unwrap")]
314 pub use derive_more_impl::TryUnwrap;
315
316 #[cfg(feature = "unwrap")]
317 pub use derive_more_impl::Unwrap;
318 }
319
320 #[cfg(feature = "add")]
326 #[doc(hidden)]
327 pub use all_traits_and_derives::{Add, BitAnd, BitOr, BitXor, Sub};
328
329 #[cfg(feature = "add_assign")]
330 #[doc(hidden)]
331 pub use all_traits_and_derives::{
332 AddAssign, BitAndAssign, BitOrAssign, BitXorAssign, SubAssign,
333 };
334
335 #[cfg(feature = "as_ref")]
336 #[doc(hidden)]
337 pub use all_traits_and_derives::{AsMut, AsRef};
338
339 #[cfg(feature = "constructor")]
340 #[doc(hidden)]
341 pub use all_traits_and_derives::Constructor;
342
343 #[cfg(feature = "debug")]
344 #[doc(hidden)]
345 pub use all_traits_and_derives::Debug;
346
347 #[cfg(feature = "deref")]
348 #[doc(hidden)]
349 pub use all_traits_and_derives::Deref;
350
351 #[cfg(feature = "deref_mut")]
352 #[doc(hidden)]
353 pub use all_traits_and_derives::DerefMut;
354
355 #[cfg(feature = "display")]
356 #[doc(hidden)]
357 pub use all_traits_and_derives::{
358 Binary, Display, LowerExp, LowerHex, Octal, Pointer, UpperExp, UpperHex,
359 };
360
361 #[cfg(feature = "error")]
362 #[doc(hidden)]
363 pub use all_traits_and_derives::Error;
364
365 #[cfg(feature = "from")]
366 #[doc(hidden)]
367 pub use all_traits_and_derives::From;
368
369 #[cfg(feature = "from_str")]
370 #[doc(hidden)]
371 pub use all_traits_and_derives::FromStr;
372
373 #[cfg(feature = "index")]
374 #[doc(hidden)]
375 pub use all_traits_and_derives::Index;
376
377 #[cfg(feature = "index_mut")]
378 #[doc(hidden)]
379 pub use all_traits_and_derives::IndexMut;
380
381 #[cfg(feature = "into")]
382 #[doc(hidden)]
383 pub use all_traits_and_derives::Into;
384
385 #[cfg(feature = "into_iterator")]
386 #[doc(hidden)]
387 pub use all_traits_and_derives::IntoIterator;
388
389 #[cfg(feature = "is_variant")]
390 #[doc(hidden)]
391 pub use all_traits_and_derives::IsVariant;
392
393 #[cfg(feature = "mul")]
394 #[doc(hidden)]
395 pub use all_traits_and_derives::{Div, Mul, Rem, Shl, Shr};
396
397 #[cfg(feature = "mul_assign")]
398 #[doc(hidden)]
399 pub use all_traits_and_derives::{
400 DivAssign, MulAssign, RemAssign, ShlAssign, ShrAssign,
401 };
402
403 #[cfg(feature = "not")]
404 #[doc(hidden)]
405 pub use all_traits_and_derives::{Neg, Not};
406
407 #[cfg(feature = "sum")]
408 #[doc(hidden)]
409 pub use all_traits_and_derives::{Product, Sum};
410
411 #[cfg(feature = "try_from")]
412 #[doc(hidden)]
413 pub use all_traits_and_derives::TryFrom;
414
415 #[cfg(feature = "try_into")]
416 #[doc(hidden)]
417 pub use all_traits_and_derives::TryInto;
418
419 #[cfg(feature = "try_unwrap")]
420 #[doc(hidden)]
421 pub use all_traits_and_derives::TryUnwrap;
422
423 #[cfg(feature = "unwrap")]
424 #[doc(hidden)]
425 pub use all_traits_and_derives::Unwrap;
426
427 #[allow(unused_imports)]
430 pub use derive_more_impl::*;
431}
432
433#[cfg(not(any(
435 feature = "full",
436 feature = "add",
437 feature = "add_assign",
438 feature = "as_ref",
439 feature = "constructor",
440 feature = "debug",
441 feature = "deref",
442 feature = "deref_mut",
443 feature = "display",
444 feature = "error",
445 feature = "from",
446 feature = "from_str",
447 feature = "index",
448 feature = "index_mut",
449 feature = "into",
450 feature = "into_iterator",
451 feature = "is_variant",
452 feature = "mul",
453 feature = "mul_assign",
454 feature = "not",
455 feature = "sum",
456 feature = "try_from",
457 feature = "try_into",
458 feature = "try_unwrap",
459 feature = "unwrap",
460)))]
461compile_error!(
462 "at least one derive feature must be enabled (or the \"full\" feature enabling all the derives)"
463);