update code for new idioms

png-branch
an 2018-12-11 02:33:38 -05:00
parent 2a3dd59570
commit 932ec1a668
6 changed files with 11 additions and 31 deletions

View File

@ -42,14 +42,13 @@ impl BinUtil for [u8]
fn c_u32b(&self, i: usize) -> ResultS<u32>
{
if i + 3 >= self.len() {return Err("not enough data")}
Ok(self[i ] as (u32) << 24 | self[i+1] as (u32) << 16 |
self[i+2] as (u32) << 8 | self[i+3] as (u32))
Ok(u32::from_be_bytes([self[i], self[i+1], self[i+2], self[i+3]]))
}
fn c_u16b(&self, i: usize) -> ResultS<u16>
{
if i + 1 >= self.len() {return Err("not enough data")}
Ok(self[i] as (u16) << 8 | self[i+1] as (u16))
Ok(u16::from_be_bytes([self[i], self[i+1]]))
}
}

View File

@ -3,8 +3,7 @@
use std::ops::{Index, IndexMut};
/// RGBA8 color.
#[derive(Clone)]
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct Color
{
pub r: u8,

View File

@ -1,10 +1,8 @@
//! QuickDraw PICT format loader.
use crate::durandal::{bin::*, image::*};
use generic_array::*;
use crate::durandal::image::*;
use crate::durandal::bin::*;
const PACK_DEFAULT: u16 = 0;
const PACK_NONE : u16 = 1;
const PACK_NOPAD : u16 = 2;

View File

@ -1,20 +1,10 @@
extern crate memmap;
extern crate generic_array;
pub mod durandal;
pub mod marathon;
use std::{io, fs, env};
use std::io::Write;
use crate::durandal::pict::load_pict;
use crate::durandal::image::Image;
use crate::durandal::{bin::ResultS, image::Image, pict::load_pict};
use crate::marathon::{wad, term};
use memmap::Mmap;
use crate::durandal::bin::ResultS;
use std::{io, io::Write, fs, env};
#[derive(Debug)]
struct Minf

View File

@ -1,8 +1,6 @@
use crate::durandal::{bin::*, text::*};
use std::fmt;
use crate::durandal::text::*;
use crate::durandal::bin::*;
impl Terminal
{
pub fn read(b: &[u8]) -> ResultS<(usize, Terminal)>

View File

@ -1,11 +1,7 @@
//! Marathon Wad format handling.
use std::collections::BTreeMap;
use std::fmt;
use crate::durandal::bin::*;
use crate::durandal::machead::try_mac_header;
use crate::durandal::text::mac_roman_conv;
use crate::durandal::{bin::*, machead::try_mac_header, text::mac_roman_conv};
use std::{collections::BTreeMap, fmt};
type Chunk <'a> = &'a[u8];
type ChunkMap<'a> = BTreeMap<Ident, Chunk<'a>>;
@ -36,7 +32,7 @@ pub enum Ver
MI
}
impl<'a> fmt::Debug for Entry<'a>
impl fmt::Debug for Entry<'_>
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
{
@ -46,7 +42,7 @@ impl<'a> fmt::Debug for Entry<'a>
}
}
impl<'a> Wad<'a>
impl Wad<'_>
{
pub fn new(b: &[u8]) -> ResultS<Wad>
{