Skip to content

Commit d1bff24

Browse files
committed
Auto merge of #55 - japaric:late-resources, r=japaric
[RFC] rename LateResourceValues to LateResources After writing `LateResourceValues` several times I now think it's too long to type. I'd like that struct to be renamed to `LateResources`. I don't think there would be a loss in readability with the rename because you can think of "late resources" as resources that "don't exist" until `init` ends instead of as resources that are not initialized after `init` ends -- the second meaning maps better to `LateResourceValues`. This would be a breaking-change but we are moving to v0.3.0 due to #50 in any case. cc jonas-schievink
2 parents e78ca98 + edca7d5 commit d1bff24

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

examples/late-resources.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ app! {
5555
}
5656

5757
// The signature of `init` is now required to have a specific return type.
58-
fn init(_p: init::Peripherals, _r: init::Resources) -> init::LateResourceValues {
58+
fn init(_p: init::Peripherals, _r: init::Resources) -> init::LateResources {
5959
// `init::Resources` does not contain `IP_ADDRESS`, since it is not yet
6060
// initialized.
6161
//_r.IP_ADDRESS; // doesn't compile
6262

6363
// ...obtain value for IP_ADDRESS from EEPROM/DHCP...
6464
let ip_address = 0x7f000001;
6565

66-
init::LateResourceValues {
66+
init::LateResources {
6767
// This struct will contain fields for all resources with omitted
6868
// initializers.
6969
IP_ADDRESS: ip_address,

macros/src/trans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,17 @@ fn init(app: &App, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) {
234234
root.push(quote! {
235235
#[allow(non_camel_case_types)]
236236
#[allow(non_snake_case)]
237-
pub struct _initLateResourceValues {
237+
pub struct _initLateResources {
238238
#(#fields)*
239239
}
240240
});
241241

242242
mod_items.push(quote! {
243-
pub use ::_initLateResourceValues as LateResourceValues;
243+
pub use ::_initLateResources as LateResources;
244244
});
245245

246246
// `init` must return the initialized resources
247-
ret = Some(quote!( -> ::init::LateResourceValues));
247+
ret = Some(quote!( -> ::init::LateResources));
248248
}
249249

250250
root.push(quote! {

src/examples/_5_late_resources.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@
5757
//! }
5858
//!
5959
//! // The signature of `init` is now required to have a specific return type.
60-
//! fn init(_p: init::Peripherals, _r: init::Resources) -> init::LateResourceValues {
60+
//! fn init(_p: init::Peripherals, _r: init::Resources) -> init::LateResources {
6161
//! // `init::Resources` does not contain `IP_ADDRESS`, since it is not yet
6262
//! // initialized.
6363
//! //_r.IP_ADDRESS; // doesn't compile
6464
//!
6565
//! // ...obtain value for IP_ADDRESS from EEPROM/DHCP...
6666
//! let ip_address = 0x7f000001;
6767
//!
68-
//! init::LateResourceValues {
68+
//! init::LateResources {
6969
//! // This struct will contain fields for all resources with omitted
7070
//! // initializers.
7171
//! IP_ADDRESS: ip_address,

tests/cfail/late-resource-init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ app! {
3030
},
3131
}
3232

33-
fn init(_p: init::Peripherals, r: init::Resources) -> init::LateResourceValues {
33+
fn init(_p: init::Peripherals, r: init::Resources) -> init::LateResources {
3434
// Try to use a resource that's not yet initialized:
3535
r.LATE;
3636
//~^ error: no field `LATE`
3737

38-
init::LateResourceValues {
38+
init::LateResources {
3939
LATE: 0,
4040
}
4141
}

0 commit comments

Comments
 (0)