1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
// -*- mode:rust; coding:utf-8-unix; -*-

//! lib.rs

//  Copyright 2016 hanepjiv
//  @author hanepjiv <hanepjiv@gmail.com>
//  @copyright The MIT License (MIT) / Apache License Version 2.0
//  @since 2016/03/08
//  @date 2024/04/27

//!
//! # Examples
//!
//! ## Elicit
//!
//! ```
//! pub(crate) mod mine {
//!     use elicit::{elicit_define, Elicit};
//!
//!     #[elicit_define(mine_elicit)]
//!     pub(crate) trait Mine {
//!         fn action(&self) -> i32;
//!         fn action_mut(&mut self) -> i32;
//!     }
//!
//!     // pub(crate) mine_elicit::author as elicit_author;
//!     pub(crate) use mine_elicit::user as elicit_user;
//!
//!     #[derive(Debug, Default, Clone, Elicit)]
//!     #[elicit_mod_author(mine_elicit::author)]
//!     pub(crate) struct MineX {}
//!
//!     impl Mine for MineX {
//!         fn action(&self) -> i32 {
//!             0i32
//!         }
//!         fn action_mut(&mut self) -> i32 {
//!             0i32
//!         }
//!     }
//!
//!     #[derive(Debug, Clone, Elicit)]
//!     #[elicit_mod_author(mine_elicit::author)]
//!     // #[elicit_from_self_field(_fsf)] // here
//!     pub(crate) struct MineY {
//!         #[elicit_from_self_field] // or here
//!         _fsf: mine_elicit::author::ElicitFromSelfField,
//!         i: i32,
//!     }
//!
//!     impl MineY {
//!         pub(crate) fn new(a: i32) -> Self {
//!             MineY {
//!                 _fsf: Default::default(),
//!                 i: a,
//!             }
//!         }
//!         ///
//!         ///
//!         /// fn evil
//!         ///
//!         /// It is not possible to suppress calls to _weak_assign within
//!         /// the same module.
//!         ///
//!         #[allow(box_pointers, dead_code)]
//!         pub(crate) fn evil(&mut self) -> elicit::Result<()> {
//!             use mine_elicit::author::*;
//!             use std::{cell::RefCell, rc::Rc};
//!             self._weak_assign(Rc::<RefCell<Box<dyn ElicitBase>>>::downgrade(
//!                 &Rc::new(RefCell::new(Box::<MineX>::default())),
//!             ))
//!         }
//!     }
//!
//!     impl Mine for MineY {
//!         fn action(&self) -> i32 {
//!             self.i
//!         }
//!         fn action_mut(&mut self) -> i32 {
//!             self.i += 1;
//!             self.i
//!         }
//!     }
//! }
//!
//! pub(crate) fn fire() -> elicit::Result<()> {
//!     use mine::elicit_user::Elicit as MineElicit;
//!     use mine::{MineX, MineY};
//!
//!     let mut e: MineElicit;
//!
//!     e = MineElicit::new(MineX::default())?;
//!
//!     e.try_with(|m| -> elicit::Result<()> {
//!         println!("{:?}", m);
//!         assert!(m.action() == 0);
//!         Ok(())
//!     })?;
//!
//!     let y = MineY::new(1);
//!
//!     // eprintln!("{:?}", y.evil());
//!
//!     e = MineElicit::new(y)?;
//!
//!     e.try_with_mut(|m| -> elicit::Result<()> {
//!         println!("{:?}", m);
//!         assert!(m.action_mut() == 2);
//!         Ok(())
//!     })?;
//!
//!     Ok(())
//! }
//!
//! fire().expect("Doc-tests");
//! ```
//!

// ////////////////////////////////////////////////////////////////////////////
// attribute  =================================================================
/*
// rustc 1.77.2 (25ef9e3d8 2024-04-09)
#![forbid(
    absolute_paths_not_starting_with_crate,
    deprecated_in_future,
    elided_lifetimes_in_paths,
    explicit_outlives_requirements,
    ffi_unwind_calls,
    keyword_idents,
    let_underscore_drop,
    macro_use_extern_crate,
    meta_variable_misuse,
    missing_abi,
    missing_copy_implementations,
    missing_debug_implementations,
    missing_docs,
    non_ascii_idents,
    rust_2021_incompatible_closure_captures,
    rust_2021_incompatible_or_patterns,
    rust_2021_prefixes_incompatible_syntax,
    rust_2021_prelude_collisions,
    single_use_lifetimes,
    trivial_numeric_casts,
    unit_bindings,
    unsafe_code,
    unsafe_op_in_unsafe_fn,
    unstable_features,
    unused_crate_dependencies,
    unused_extern_crates,
    unused_import_braces,
    unused_lifetimes,
    unused_macro_rules,
    unused_qualifications,
    unused_results,
    variant_size_differences,
    ambiguous_glob_imports,
    ambiguous_glob_reexports,
    ambiguous_wide_pointer_comparisons,
    anonymous_parameters,
    array_into_iter,
    asm_sub_register,
    async_fn_in_trait,
    bad_asm_style,
    bare_trait_objects,
    break_with_label_and_loop,
    byte_slice_in_packed_struct_with_derive,
    clashing_extern_declarations,
    coherence_leak_check,
    confusable_idents,
    const_evaluatable_unchecked,
    const_eval_mutable_ptr_in_final_value,
    const_item_mutation,
    deprecated,
    deprecated_where_clause_location,
    deref_into_dyn_supertrait,
    deref_nullptr,
    dropping_copy_types,
    dropping_references,
    drop_bounds,
    duplicate_macro_attributes,
    dyn_drop,
    elided_lifetimes_in_associated_constant,
    ellipsis_inclusive_range_patterns,
    exported_private_dependencies,
    forbidden_lint_groups,
    forgetting_copy_types,
    forgetting_references,
    for_loops_over_fallibles,
    function_item_references,
    hidden_glob_reexports,
    improper_ctypes,
    improper_ctypes_definitions,
    incomplete_features,
    indirect_structural_match,
    inline_no_sanitize,
    internal_features,
    invalid_doc_attributes,
    invalid_from_utf8,
    invalid_macro_export_arguments,
    invalid_nan_comparisons,
    invalid_value,
    irrefutable_let_patterns,
    large_assignments,
    late_bound_lifetime_arguments,
    legacy_derive_helpers,
    map_unit_fn,
    mixed_script_confusables,
    named_arguments_used_positionally,
    non_camel_case_types,
    non_fmt_panics,
    non_shorthand_field_patterns,
    non_snake_case,
    non_upper_case_globals,
    noop_method_call,
    no_mangle_generic_items,
    opaque_hidden_inferred_bound,
    overlapping_range_endpoints,
    path_statements,
    pointer_structural_match,
    private_bounds,
    private_interfaces,
    redundant_semicolons,
    refining_impl_trait,
    renamed_and_removed_lints,
    repr_transparent_external_private_fields,
    semicolon_in_expressions_from_macros,
    special_module_name,
    stable_features,
    static_mut_refs,
    suspicious_double_ref_op,
    temporary_cstring_as_ptr,
    trivial_bounds,
    type_alias_bounds,
    tyvar_behind_raw_pointer,
    uncommon_codepoints,
    unconditional_recursion,
    undefined_naked_function_abi,
    unexpected_cfgs,
    ungated_async_fn_track_caller,
    uninhabited_static,
    unknown_lints,
    unnameable_test_items,
    unreachable_code,
    unreachable_patterns,
    unstable_name_collisions,
    unstable_syntax_pre_expansion,
    unsupported_calling_conventions,
    unused_allocation,
    unused_assignments,
    unused_associated_type_bounds,
    unused_attributes,
    unused_braces,
    unused_comparisons,
    unused_doc_comments,
    unused_features,
    unused_imports,
    unused_labels,
    unused_macros,
    unused_must_use,
    unused_mut,
    unused_parens,
    unused_unsafe,
    unused_variables,
    useless_ptr_null_checks,
    where_clauses_object_safety,
    while_true,
    writes_through_immutable_pointer,
    ambiguous_associated_items,
    arithmetic_overflow,
    bindings_with_variant_name,
    cenum_impl_drop_cast,
    conflicting_repr_hints,
    deprecated_cfg_attr_crate_type_name,
    enum_intrinsics_non_enums,
    ill_formed_attribute_input,
    incomplete_include,
    ineffective_unstable_trait_impl,
    invalid_atomic_ordering,
    invalid_from_utf8_unchecked,
    invalid_reference_casting,
    invalid_type_param_default,
    let_underscore_lock,
    long_running_const_eval,
    macro_expanded_macro_exports_accessed_by_absolute_paths,
    missing_fragment_specifier,
    mutable_transmutes,
    named_asm_labels,
    no_mangle_const_items,
    order_dependent_trait_objects,
    overflowing_literals,
    patterns_in_fns_without_body,
    proc_macro_back_compat,
    proc_macro_derive_resolution_fallback,
    pub_use_of_private_extern_crate,
    soft_unstable,
    text_direction_codepoint_in_comment,
    text_direction_codepoint_in_literal,
    unconditional_panic,
    undropped_manually_drops,
    unknown_crate_types,
    useless_deprecated,
    clippy::all,
    box_pointers,
    dead_code,
    trivial_casts,
    unreachable_pub
)]
*/
// ////////////////////////////////////////////////////////////////////////////
// mod  =======================================================================
mod error;
// ////////////////////////////////////////////////////////////////////////////
// use  =======================================================================
#[cfg(feature = "parking_lot")]
pub use parking_lot::{
    Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard,
};
// ----------------------------------------------------------------------------
#[cfg(not(any(feature = "parking_lot",)))]
pub use std::sync::{
    Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard,
};
// ============================================================================
pub use self::error::{Error, Result};
pub use elicit_macro::{
    aelicit_define, elicit_define, melicit_define, Aelicit, Elicit, Melicit,
};