Commit 377286b4 authored by Arthur Carlsson's avatar Arthur Carlsson

rustfmt

parent d7bf97b3
Pipeline #25843568 passed with stage
in 7 minutes and 2 seconds
use byteorder::BigEndian;
use cpu::mem;
pub enum Cart {
}
pub enum Cart {}
impl Cart {
pub fn new(buf: Vec<u8>) -> mem::Mem<Cart> {
let buf = match buf[0] {
0x37 => mem::byte_swap(buf.clone()),
0x40 => mem::endian_swap(buf.clone()),
_ => buf
_ => buf,
};
mem::Mem::new(buf)
......
......@@ -33,10 +33,13 @@ pub trait Write {
pub struct Mem<T> {
buf: Vec<u8>,
phantom: PhantomData<T>
phantom: PhantomData<T>,
}
impl<T> ReadOnly for T where T: ReadWrite {
impl<T> ReadOnly for T
where
T: ReadWrite,
{
type ByteOrder = T::ByteOrder;
}
......@@ -45,7 +48,7 @@ impl<T> Mem<T> {
pub fn new(data: Vec<u8>) -> Self {
Self {
buf: data,
phantom: PhantomData
phantom: PhantomData,
}
}
......@@ -53,7 +56,7 @@ impl<T> Mem<T> {
pub fn with_capacity(size: usize) -> Self {
Self {
buf: vec![0xab; size],
phantom: PhantomData
phantom: PhantomData,
}
}
......@@ -64,7 +67,10 @@ impl<T> Mem<T> {
}
}
impl<T> Read for Mem<T> where T: ReadOnly {
impl<T> Read for Mem<T>
where
T: ReadOnly,
{
fn readb(&self, addr: u32) -> u8 {
self.buf[addr as usize]
}
......@@ -74,7 +80,10 @@ impl<T> Read for Mem<T> where T: ReadOnly {
}
}
impl<T> Write for Mem<T> where T: ReadWrite {
impl<T> Write for Mem<T>
where
T: ReadWrite,
{
fn writeb(&mut self, addr: u32, byte: u8) {
self.buf[addr as usize] = byte
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment