Run rustfmt

This commit is contained in:
konstin 2018-11-02 22:35:19 +01:00
parent 569db5fb02
commit 9ffb2c617d
19 changed files with 35 additions and 37 deletions

View File

@ -5,7 +5,6 @@
#[macro_use] #[macro_use]
mod macros; mod macros;
pub mod pyasync;
pub mod basic; pub mod basic;
pub mod buffer; pub mod buffer;
pub mod context; pub mod context;
@ -15,9 +14,9 @@ pub mod iter;
pub mod mapping; pub mod mapping;
pub mod methods; pub mod methods;
pub mod number; pub mod number;
pub mod pyasync;
pub mod sequence; pub mod sequence;
pub use self::pyasync::PyAsyncProtocol;
pub use self::basic::PyObjectProtocol; pub use self::basic::PyObjectProtocol;
pub use self::buffer::PyBufferProtocol; pub use self::buffer::PyBufferProtocol;
pub use self::context::PyContextProtocol; pub use self::context::PyContextProtocol;
@ -25,6 +24,7 @@ pub use self::descr::PyDescrProtocol;
pub use self::iter::PyIterProtocol; pub use self::iter::PyIterProtocol;
pub use self::mapping::PyMappingProtocol; pub use self::mapping::PyMappingProtocol;
pub use self::number::PyNumberProtocol; pub use self::number::PyNumberProtocol;
pub use self::pyasync::PyAsyncProtocol;
pub use self::sequence::PySequenceProtocol; pub use self::sequence::PySequenceProtocol;
pub use self::gc::{PyGCProtocol, PyTraverseError, PyVisit}; pub use self::gc::{PyGCProtocol, PyTraverseError, PyVisit};

View File

@ -9,9 +9,9 @@ use crate::err::{PyErr, PyResult};
use crate::ffi; use crate::ffi;
use crate::objectprotocol::ObjectProtocol; use crate::objectprotocol::ObjectProtocol;
use crate::python::Python; use crate::python::Python;
use std::os::raw::c_int;
use crate::typeob::PyTypeInfo; use crate::typeob::PyTypeInfo;
use crate::types::{exceptions, PyObjectRef}; use crate::types::{exceptions, PyObjectRef};
use std::os::raw::c_int;
/// Sequece interface /// Sequece interface
#[allow(unused_variables)] #[allow(unused_variables)]

View File

@ -9,11 +9,11 @@ use crate::err::PyResult;
use crate::exceptions::TypeError; use crate::exceptions::TypeError;
use crate::ffi; use crate::ffi;
use crate::init_once; use crate::init_once;
use std::ptr;
use crate::types::PyModule; use crate::types::PyModule;
use crate::types::{PyDict, PyObjectRef, PyString, PyTuple}; use crate::types::{PyDict, PyObjectRef, PyString, PyTuple};
use crate::GILPool; use crate::GILPool;
use crate::Python; use crate::Python;
use std::ptr;
#[derive(Debug)] #[derive(Debug)]
/// Description of a python parameter; used for `parse_args()`. /// Description of a python parameter; used for `parse_args()`.

View File

@ -45,7 +45,8 @@ extern "C" {
// TODO: Py_EnterRecursiveCall etc. // TODO: Py_EnterRecursiveCall etc.
#[cfg(Py_3_6)] #[cfg(Py_3_6)]
pub type _PyFrameEvalFunction = extern "C" fn(*mut crate::ffi3::PyFrameObject, c_int) -> *mut PyObject; pub type _PyFrameEvalFunction =
extern "C" fn(*mut crate::ffi3::PyFrameObject, c_int) -> *mut PyObject;
#[cfg_attr(windows, link(name = "pythonXY"))] #[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" { extern "C" {
@ -54,7 +55,10 @@ extern "C" {
pub fn PyEval_GetCallStats(arg1: *mut PyObject) -> *mut PyObject; pub fn PyEval_GetCallStats(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyEval_EvalFrame(arg1: *mut crate::ffi3::PyFrameObject) -> *mut PyObject; pub fn PyEval_EvalFrame(arg1: *mut crate::ffi3::PyFrameObject) -> *mut PyObject;
#[cfg(Py_3_6)] #[cfg(Py_3_6)]
pub fn _PyEval_EvalFrameDefault(arg1: *mut crate::ffi3::PyFrameObject, exc: c_int) -> *mut PyObject; pub fn _PyEval_EvalFrameDefault(
arg1: *mut crate::ffi3::PyFrameObject,
exc: c_int,
) -> *mut PyObject;
#[cfg(Py_3_6)] #[cfg(Py_3_6)]
pub fn _PyEval_RequestCodeExtraIndex(func: FreeFunc) -> c_int; pub fn _PyEval_RequestCodeExtraIndex(func: FreeFunc) -> c_int;
pub fn PyEval_EvalFrameEx(f: *mut crate::ffi3::PyFrameObject, exc: c_int) -> *mut PyObject; pub fn PyEval_EvalFrameEx(f: *mut crate::ffi3::PyFrameObject, exc: c_int) -> *mut PyObject;

View File

@ -5,9 +5,9 @@
use crate::err::PyResult; use crate::err::PyResult;
use crate::ffi; use crate::ffi;
use crate::python::Python; use crate::python::Python;
use crate::typeob::{pytype_drop, PyObjectAlloc, PyTypeInfo};
use std::mem; use std::mem;
use std::os::raw::c_void; use std::os::raw::c_void;
use crate::typeob::{pytype_drop, PyObjectAlloc, PyTypeInfo};
/// Implementing this trait for custom class adds free allocation list to class. /// Implementing this trait for custom class adds free allocation list to class.
/// The performance improvement applies to types that are often created and deleted in a row, /// The performance improvement applies to types that are often created and deleted in a row,

View File

@ -6,11 +6,11 @@ use crate::ffi;
use crate::instance::PyObjectWithToken; use crate::instance::PyObjectWithToken;
use crate::object::PyObject; use crate::object::PyObject;
use crate::python::{IntoPyPointer, Python, ToPyPointer}; use crate::python::{IntoPyPointer, Python, ToPyPointer};
use crate::typeob::PyTypeInfo;
use crate::types::{PyDict, PyIterator, PyObjectRef, PyString, PyTuple, PyType};
use std; use std;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::os::raw::c_int; use std::os::raw::c_int;
use crate::typeob::PyTypeInfo;
use crate::types::{PyDict, PyIterator, PyObjectRef, PyString, PyTuple, PyType};
/// Python object model helper methods /// Python object model helper methods
pub trait ObjectProtocol { pub trait ObjectProtocol {

View File

@ -8,13 +8,13 @@ use crate::ffi;
use crate::instance::{AsPyRef, Py, PyToken}; use crate::instance::{AsPyRef, Py, PyToken};
use crate::object::PyObject; use crate::object::PyObject;
use crate::pythonrun::{self, GILGuard}; use crate::pythonrun::{self, GILGuard};
use crate::typeob::PyTypeCreate;
use crate::typeob::{PyTypeInfo, PyTypeObject};
use crate::types::{PyDict, PyModule, PyObjectRef, PyType};
use std; use std;
use std::ffi::CString; use std::ffi::CString;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::os::raw::c_int; use std::os::raw::c_int;
use crate::typeob::PyTypeCreate;
use crate::typeob::{PyTypeInfo, PyTypeObject};
use crate::types::{PyDict, PyModule, PyObjectRef, PyType};
/// Marker type that indicates that the GIL is currently held. /// Marker type that indicates that the GIL is currently held.
/// ///

View File

@ -1,9 +1,9 @@
// Copyright (c) 2017-present PyO3 Project and Contributors // Copyright (c) 2017-present PyO3 Project and Contributors
use crate::ffi; use crate::ffi;
use crate::python::Python; use crate::python::Python;
use crate::types::PyObjectRef;
use spin; use spin;
use std::{any, marker, rc, sync}; use std::{any, marker, rc, sync};
use crate::types::PyObjectRef;
static START: sync::Once = sync::ONCE_INIT; static START: sync::Once = sync::ONCE_INIT;
static START_PYO3: sync::Once = sync::ONCE_INIT; static START_PYO3: sync::Once = sync::ONCE_INIT;

View File

@ -7,14 +7,14 @@ use crate::err::{PyErr, PyResult};
use crate::instance::{Py, PyObjectWithToken, PyToken}; use crate::instance::{Py, PyObjectWithToken, PyToken};
use crate::python::ToPyPointer; use crate::python::ToPyPointer;
use crate::python::{IntoPyPointer, Python}; use crate::python::{IntoPyPointer, Python};
use crate::types::PyObjectRef;
use crate::types::PyType;
use crate::{class, ffi, pythonrun};
use std; use std;
use std::collections::HashMap; use std::collections::HashMap;
use std::ffi::CString; use std::ffi::CString;
use std::mem; use std::mem;
use std::os::raw::c_void; use std::os::raw::c_void;
use crate::types::PyObjectRef;
use crate::types::PyType;
use crate::{class, ffi, pythonrun};
/// Python type information. /// Python type information.
pub trait PyTypeInfo { pub trait PyTypeInfo {

View File

@ -24,9 +24,9 @@ use crate::ffi::{
use crate::instance::Py; use crate::instance::Py;
use crate::object::PyObject; use crate::object::PyObject;
use crate::python::{Python, ToPyPointer}; use crate::python::{Python, ToPyPointer};
use crate::types::PyTuple;
use std::os::raw::c_int; use std::os::raw::c_int;
use std::ptr; use std::ptr;
use crate::types::PyTuple;
/// Access traits /// Access traits

View File

@ -6,9 +6,9 @@ use crate::ffi;
use crate::instance::PyObjectWithToken; use crate::instance::PyObjectWithToken;
use crate::object::PyObject; use crate::object::PyObject;
use crate::python::{IntoPyPointer, Python, ToPyPointer}; use crate::python::{IntoPyPointer, Python, ToPyPointer};
use crate::types::{PyList, PyObjectRef};
use std; use std;
use std::{cmp, collections, hash, mem}; use std::{cmp, collections, hash, mem};
use crate::types::{PyList, PyObjectRef};
/// Represents a Python `dict`. /// Represents a Python `dict`.
#[repr(transparent)] #[repr(transparent)]
@ -275,10 +275,10 @@ mod test {
use crate::conversion::{IntoPyObject, PyTryFrom, ToPyObject}; use crate::conversion::{IntoPyObject, PyTryFrom, ToPyObject};
use crate::instance::AsPyRef; use crate::instance::AsPyRef;
use crate::python::Python; use crate::python::Python;
use std::collections::{BTreeMap, HashMap};
use crate::types::dict::IntoPyDict; use crate::types::dict::IntoPyDict;
use crate::types::{PyDict, PyList, PyTuple}; use crate::types::{PyDict, PyList, PyTuple};
use crate::ObjectProtocol; use crate::ObjectProtocol;
use std::collections::{BTreeMap, HashMap};
#[test] #[test]
fn test_new() { fn test_new() {

View File

@ -7,11 +7,11 @@ use crate::err::{PyErr, PyResult};
use crate::ffi; use crate::ffi;
use crate::instance::Py; use crate::instance::Py;
use crate::python::{Python, ToPyPointer}; use crate::python::{Python, ToPyPointer};
use crate::typeob::PyTypeObject;
use crate::types::{PyObjectRef, PyTuple, PyType};
use std::ffi::CStr; use std::ffi::CStr;
use std::os::raw::c_char; use std::os::raw::c_char;
use std::{self, ops}; use std::{self, ops};
use crate::typeob::PyTypeObject;
use crate::types::{PyObjectRef, PyTuple, PyType};
// Copyright (c) 2017-present PyO3 Project and Contributors // Copyright (c) 2017-present PyO3 Project and Contributors

View File

@ -9,10 +9,10 @@ use crate::instance::{Py, PyObjectWithToken};
use crate::object::PyObject; use crate::object::PyObject;
use crate::objectprotocol::ObjectProtocol; use crate::objectprotocol::ObjectProtocol;
use crate::python::{Python, ToPyPointer}; use crate::python::{Python, ToPyPointer};
use std::os::raw::c_double;
use crate::types::PyObjectRef; use crate::types::PyObjectRef;
use crate::FromPyObject; use crate::FromPyObject;
use crate::PyResult; use crate::PyResult;
use std::os::raw::c_double;
/// Represents a Python `float` object. /// Represents a Python `float` object.
/// ///

View File

@ -71,7 +71,8 @@ mod tests {
use crate::objectprotocol::ObjectProtocol; use crate::objectprotocol::ObjectProtocol;
use crate::python::Python; use crate::python::Python;
use crate::pythonrun::GILPool; use crate::pythonrun::GILPool;
use crate::types::{PyList, PyObjectRef}; use crate::types::{PyDict, PyList, PyObjectRef};
use crate::GILGuard;
#[test] #[test]
fn vec_iter() { fn vec_iter() {
@ -135,13 +136,6 @@ mod tests {
} }
assert_eq!(count, none.get_refcnt()); assert_eq!(count, none.get_refcnt());
} }
}
#[cfg(test)]
mod test {
use crate::objectprotocol::ObjectProtocol;
use crate::GILGuard;
use crate::types::PyDict;
#[test] #[test]
fn fibonacci_generator() { fn fibonacci_generator() {

View File

@ -9,11 +9,11 @@ use crate::instance::PyObjectWithToken;
use crate::object::PyObject; use crate::object::PyObject;
use crate::objectprotocol::ObjectProtocol; use crate::objectprotocol::ObjectProtocol;
use crate::python::{Python, ToPyPointer}; use crate::python::{Python, ToPyPointer};
use crate::typeob::{initialize_type, PyTypeInfo};
use crate::types::{exceptions, PyDict, PyObjectRef, PyType};
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::os::raw::c_char; use std::os::raw::c_char;
use std::str; use std::str;
use crate::typeob::{initialize_type, PyTypeInfo};
use crate::types::{exceptions, PyDict, PyObjectRef, PyType};
/// Represents a Python `module` object. /// Represents a Python `module` object.
#[repr(transparent)] #[repr(transparent)]

View File

@ -12,9 +12,9 @@ use crate::ffi;
use crate::instance::PyObjectWithToken; use crate::instance::PyObjectWithToken;
use crate::object::PyObject; use crate::object::PyObject;
use crate::python::{Python, ToPyPointer}; use crate::python::{Python, ToPyPointer};
use crate::types::{exceptions, PyObjectRef};
use std::i64; use std::i64;
use std::os::raw::{c_long, c_uchar}; use std::os::raw::{c_long, c_uchar};
use crate::types::{exceptions, PyObjectRef};
/// Represents a Python `int` object. /// Represents a Python `int` object.
/// ///

View File

@ -188,8 +188,8 @@ mod test {
fn test_u128_overflow() { fn test_u128_overflow() {
use crate::ffi; use crate::ffi;
use crate::object::PyObject; use crate::object::PyObject;
use std::os::raw::c_uchar;
use crate::types::exceptions; use crate::types::exceptions;
use std::os::raw::c_uchar;
let gil = Python::acquire_gil(); let gil = Python::acquire_gil();
let py = gil.python(); let py = gil.python();
let overflow_bytes: [c_uchar; 20] = [255; 20]; let overflow_bytes: [c_uchar; 20] = [255; 20];

View File

@ -3,9 +3,9 @@ use crate::err::PyResult;
use crate::instance::PyObjectWithToken; use crate::instance::PyObjectWithToken;
use crate::object::PyObject; use crate::object::PyObject;
use crate::python::Python; use crate::python::Python;
use std::borrow::Cow;
use crate::types::{PyObjectRef, PyString}; use crate::types::{PyObjectRef, PyString};
use crate::FromPyObject; use crate::FromPyObject;
use std::borrow::Cow;
/// Converts Rust `str` to Python object. /// Converts Rust `str` to Python object.
/// See `PyString::new` for details on the conversion. /// See `PyString::new` for details on the conversion.

View File

@ -7,8 +7,8 @@ use crate::ffi::{self, Py_ssize_t};
use crate::instance::{AsPyRef, Py, PyObjectWithToken}; use crate::instance::{AsPyRef, Py, PyObjectWithToken};
use crate::object::PyObject; use crate::object::PyObject;
use crate::python::{IntoPyPointer, Python, ToPyPointer}; use crate::python::{IntoPyPointer, Python, ToPyPointer};
use std::slice;
use crate::types::PyObjectRef; use crate::types::PyObjectRef;
use std::slice;
/// Represents a Python `tuple` object. /// Represents a Python `tuple` object.
#[repr(transparent)] #[repr(transparent)]
@ -269,9 +269,9 @@ mod test {
use crate::instance::AsPyRef; use crate::instance::AsPyRef;
use crate::objectprotocol::ObjectProtocol; use crate::objectprotocol::ObjectProtocol;
use crate::python::Python; use crate::python::Python;
use std::collections::HashSet;
use crate::types::PyObjectRef; use crate::types::PyObjectRef;
use crate::types::PyTuple; use crate::types::PyTuple;
use std::collections::HashSet;
#[test] #[test]
fn test_new() { fn test_new() {