Skip to content

Commit

Permalink
Merge branch 'main' into fix/keyword-only-non-default-argument
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanArhancet authored May 14, 2024
2 parents 8106d0a + aed6844 commit 8889628
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
7 changes: 2 additions & 5 deletions src/errors/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,12 @@ fn field_from_context<'py, T: FromPyObject<'py>>(
.map_err(|_| py_error_type!(PyTypeError; "{}: '{}' context value must be a {}", enum_name, field_name, type_name_fn()))
}

fn cow_field_from_context<'py, T: FromPyObject<'py>, B: ?Sized + 'static>(
fn cow_field_from_context<'py, T: FromPyObject<'py>, B: ToOwned<Owned = T> + ?Sized + 'static>(
context: Option<&Bound<'py, PyDict>>,
field_name: &str,
enum_name: &str,
_type_name_fn: fn() -> &'static str,
) -> PyResult<Cow<'static, B>>
where
B: ToOwned<Owned = T>,
{
) -> PyResult<Cow<'static, B>> {
let res: T = field_from_context(context, field_name, enum_name, || {
type_name::<T>().split("::").last().unwrap()
})?;
Expand Down
12 changes: 3 additions & 9 deletions src/serializers/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,17 @@ where
self.serialize_str(variant)
}

fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> Result<Self::Ok>
where
T: Serialize,
{
fn serialize_newtype_struct<T: Serialize + ?Sized>(self, _name: &'static str, value: &T) -> Result<Self::Ok> {
value.serialize(self)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T: Serialize + ?Sized>(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<Self::Ok>
where
T: Serialize,
{
) -> Result<Self::Ok> {
tri!(self
.formatter
.begin_object(&mut self.writer)
Expand Down

0 comments on commit 8889628

Please sign in to comment.