Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent impl for &T, Rc<T>, and Arc<T> #145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions pyo3-stub-gen/src/stub_type/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use std::{
borrow::Cow,
ffi::{OsStr, OsString},
path::PathBuf,
rc::Rc,
sync::Arc,
time::SystemTime,
};

Expand Down Expand Up @@ -88,3 +90,30 @@ impl_with_module!(FixedOffset, "datetime.tzinfo", "datetime");
impl_with_module!(Utc, "datetime.tzinfo", "datetime");
impl_with_module!(std::time::Duration, "datetime.timedelta", "datetime");
impl_with_module!(chrono::Duration, "datetime.timedelta", "datetime");

impl<T: PyStubType> PyStubType for &T {
fn type_input() -> TypeInfo {
T::type_input()
}
fn type_output() -> TypeInfo {
T::type_output()
}
}

impl<T: PyStubType> PyStubType for Rc<T> {
fn type_input() -> TypeInfo {
T::type_input()
}
fn type_output() -> TypeInfo {
T::type_output()
}
}

impl<T: PyStubType> PyStubType for Arc<T> {
fn type_input() -> TypeInfo {
T::type_input()
}
fn type_output() -> TypeInfo {
T::type_output()
}
}
9 changes: 0 additions & 9 deletions pyo3-stub-gen/src/stub_type/collections.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
use crate::stub_type::*;
use std::collections::{BTreeMap, BTreeSet, HashMap};

impl<T: PyStubType> PyStubType for &T {
fn type_input() -> TypeInfo {
T::type_input()
}
fn type_output() -> TypeInfo {
T::type_output()
}
}

impl<T: PyStubType> PyStubType for Option<T> {
fn type_input() -> TypeInfo {
let TypeInfo { name, mut import } = T::type_input();
Expand Down
Loading