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

gstring: Add fmt::Debug bounds #1185

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 9 additions & 9 deletions glib/src/gstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,9 +1299,9 @@ macro_rules! gformat {
/// `T` is the type of the value the conversion was attempted from.
#[derive(thiserror::Error, Clone, PartialEq, Eq, Debug)]
#[error("data provided is not nul terminated")]
pub struct GStringNoTrailingNulError<T>(T);
pub struct GStringNoTrailingNulError<T: fmt::Debug>(T);

impl<T> GStringNoTrailingNulError<T> {
impl<T: fmt::Debug> GStringNoTrailingNulError<T> {
// rustdoc-stripper-ignore-next
/// Returns the original value that was attempted to convert to [`GString`].
#[inline]
Expand All @@ -1316,9 +1316,9 @@ impl<T> GStringNoTrailingNulError<T> {
/// `T` is the type of the value the conversion was attempted from.
#[derive(thiserror::Error, Clone, PartialEq, Eq, Debug)]
#[error("{1}")]
pub struct GStringInteriorNulError<T>(T, GStrInteriorNulError);
pub struct GStringInteriorNulError<T: std::fmt::Debug>(T, GStrInteriorNulError);

impl<T> GStringInteriorNulError<T> {
impl<T: std::fmt::Debug> GStringInteriorNulError<T> {
// rustdoc-stripper-ignore-next
/// Returns the original value that was attempted to convert to [`GString`].
#[inline]
Expand All @@ -1339,9 +1339,9 @@ impl<T> GStringInteriorNulError<T> {
/// `T` is the type of the value the conversion was attempted from.
#[derive(thiserror::Error, Clone, PartialEq, Eq, Debug)]
#[error("{1}")]
pub struct GStringUtf8Error<T>(T, std::str::Utf8Error);
pub struct GStringUtf8Error<T: fmt::Debug>(T, std::str::Utf8Error);

impl<T> GStringUtf8Error<T> {
impl<T: fmt::Debug> GStringUtf8Error<T> {
// rustdoc-stripper-ignore-next
/// Returns the original value that was attempted to convert to [`GString`].
#[inline]
Expand All @@ -1360,7 +1360,7 @@ impl<T> GStringUtf8Error<T> {
// rustdoc-stripper-ignore-next
/// Error type holding all possible failures when creating a [`GString`].
#[derive(thiserror::Error, Debug)]
pub enum GStringFromError<T> {
pub enum GStringFromError<T: fmt::Debug> {
#[error(transparent)]
NoTrailingNul(#[from] GStringNoTrailingNulError<T>),
#[error(transparent)]
Expand All @@ -1371,7 +1371,7 @@ pub enum GStringFromError<T> {
Unspecified(T),
}

impl<T> GStringFromError<T> {
impl<T: fmt::Debug> GStringFromError<T> {
pub fn into_inner(self) -> T {
match self {
Self::NoTrailingNul(GStringNoTrailingNulError(t)) => t,
Expand All @@ -1381,7 +1381,7 @@ impl<T> GStringFromError<T> {
}
}
#[inline]
fn convert<R>(self, func: impl FnOnce(T) -> R) -> GStringFromError<R> {
fn convert<R: fmt::Debug>(self, func: impl FnOnce(T) -> R) -> GStringFromError<R> {
match self {
Self::NoTrailingNul(GStringNoTrailingNulError(t)) => {
GStringFromError::NoTrailingNul(GStringNoTrailingNulError(func(t)))
Expand Down
Loading