pub struct ClassVersion { /* private fields */ }Expand description
The minor and major version numbers stored in a class-file header.
Implementations§
Source§impl ClassVersion
impl ClassVersion
Sourcepub fn minor(self) -> u16
pub fn minor(self) -> u16
Returns the class-file minor version.
Examples found in repository?
examples/disassemble.rs (line 30)
17fn run() -> Result<ExitCode, String> {
18 let path = class_path()?;
19 let file =
20 File::open(&path).map_err(|error| format!("could not open {}: {error}", path.display()))?;
21 let disassembly = Disassembler::default()
22 .parse_reader(file)
23 .map_err(|error| format!("could not parse {}: {error}", path.display()))?;
24
25 let version = disassembly.version();
26 let Some(class) = disassembly.class() else {
27 println!(
28 "partial class file v{}.{}",
29 version.major(),
30 version.minor()
31 );
32 for diagnostic in disassembly.diagnostics() {
33 print_diagnostic(diagnostic);
34 }
35 return Ok(ExitCode::from(2));
36 };
37
38 let output = FerroFormatter
39 .format(class)
40 .map_err(|error| format!("could not format {}: {error}", path.display()))?;
41 print!("{output}");
42
43 Ok(ExitCode::SUCCESS)
44}Sourcepub fn major(self) -> u16
pub fn major(self) -> u16
Returns the class-file major version.
Examples found in repository?
examples/disassemble.rs (line 29)
17fn run() -> Result<ExitCode, String> {
18 let path = class_path()?;
19 let file =
20 File::open(&path).map_err(|error| format!("could not open {}: {error}", path.display()))?;
21 let disassembly = Disassembler::default()
22 .parse_reader(file)
23 .map_err(|error| format!("could not parse {}: {error}", path.display()))?;
24
25 let version = disassembly.version();
26 let Some(class) = disassembly.class() else {
27 println!(
28 "partial class file v{}.{}",
29 version.major(),
30 version.minor()
31 );
32 for diagnostic in disassembly.diagnostics() {
33 print_diagnostic(diagnostic);
34 }
35 return Ok(ExitCode::from(2));
36 };
37
38 let output = FerroFormatter
39 .format(class)
40 .map_err(|error| format!("could not format {}: {error}", path.display()))?;
41 print!("{output}");
42
43 Ok(ExitCode::SUCCESS)
44}Trait Implementations§
Source§impl Clone for ClassVersion
impl Clone for ClassVersion
Source§fn clone(&self) -> ClassVersion
fn clone(&self) -> ClassVersion
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ClassVersion
Source§impl Debug for ClassVersion
impl Debug for ClassVersion
impl Eq for ClassVersion
Source§impl PartialEq for ClassVersion
impl PartialEq for ClassVersion
impl StructuralPartialEq for ClassVersion
Auto Trait Implementations§
impl Freeze for ClassVersion
impl RefUnwindSafe for ClassVersion
impl Send for ClassVersion
impl Sync for ClassVersion
impl Unpin for ClassVersion
impl UnsafeUnpin for ClassVersion
impl UnwindSafe for ClassVersion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more