-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: require docs on all public APIs
- Loading branch information
1 parent
3af18ea
commit b419fb0
Showing
16 changed files
with
123 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ rustflags = [ | |
"-Delided_lifetimes_in_paths", | ||
"-Dunused_lifetimes", | ||
"-Drust_2021_prelude_collisions" | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![allow(missing_docs)] | ||
//! Crate-private implementation of pycell | ||
use std::cell::Cell; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::os::raw::{c_int, c_void}; | ||
|
||
use crate::{ffi, AsPyPointer, Python}; | ||
|
||
/// Error returned by a `__traverse__` visitor implementation. | ||
#[repr(transparent)] | ||
pub struct PyTraverseError(pub(crate) c_int); | ||
|
||
/// Object visitor for GC. | ||
#[derive(Clone)] | ||
pub struct PyVisit<'p> { | ||
pub(crate) visit: ffi::visitproc, | ||
pub(crate) arg: *mut c_void, | ||
/// VisitProc contains a Python instance to ensure that | ||
/// 1) it is cannot be moved out of the traverse() call | ||
/// 2) it cannot be sent to other threads | ||
pub(crate) _py: Python<'p>, | ||
} | ||
|
||
impl<'p> PyVisit<'p> { | ||
/// Visit `obj`. | ||
pub fn call<T>(&self, obj: &T) -> Result<(), PyTraverseError> | ||
where | ||
T: AsPyPointer, | ||
{ | ||
let r = unsafe { (self.visit)(obj.as_ptr(), self.arg) }; | ||
if r == 0 { | ||
Ok(()) | ||
} else { | ||
Err(PyTraverseError(r)) | ||
} | ||
} | ||
|
||
/// Creates the PyVisit from the arguments to tp_traverse | ||
#[doc(hidden)] | ||
pub unsafe fn from_raw(visit: ffi::visitproc, arg: *mut c_void, _py: Python<'p>) -> Self { | ||
Self { visit, arg, _py } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters