File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 19
19
//! comments ``/// something`` (as well as other meta attrbiutes) on variants
20
20
//! are allowed.
21
21
//!
22
+ //! # Allowed Syntax
23
+ //!
22
24
//! You may add arbitrary parameters to any struct variant:
23
25
//!
24
26
//! ```rust
200
202
//! }
201
203
//! }
202
204
//! ```
205
+ //! # Context
203
206
//!
204
207
//! Since quick-error 1.1 we also have a `context` declaration, which is
205
208
//! similar to (the longest form of) `from`, but allows adding some context to
258
261
//! Docstrings are also okay. Empty braces can be omitted as of quick_error
259
262
//! 0.1.3.
260
263
//!
264
+ //! # Private Enums
265
+ //!
266
+ //! Since quick-error 1.2.0 we have a way to make a private enum that is
267
+ //! wrapped by public structure:
268
+ //!
269
+ //! ```rust
270
+ //! #[macro_use] extern crate quick_error;
271
+ //! # fn main() {}
272
+ //!
273
+ //! quick_error! {
274
+ //! #[derive(Debug)]
275
+ //! pub enum PubError wraps ErrorEnum {
276
+ //! Variant1 {}
277
+ //! }
278
+ //! }
279
+ //! ```
280
+ //!
281
+ //! This generates data structures like this
282
+ //!
283
+ //! ```rust
284
+ //!
285
+ //! pub struct PubError(ErrorEnum);
286
+ //!
287
+ //! enum ErrorEnum {
288
+ //! Variant1,
289
+ //! }
290
+ //!
291
+ //! ```
292
+ //!
293
+ //! Which in turn allows you to export just `PubError` in your crate and keep
294
+ //! actual enumeration private to the crate. This is useful to keep backwards
295
+ //! compatibility for error types. Currently there is no shorcuts to define
296
+ //! error constructors for the inner type, but we consider adding some in
297
+ //! future versions.
298
+ //!
299
+ //! It's possible to declare internal enum as public too.
300
+ //!
261
301
//!
262
302
263
303
You can’t perform that action at this time.
0 commit comments