Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Apr 27, 2024
1 parent a0ab1b9 commit 7730e16
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
11 changes: 8 additions & 3 deletions slinky/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use std::{fs, path::Path};
use serde::Deserialize;

use crate::{
absent_nullable::AbsentNullable, segment::SegmentSerial, settings::SettingsSerial, vram_class::VramClassSerial, Segment, Settings, SlinkyError, VramClass
absent_nullable::AbsentNullable, segment::SegmentSerial, settings::SettingsSerial,
vram_class::VramClassSerial, Segment, Settings, SlinkyError, VramClass,
};

#[derive(PartialEq, Debug)]
Expand Down Expand Up @@ -74,14 +75,18 @@ impl DocumentSerial {
for c in v {
vram_classes.push(c.unserialize(&settings)?);
}
},
}
}

let mut segments = Vec::with_capacity(self.segments.len());
for seg in self.segments {
segments.push(seg.unserialize(&settings)?);
}

Ok(Document { settings, vram_classes, segments })
Ok(Document {
settings,
vram_classes,
segments,
})
}
}
1 change: 0 additions & 1 deletion slinky/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub use file_info::FileInfo;
pub use file_kind::FileKind;
pub use segment::Segment;


pub use vram_class::VramClass;

pub use document::Document;
Expand Down
16 changes: 8 additions & 8 deletions slinky/src/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ impl SegmentSerial {
.follows_segment
.get_optional_nullable("follows_segment", || None)?;

let vram_class = self.vram_class.get_optional_nullable("vram_class", || None)?;
let vram_class = self
.vram_class
.get_optional_nullable("vram_class", || None)?;

if fixed_vram.is_some() {
if follows_segment.is_some() {
Expand All @@ -119,13 +121,11 @@ impl SegmentSerial {
}
}

if follows_segment.is_some() {
if vram_class.is_some() {
return Err(SlinkyError::InvalidFieldCombo {
field1: "follows_segment".to_string(),
field2: "vram_class".to_string(),
});
}
if follows_segment.is_some() && vram_class.is_some() {
return Err(SlinkyError::InvalidFieldCombo {
field1: "follows_segment".to_string(),
field2: "vram_class".to_string(),
});
}

let alloc_sections = self
Expand Down
8 changes: 6 additions & 2 deletions slinky/src/vram_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ impl VramClassSerial {
.fixed_vram
.get_optional_nullable("fixed_vram", || None)?;

let follows_classes = self.follows_classes.get_non_null("follows_classes", || Vec::new())?;
let follows_classes = self
.follows_classes
.get_non_null("follows_classes", Vec::new)?;

if fixed_vram.is_some() && !follows_classes.is_empty() {
return Err(SlinkyError::InvalidFieldCombo {
Expand All @@ -49,7 +51,9 @@ impl VramClassSerial {
}

if fixed_vram.is_none() && follows_classes.is_empty() {
return Err(SlinkyError::MissingAnyOfOptionalFields { fields: "'fixed_vram', 'follows_classes'".into() })
return Err(SlinkyError::MissingAnyOfOptionalFields {
fields: "'fixed_vram', 'follows_classes'".into(),
});
}

Ok(VramClass {
Expand Down

0 comments on commit 7730e16

Please sign in to comment.