Fix refs to std::num::cast -> num::traits::cast

This function was removed from the rust stdlib in
https://github.com/rust-lang/rust/commit/eeb948.

Updated to refer to the 'num' crate instead.
This commit is contained in:
James Salter 2015-05-09 17:12:26 +01:00
parent b9b67ee932
commit c1acf04e0e
2 changed files with 7 additions and 5 deletions

View file

@ -22,4 +22,4 @@ exclude = [
[dependencies] [dependencies]
python27-sys="*" python27-sys="*"
libc="*" libc="*"
num="*"

View file

@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
extern crate num;
use libc::{c_long, c_double}; use libc::{c_long, c_double};
use std; use std;
use python::{Python, PythonObject, ToPythonPointer}; use python::{Python, PythonObject, ToPythonPointer};
@ -78,7 +80,7 @@ macro_rules! int_fits_c_long(
if val == -1 && PyErr::occurred(py) { if val == -1 && PyErr::occurred(py) {
return Err(PyErr::fetch(py)); return Err(PyErr::fetch(py));
} }
match std::num::cast::<c_long, $rust_type>(val) { match num::traits::cast::<c_long, $rust_type>(val) {
Some(v) => Ok(v), Some(v) => Ok(v),
None => Err(overflow_error(py)) None => Err(overflow_error(py))
} }
@ -103,7 +105,7 @@ macro_rules! int_fits_larger_int(
fn from_py_object(s: &'s PyObject<'p>) -> PyResult<'p, $rust_type> { fn from_py_object(s: &'s PyObject<'p>) -> PyResult<'p, $rust_type> {
let py = s.python(); let py = s.python();
let val = try!(s.extract::<$larger_type>()); let val = try!(s.extract::<$larger_type>());
match std::num::cast::<$larger_type, $rust_type>(val) { match num::traits::cast::<$larger_type, $rust_type>(val) {
Some(v) => Ok(v), Some(v) => Ok(v),
None => Err(overflow_error(py)) None => Err(overflow_error(py))
} }
@ -143,7 +145,7 @@ impl <'p> ToPyObject<'p> for u64 {
fn to_py_object(&self, py: Python<'p>) -> PyObject<'p> { fn to_py_object(&self, py: Python<'p>) -> PyObject<'p> {
unsafe { unsafe {
let ptr = match std::num::cast::<u64, c_long>(*self) { let ptr = match num::traits::cast::<u64, c_long>(*self) {
Some(v) => ffi::PyInt_FromLong(v), Some(v) => ffi::PyInt_FromLong(v),
None => ffi::PyLong_FromUnsignedLongLong(*self) None => ffi::PyLong_FromUnsignedLongLong(*self)
}; };
@ -170,7 +172,7 @@ impl <'p, 's> FromPyObject<'p, 's> for u64 {
if ffi::PyLong_Check(ptr) != 0 { if ffi::PyLong_Check(ptr) != 0 {
pylong_as_u64(s) pylong_as_u64(s)
} else if ffi::PyInt_Check(ptr) != 0 { } else if ffi::PyInt_Check(ptr) != 0 {
match std::num::cast::<c_long, u64>(ffi::PyInt_AS_LONG(ptr)) { match num::traits::cast::<c_long, u64>(ffi::PyInt_AS_LONG(ptr)) {
Some(v) => Ok(v), Some(v) => Ok(v),
None => Err(overflow_error(py)) None => Err(overflow_error(py))
} }