aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/examples/rand.rs
diff options
context:
space:
mode:
authorGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-09-08 21:57:12 +0000
committerGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-09-08 21:57:12 +0000
commit513e66ff804c096d98b408fbf87f599aed0a9af2 (patch)
tree97ce43183744bafb6207a5ab3becd34ab4ae789b /cortex-m-rt/examples/rand.rs
parent9cb792ed7b6b45071080816d383296491c57202f (diff)
parentca46815047dd5f23f9a46f6cda7cf6e1e638815e (diff)
downloadcortex-m-513e66ff804c096d98b408fbf87f599aed0a9af2.tar.gz
cortex-m-513e66ff804c096d98b408fbf87f599aed0a9af2.tar.zst
cortex-m-513e66ff804c096d98b408fbf87f599aed0a9af2.zip
Merge #107
107: Disable default-features on rand dependency to avoid std version r=japaric a=therealprof Due to the single dependency tree, the attempted use of a std version flips all depending crates to the std version as well which will not compile on no_std systems. Fixes #105 Signed-off-by: Daniel Egger <daniel@eggers-club.de> Co-authored-by: Daniel Egger <daniel@eggers-club.de>
Diffstat (limited to 'cortex-m-rt/examples/rand.rs')
-rw-r--r--cortex-m-rt/examples/rand.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/cortex-m-rt/examples/rand.rs b/cortex-m-rt/examples/rand.rs
new file mode 100644
index 0000000..e0cfd31
--- /dev/null
+++ b/cortex-m-rt/examples/rand.rs
@@ -0,0 +1,24 @@
+//! Use rand crate to ensure it's configured for no_std compatbility
+
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt as rt;
+use rt::entry;
+
+extern crate panic_semihosting;
+
+extern crate rand;
+use rand::Rng;
+use rand::SeedableRng;
+
+// the program entry point
+#[entry]
+fn main() -> ! {
+ let seed: [u8; 32] = [0; 32];
+ let mut rng = rand::ChaChaRng::from_seed(seed);
+ let _ = rng.gen::<u32>();
+
+ loop {}
+}