@@ -28,20 +28,23 @@ use pubnub::{
2828fn custom_random ( buf : & mut [ u8 ] ) -> Result < ( ) , getrandom:: Error > {
2929 // We're using `42` as a random number, because it's the answer
3030 // to the Ultimate Question of Life, the Universe, and Everything.
31- // In your program, you should use proper random number generator that is supported by your target.
31+ // In your program, you should use proper random number generator that is
32+ // supported by your target.
3233 for i in buf. iter_mut ( ) {
3334 * i = 42 ;
3435 }
3536
3637 Ok ( ( ) )
3738}
3839
39- // This function is used to register the custom implementation of `getrandom` function.
40+ // This function is used to register the custom implementation of `getrandom`
41+ // function.
4042#[ no_mangle]
4143unsafe extern "Rust" fn __getrandom_v03_custom (
4244 dest : * mut u8 ,
4345 len : usize ,
4446) -> Result < ( ) , getrandom:: Error > {
47+ #[ allow( unsafe_code) ]
4548 let buf = unsafe {
4649 // fill the buffer with zeros
4750 core:: ptr:: write_bytes ( dest, 0 , len) ;
@@ -53,7 +56,8 @@ unsafe extern "Rust" fn __getrandom_v03_custom(
5356
5457// Many targets have very specific requirements for networking, so it's hard to
5558// provide a generic implementation.
56- // Depending on the target, you will probably need to implement `Transport` trait.
59+ // Depending on the target, you will probably need to implement `Transport`
60+ // trait.
5761struct MyTransport ;
5862
5963impl Transport for MyTransport {
@@ -69,8 +73,8 @@ impl Transport for MyTransport {
6973// As our target does not have `std` library, we need to provide custom
7074// implementation of `GlobalAlloc` trait.
7175//
72- // In your program, you should use proper allocator that is supported by your target.
73- // Here you have dummy implementation that does nothing.
76+ // In your program, you should use proper allocator that is supported by your
77+ // target. Here you have dummy implementation that does nothing.
7478#[ derive( Default ) ]
7579pub struct Allocator ;
7680
@@ -87,23 +91,23 @@ static GLOBAL_ALLOCATOR: Allocator = Allocator;
8791// As our target does not have `std` library, we need to provide custom
8892// implementation of `panic_handler`.
8993//
90- // In your program, you should use proper panic handler that is supported by your target.
91- // Here you have dummy implementation that does nothing.
94+ // In your program, you should use proper panic handler that is supported by
95+ // your target. Here you have dummy implementation that does nothing.
9296#[ panic_handler]
9397fn panicking ( _: & PanicInfo ) -> ! {
9498 loop { }
9599}
96100
97- // As we're using `no_main` attribute, we need to define `main` function manually.
98- // For this example we're using `extern "C"` ABI to make it work.
101+ // As we're using `no_main` attribute, we need to define `main` function
102+ // manually. For this example we're using `extern "C"` ABI to make it work.
99103#[ no_mangle]
100104pub extern "C" fn main ( _argc : isize , _argv : * const * const u8 ) -> usize {
101105 publish_example ( ) . map ( |_| 0 ) . unwrap ( )
102106}
103107
104- // In standard subscribe examples we use `println` macro to print the result of the operation
105- // and it shows the idea of the example. `no_std` does not support `println` macro,
106- // so we're using `do_a_thing` function instead.
108+ // In standard subscribe examples we use `println` macro to print the result of
109+ // the operation and it shows the idea of the example. `no_std` does not support
110+ // `println` macro, so we're using `do_a_thing` function instead.
107111fn do_a_thing < T > ( _: & T ) { }
108112
109113// As `no_std` does not support `Error` trait, we use `PubNubError` instead.
@@ -129,8 +133,8 @@ fn publish_example() -> Result<(), PubNubError> {
129133 . include_user_id ( true )
130134 . execute_blocking ( ) ?;
131135
132- // As `no_std` does not support `println` macro, we're using `do_a_thing` function instead
133- // to show possible usage of the result.
136+ // As `no_std` does not support `println` macro, we're using `do_a_thing`
137+ // function instead to show possible usage of the result.
134138
135139 channels_now. iter ( ) . for_each ( |channel| {
136140 do_a_thing ( & channel. name ) ;
0 commit comments