Add reformat to the CI (#21)

This commit is contained in:
John Nunley 2022-12-22 12:35:18 -08:00 committed by GitHub
parent df091d59dd
commit 5674886dfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 112 additions and 78 deletions

View file

@ -1,5 +1,5 @@
use std::error::Error;
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
use std::error::Error;
use thiserror::Error;
#[derive(Error, Debug)]
@ -12,7 +12,7 @@ pub enum SwBufError {
human_readable_window_platform_name: &'static str,
human_readable_display_platform_name: &'static str,
window_handle: RawWindowHandle,
display_handle: RawDisplayHandle
display_handle: RawDisplayHandle,
},
#[error("The provided window handle is null.")]
@ -22,13 +22,19 @@ pub enum SwBufError {
IncompleteDisplayHandle,
#[error("Platform error")]
PlatformError(Option<String>, Option<Box<dyn Error>>)
PlatformError(Option<String>, Option<Box<dyn Error>>),
}
#[allow(unused)] // This isn't used on all platforms
pub(crate) fn unwrap<T, E: std::error::Error + 'static>(res: Result<T, E>, str: &str) -> Result<T, SwBufError>{
match res{
pub(crate) fn unwrap<T, E: std::error::Error + 'static>(
res: Result<T, E>,
str: &str,
) -> Result<T, SwBufError> {
match res {
Ok(t) => Ok(t),
Err(e) => Err(SwBufError::PlatformError(Some(str.into()), Some(Box::new(e))))
Err(e) => Err(SwBufError::PlatformError(
Some(str.into()),
Some(Box::new(e)),
)),
}
}