@@ -39,51 +39,43 @@ impl<T: SelfInstanceBuilder> FactorInstanceBuilder for T {
39
39
/// A PrepareContext is passed to [`Factor::prepare`].
40
40
///
41
41
/// This gives the factor access to app state and the app component.
42
- pub struct PrepareContext < ' a , F : Factor > {
42
+ pub struct PrepareContext < ' a , T : RuntimeFactors , F : Factor > {
43
43
pub ( crate ) app_state : & ' a F :: AppState ,
44
44
pub ( crate ) app_component : & ' a AppComponent < ' a > ,
45
+ pub ( crate ) instance_builders : & ' a mut T :: InstanceBuilders ,
45
46
}
46
47
47
- impl < ' a , F : Factor > PrepareContext < ' a , F > {
48
+ impl < ' a , T : RuntimeFactors , F : Factor > PrepareContext < ' a , T , F > {
48
49
#[ doc( hidden) ]
49
- pub fn new ( app_state : & ' a F :: AppState , app_component : & ' a AppComponent ) -> Self {
50
+ pub fn new (
51
+ app_state : & ' a F :: AppState ,
52
+ app_component : & ' a AppComponent ,
53
+ instance_builders : & ' a mut T :: InstanceBuilders ,
54
+ ) -> Self {
50
55
Self {
51
56
app_state,
52
57
app_component,
58
+ instance_builders,
53
59
}
54
60
}
55
61
56
62
/// Get the app state related to the factor.
57
- pub fn app_state ( & self ) -> & F :: AppState {
63
+ pub fn app_state ( & self ) -> & ' a F :: AppState {
58
64
self . app_state
59
65
}
60
66
61
67
/// Get the app component.
62
- pub fn app_component ( & self ) -> & AppComponent {
68
+ pub fn app_component ( & self ) -> & ' a AppComponent {
63
69
self . app_component
64
70
}
65
- }
66
-
67
- /// The collection of all the already prepared `InstanceBuilder`s.
68
- ///
69
- /// Use `InstanceBuilders::get_mut` to get a mutable reference to a specific factor's instance builder.
70
- pub struct PreparedInstanceBuilders < ' a , T : RuntimeFactors > {
71
- pub ( crate ) inner : & ' a mut T :: InstanceBuilders ,
72
- }
73
-
74
- impl < ' a , T : RuntimeFactors > PreparedInstanceBuilders < ' a , T > {
75
- #[ doc( hidden) ]
76
- pub fn new ( inner : & ' a mut T :: InstanceBuilders ) -> Self {
77
- Self { inner }
78
- }
79
71
80
72
/// Returns the prepared [`FactorInstanceBuilder`] for the given [`Factor`].
81
73
///
82
74
/// Fails if the current [`RuntimeFactors`] does not include the given
83
75
/// [`Factor`] or if the given [`Factor`]'s builder has not been prepared
84
76
/// yet (because it is sequenced after this factor).
85
- pub fn get_mut < U : Factor > ( & mut self ) -> crate :: Result < & mut U :: InstanceBuilder > {
86
- T :: instance_builder_mut :: < U > ( self . inner )
77
+ pub fn instance_builder < U : Factor > ( & mut self ) -> crate :: Result < & mut U :: InstanceBuilder > {
78
+ T :: instance_builder_mut :: < U > ( self . instance_builders )
87
79
. ok_or ( Error :: no_such_factor :: < U > ( ) ) ?
88
80
. ok_or_else ( || {
89
81
Error :: DependencyOrderingError ( format ! (
0 commit comments