File tree Expand file tree Collapse file tree 4 files changed +21
-10
lines changed Expand file tree Collapse file tree 4 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -41,8 +41,7 @@ fn main() {
4141 receiver
4242 . bind ( "inproc://step3" )
4343 . expect ( "failed binding step 3" ) ;
44- let ctx = context. clone ( ) ;
45- thread:: spawn ( move || step2 ( & ctx) ) ;
44+ thread:: spawn ( move || step2 ( & context) ) ;
4645 //wait for signal and pass it on
4746 receiver. recv_msg ( 0 ) . unwrap ( ) ;
4847 println ! ( "Test successful!" ) ;
Original file line number Diff line number Diff line change @@ -480,10 +480,8 @@ unsafe impl Send for Socket {}
480480
481481impl Drop for Socket {
482482 fn drop ( & mut self ) {
483- if self . owned {
484- if unsafe { zmq_sys:: zmq_close ( self . sock ) } == -1 {
485- panic ! ( errno_to_error( ) ) ;
486- }
483+ if self . owned && unsafe { zmq_sys:: zmq_close ( self . sock ) } == -1 {
484+ panic ! ( errno_to_error( ) ) ;
487485 }
488486 }
489487}
@@ -591,6 +589,13 @@ impl Socket {
591589 ///
592590 /// The Socket assumes ownership of the pointer and will close the socket
593591 /// when it is dropped. The returned socket will not reference any context.
592+ ///
593+ /// # Safety
594+ ///
595+ /// The socket pointer must be a socket created via the `into_raw`
596+ /// method. The ownership of the socket is transferred the returned Socket,
597+ /// so any other pointers to the same socket may only be used until it is
598+ /// dropped.
594599 pub unsafe fn from_raw ( sock : * mut c_void ) -> Socket {
595600 Socket {
596601 sock,
Original file line number Diff line number Diff line change @@ -65,6 +65,14 @@ impl Message {
6565 /// function, its use is not recommended, and it will be removed in a future
6666 /// release. If there is a use-case that cannot be handled efficiently by
6767 /// the safe message constructors, please file an issue.
68+ ///
69+ /// # Safety
70+ ///
71+ /// The returned message contains uninitialized memory, and hence the
72+ /// `Deref` and `DerefMut` traits must not be used until the memory has been
73+ /// initialized. Since there is no proper API to do so, this function is
74+ /// basically not usable safely, unless you happen to invoke C code that
75+ /// takes a raw message pointer and initializes its contents.
6876 #[ deprecated(
6977 since = "0.9.1" ,
7078 note = "This method has an unintuitive name, and should not be needed."
Original file line number Diff line number Diff line change 1- use std:: env:: var ;
1+ use std:: env;
22use std:: path:: PathBuf ;
33
44fn run_mode ( mode : & ' static str ) {
@@ -11,9 +11,8 @@ fn run_mode(mode: &'static str) {
1111 profile = env!( "BUILD_PROFILE" )
1212 ) ) ;
1313
14- if let Ok ( name) = var :: < & str > ( "TESTNAME" ) {
15- let s: String = name. to_owned ( ) ;
16- config. filter = Some ( s)
14+ if let Ok ( name) = env:: var ( "TESTNAME" ) {
15+ config. filter = Some ( name)
1716 }
1817 config. mode = cfg_mode;
1918 config. src_base = PathBuf :: from ( format ! ( "tests/{}" , mode) ) ;
You can’t perform that action at this time.
0 commit comments