Add missing module level docs

This commit is contained in:
messense 2017-06-24 16:47:36 +08:00
parent 84ebdbcfe9
commit 0ba541e762
No known key found for this signature in database
GPG Key ID: BB41A8A2C716CCA9
8 changed files with 17 additions and 5 deletions

View File

@ -2,6 +2,7 @@
//
// based on Daniel Grunwald's https://github.com/dgrunwald/rust-cpython
//! Python argument parsing
use ffi;
use python::Python;

View File

@ -16,6 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//! `PyBuffer` implementation
use std::os::raw;
use std::{mem, slice, cell};
use std::ffi::CStr;
@ -180,7 +181,7 @@ impl PyBuffer {
}
/// Gets the size of a single element, in bytes.
/// Important exception: when requesting an unformatted buffer, item_size still has the value
/// Important exception: when requesting an unformatted buffer, item_size still has the value
#[inline]
pub fn item_size(&self) -> usize {
self.0.itemsize as usize
@ -459,7 +460,7 @@ impl PyBuffer {
pub fn copy_from_slice<T: Element+Copy>(&self, py: Python, source: &[T]) -> PyResult<()> {
self.copy_from_slice_impl(py, source, b'C')
}
/// Copies the specified slice into the buffer.
/// If the buffer is multi-dimensional, the elements in the slice are expected to be in Fortran-style order.
///
@ -473,7 +474,7 @@ impl PyBuffer {
pub fn copy_from_fortran_slice<T: Element+Copy>(&self, py: Python, source: &[T]) -> PyResult<()> {
self.copy_from_slice_impl(py, source, b'F')
}
fn copy_from_slice_impl<T: Element+Copy>(&self, py: Python, source: &[T], fort: u8) -> PyResult<()> {
if self.readonly() {
return buffer_readonly_error(py);
@ -609,7 +610,7 @@ mod test {
assert_eq!(arr, b"abcde" as &[u8]);
assert!(buffer.copy_from_slice(py, &[0u8; 5]).is_err());
assert!(buffer.to_vec::<i8>(py).is_err());
assert!(buffer.to_vec::<u16>(py).is_err());
assert_eq!(buffer.to_vec::<u8>(py).unwrap(), b"abcde");
@ -635,7 +636,7 @@ mod test {
assert_eq!(slice.len(), 4);
assert_eq!(slice[0].get(), 1.0);
assert_eq!(slice[3].get(), 2.5);
let mut_slice = buffer.as_mut_slice::<f32>(py).unwrap();
assert_eq!(mut_slice.len(), 4);
assert_eq!(mut_slice[0].get(), 1.0);

View File

@ -1,5 +1,7 @@
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Python object protocols
#[macro_use] mod macros;
pub mod async;

View File

@ -1,3 +1,4 @@
//! Rust FFI declarations for Python 2
#![no_std]
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]

View File

@ -1,3 +1,4 @@
//! Rust FFI declarations for Python 3
#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)]
#![cfg_attr(Py_LIMITED_API, allow(unused_imports))]

View File

@ -1,4 +1,6 @@
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Free allocation list
use std;
use ffi;

View File

@ -143,6 +143,7 @@ mod ffi2;
#[cfg(Py_3)]
mod ffi3;
/// Rust FFI declarations for Python
pub mod ffi {
#[cfg(not(Py_3))]
pub use ffi2::*;
@ -164,6 +165,7 @@ pub use conversion::{FromPyObject, ToPyObject, IntoPyObject, IntoPyTuple};
pub mod class;
pub use class::*;
/// Procedural macros
pub mod py {
pub use pyo3cls::*;

View File

@ -1,5 +1,7 @@
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Python type object information
use std;
use std::mem;
use std::ffi::{CStr, CString};