diff options
author | 2017-12-09 13:47:10 +0000 | |
---|---|---|
committer | 2017-12-09 13:47:10 +0000 | |
commit | 0a0e0e2b382d826ac7b423c91f39d2abf91a010f (patch) | |
tree | 5b4e2a8c3319f73a2e74a0ea498067f72c560dc3 | |
parent | e78ca98c42a2af1ca9c04d176441b045cd5e8c65 (diff) | |
parent | 512091e8a36a4e561500be81533516736ec49340 (diff) | |
download | rtic-0a0e0e2b382d826ac7b423c91f39d2abf91a010f.tar.gz rtic-0a0e0e2b382d826ac7b423c91f39d2abf91a010f.tar.zst rtic-0a0e0e2b382d826ac7b423c91f39d2abf91a010f.zip |
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
-rw-r--r-- | examples/generics.rs | 4 | ||||
-rw-r--r-- | examples/late-resources.rs | 4 | ||||
-rw-r--r-- | macros/src/trans.rs | 6 | ||||
-rw-r--r-- | src/examples/_5_late_resources.rs | 4 | ||||
-rw-r--r-- | tests/cfail/late-resource-init.rs | 4 |
5 files changed, 11 insertions, 11 deletions
diff --git a/examples/generics.rs b/examples/generics.rs index afcafa0a..bc2fe7a8 100644 --- a/examples/generics.rs +++ b/examples/generics.rs @@ -32,8 +32,8 @@ app! { }, } -fn init(p: init::Peripherals) -> init::LateResourceValues { - init::LateResourceValues { +fn init(p: init::Peripherals) -> init::LateResources { + init::LateResources { GPIOA: p.device.GPIOA, SPI1: p.device.SPI1, } diff --git a/examples/late-resources.rs b/examples/late-resources.rs index 337fbdfa..69a0ce8a 100644 --- a/examples/late-resources.rs +++ b/examples/late-resources.rs @@ -55,7 +55,7 @@ app! { } // The signature of `init` is now required to have a specific return type. -fn init(_p: init::Peripherals, _r: init::Resources) -> init::LateResourceValues { +fn init(_p: init::Peripherals, _r: init::Resources) -> init::LateResources { // `init::Resources` does not contain `IP_ADDRESS`, since it is not yet // initialized. //_r.IP_ADDRESS; // doesn't compile @@ -63,7 +63,7 @@ fn init(_p: init::Peripherals, _r: init::Resources) -> init::LateResourceValues // ...obtain value for IP_ADDRESS from EEPROM/DHCP... let ip_address = 0x7f000001; - init::LateResourceValues { + init::LateResources { // This struct will contain fields for all resources with omitted // initializers. IP_ADDRESS: ip_address, diff --git a/macros/src/trans.rs b/macros/src/trans.rs index bc69f24e..96631d5d 100644 --- a/macros/src/trans.rs +++ b/macros/src/trans.rs @@ -234,17 +234,17 @@ fn init(app: &App, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) { root.push(quote! { #[allow(non_camel_case_types)] #[allow(non_snake_case)] - pub struct _initLateResourceValues { + pub struct _initLateResources { #(#fields)* } }); mod_items.push(quote! { - pub use ::_initLateResourceValues as LateResourceValues; + pub use ::_initLateResources as LateResources; }); // `init` must return the initialized resources - ret = Some(quote!( -> ::init::LateResourceValues)); + ret = Some(quote!( -> ::init::LateResources)); } root.push(quote! { diff --git a/src/examples/_5_late_resources.rs b/src/examples/_5_late_resources.rs index 8a5b6e16..8df6716c 100644 --- a/src/examples/_5_late_resources.rs +++ b/src/examples/_5_late_resources.rs @@ -57,7 +57,7 @@ //! } //! //! // The signature of `init` is now required to have a specific return type. -//! fn init(_p: init::Peripherals, _r: init::Resources) -> init::LateResourceValues { +//! fn init(_p: init::Peripherals, _r: init::Resources) -> init::LateResources { //! // `init::Resources` does not contain `IP_ADDRESS`, since it is not yet //! // initialized. //! //_r.IP_ADDRESS; // doesn't compile @@ -65,7 +65,7 @@ //! // ...obtain value for IP_ADDRESS from EEPROM/DHCP... //! let ip_address = 0x7f000001; //! -//! init::LateResourceValues { +//! init::LateResources { //! // This struct will contain fields for all resources with omitted //! // initializers. //! IP_ADDRESS: ip_address, diff --git a/tests/cfail/late-resource-init.rs b/tests/cfail/late-resource-init.rs index a997b5c2..cb37887f 100644 --- a/tests/cfail/late-resource-init.rs +++ b/tests/cfail/late-resource-init.rs @@ -30,12 +30,12 @@ app! { }, } -fn init(_p: init::Peripherals, r: init::Resources) -> init::LateResourceValues { +fn init(_p: init::Peripherals, r: init::Resources) -> init::LateResources { // Try to use a resource that's not yet initialized: r.LATE; //~^ error: no field `LATE` - init::LateResourceValues { + init::LateResources { LATE: 0, } } |