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 1919//! comments ``/// something`` (as well as other meta attrbiutes) on variants
2020//! are allowed.
2121//!
22+ //! # Allowed Syntax
23+ //!
2224//! You may add arbitrary parameters to any struct variant:
2325//!
2426//! ```rust
200202//! }
201203//! }
202204//! ```
205+ //! # Context
203206//!
204207//! Since quick-error 1.1 we also have a `context` declaration, which is
205208//! similar to (the longest form of) `from`, but allows adding some context to
258261//! Docstrings are also okay. Empty braces can be omitted as of quick_error
259262//! 0.1.3.
260263//!
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+ //!
261301//!
262302
263303
You can’t perform that action at this time.
0 commit comments