mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 14:56:42 +00:00
Cleaner implementation of Debug for extensions structs
This commit is contained in:
parent
948ecc0fb7
commit
f536b9db60
@ -11,6 +11,7 @@ use std::error;
|
||||
use std::ffi::CString;
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
use std::str;
|
||||
|
||||
use Error;
|
||||
use OomError;
|
||||
@ -22,7 +23,7 @@ use check_errors;
|
||||
macro_rules! extensions {
|
||||
($sname:ident, $($ext:ident => $s:expr,)*) => (
|
||||
/// List of extensions that are enabled or available.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct $sname {
|
||||
$(
|
||||
@ -64,6 +65,25 @@ macro_rules! extensions {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for $sname {
|
||||
#[allow(unused_assignments)]
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(write!(f, "["));
|
||||
|
||||
let mut first = true;
|
||||
|
||||
$(
|
||||
if self.$ext {
|
||||
if !first { try!(write!(f, ", ")); }
|
||||
else { first = false; }
|
||||
try!(f.write_str(str::from_utf8($s).unwrap()));
|
||||
}
|
||||
)*
|
||||
|
||||
write!(f, "]")
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user