diff --git a/zmq.rs b/zmq.rs index 7c5a205a0..f86a7fa78 100644 --- a/zmq.rs +++ b/zmq.rs @@ -356,12 +356,18 @@ obj new_socket(sock: @socket_res) { // Accept connections on a socket. fn bind(endpoint: str) -> result::t<(), error> { - _bind(sock, endpoint) + // Work around rust bug #1286. + let sock = sock; + let rc = str::as_buf(endpoint, { |b| libzmq::zmq_bind(sock.sock, b) }); + if rc == -1i32 { err(errno_to_error()) } else { ok(()) } } // Connect a socket. fn connect(endpoint: str) -> result::t<(), error> { - _connect(sock, endpoint) + // Work around rust bug #1286. + let sock = sock; + let rc = str::as_buf(endpoint, { |b| libzmq::zmq_connect(sock.sock, b) }); + if rc == -1i32 { err(errno_to_error()) } else { ok(()) } } fn send(data: [u8], flags: c_int) -> result::t<(), error> { @@ -407,17 +413,6 @@ obj new_socket(sock: @socket_res) { } } -// Work around a bug by moving this out of an object. -fn _bind(sock: @socket_res, endpoint: str) -> result::t<(), error> { - let rc = str::as_buf(endpoint, { |b| libzmq::zmq_bind(sock.sock, b) }); - if rc == -1i32 { err(errno_to_error()) } else { ok(()) } -} - -fn _connect(sock: @socket_res, endpoint: str) -> result::t<(), error> { - let rc = str::as_buf(endpoint, { |b| libzmq::zmq_connect(sock.sock, b) }); - if rc == -1i32 { err(errno_to_error()) } else { ok(()) } -} - // Convert a socket kind into the constant value. fn socket_kind_to_i32(k: socket_kind) -> c_int { alt k {