mirror of
https://github.com/encounter/object.git
synced 2026-07-10 12:18:39 -07:00
macho: simplify SectionFlags construction in const expressions
This commit is contained in:
+9
-2
@@ -1590,8 +1590,8 @@ impl SectionFlags {
|
||||
}
|
||||
|
||||
/// Set the section type field.
|
||||
pub fn with_type(self, typ: SectionType) -> SectionFlags {
|
||||
SectionFlags(self.0 & !SECTION_TYPE | u32::from(typ.0))
|
||||
pub const fn with_type(self, typ: SectionType) -> SectionFlags {
|
||||
SectionFlags(self.0 & !SECTION_TYPE | typ.0 as u32)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1600,6 +1600,13 @@ newtype!(
|
||||
struct SectionType(u8);
|
||||
);
|
||||
|
||||
impl SectionType {
|
||||
/// Convert to a `SectionFlags` with no attributes, for use in const expressions.
|
||||
pub const fn to_flags(self) -> SectionFlags {
|
||||
SectionFlags(self.0 as u32)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SectionType> for SectionFlags {
|
||||
fn from(typ: SectionType) -> Self {
|
||||
SectionFlags(u32::from(typ.0))
|
||||
|
||||
Reference in New Issue
Block a user