updates for rust 1.34

gui-branch
an 2019-04-11 16:01:39 -04:00
parent 4447897302
commit 959930cede
4 changed files with 19 additions and 19 deletions

View File

@ -7,9 +7,8 @@ homepage = "https://greyserv.net/maraiah/"
repository = "http://git.greyserv.net/marrub/Maraiah"
readme = "README.md"
license = "CC0-1.0"
edition = "2018"
publish = false
edition = "2018"
publish = false
[features]
serde_obj = ["serde"]

View File

@ -1,7 +1,7 @@
//! Binary data conversion utilities.
use crate::durandal::err::*;
use std::{fmt, num::NonZeroU16};
use std::{convert::{TryFrom, TryInto}, fmt, num::NonZeroU16};
#[doc(hidden)]
#[macro_export]
@ -161,8 +161,6 @@ macro_rules! rd_impl {
/// ```
/// # #[macro_use] extern crate maraiah;
/// # use maraiah::durandal::err::*;
/// # fn main() -> ResultS<()>
/// # {
/// let buffer = &[4, 0, 2, 0, 0, 0, 6];
///
/// read_data! {
@ -178,8 +176,7 @@ macro_rules! rd_impl {
/// assert_eq!(two, 2_u32);
/// assert_eq!(six, 6_u8);
/// assert_eq!(byte, &[2, 0, 0, 0]);
/// # Ok(())
/// # }
/// # Ok(())
/// ```
#[macro_export]
macro_rules! read_data {
@ -205,7 +202,12 @@ macro_rules! check_data {
};
}
/// Casts a `u32` to a `usize`. For future compatibility.
/// Casts a `u32` to a `usize`.
///
/// # Panics
///
/// Will panic if the platform does not have a 32-bit `usize`. In this case,
/// the application is not supported, but will still run and panic at runtime.
///
/// # Examples
///
@ -215,7 +217,7 @@ macro_rules! check_data {
/// assert_eq!(usize_from_u32(777u32), 777usize);
/// ```
#[inline]
pub const fn usize_from_u32(n: u32) -> usize {n as usize}
pub fn usize_from_u32(n: u32) -> usize {usize::try_from(n).unwrap()}
/// Creates an `Ident` from a slice.
///
@ -231,7 +233,7 @@ pub const fn usize_from_u32(n: u32) -> usize {n as usize}
/// assert_eq!(ident(b"POLY"), Ident([b'P', b'O', b'L', b'Y']));
/// ```
#[inline]
pub const fn ident(b: &[u8]) -> Ident {Ident([b[0], b[1], b[2], b[3]])}
pub fn ident(b: &[u8]) -> Ident {Ident(b[0..4].try_into().unwrap())}
/// Applies `u32::from_be_bytes` to a slice.
///
@ -247,7 +249,7 @@ pub const fn ident(b: &[u8]) -> Ident {Ident([b[0], b[1], b[2], b[3]])}
/// assert_eq!(u32b(&[0x00, 0x0B, 0xDE, 0x31]), 777_777u32);
/// ```
#[inline]
pub fn u32b(b: &[u8]) -> u32 {u32::from_be_bytes([b[0], b[1], b[2], b[3]])}
pub fn u32b(b: &[u8]) -> u32 {u32::from_be_bytes(b[0..4].try_into().unwrap())}
/// Applies `u16::from_be_bytes` to a slice.
///
@ -263,7 +265,7 @@ pub fn u32b(b: &[u8]) -> u32 {u32::from_be_bytes([b[0], b[1], b[2], b[3]])}
/// assert_eq!(u16b(&[0x1E, 0x61]), 7_777u16);
/// ```
#[inline]
pub fn u16b(b: &[u8]) -> u16 {u16::from_be_bytes([b[0], b[1]])}
pub fn u16b(b: &[u8]) -> u16 {u16::from_be_bytes(b[0..2].try_into().unwrap())}
/// Applies `i32::from_be_bytes` to a slice.
///
@ -279,7 +281,7 @@ pub fn u16b(b: &[u8]) -> u16 {u16::from_be_bytes([b[0], b[1]])}
/// assert_eq!(i32b(&[0xFF, 0x89, 0x52, 0x0F]), -7_777_777i32);
/// ```
#[inline]
pub fn i32b(b: &[u8]) -> i32 {i32::from_be_bytes([b[0], b[1], b[2], b[3]])}
pub fn i32b(b: &[u8]) -> i32 {i32::from_be_bytes(b[0..4].try_into().unwrap())}
/// Applies `i16::from_be_bytes` to a slice.
///
@ -295,7 +297,7 @@ pub fn i32b(b: &[u8]) -> i32 {i32::from_be_bytes([b[0], b[1], b[2], b[3]])}
/// assert_eq!(i16b(&[0xE1, 0x9F]), -7_777i16);
/// ```
#[inline]
pub fn i16b(b: &[u8]) -> i16 {i16::from_be_bytes([b[0], b[1]])}
pub fn i16b(b: &[u8]) -> i16 {i16::from_be_bytes(b[0..2].try_into().unwrap())}
/// Applies a read function over a slice.
///

View File

@ -144,7 +144,7 @@ fn stream_dynamic(v: &mut Vec<u8>, b: &[u8], mut p: usize) -> ResultS<usize>
let hclen = read_bits_l(b, p, 4)?;
p += 4;
let hlit = 257 + hlit as usize;
let hlit = 257 + hlit as usize;
let hdist = 1 + hdist as usize;
let hclen = 4 + hclen as usize;

View File

@ -3,9 +3,8 @@ name = "maraiah-tycho"
version = "0.1.0"
authors = ["Alison Sanderson <marrub@greyserv.net>"]
description = "Tycho map editor."
edition = "2018"
build = "build.rs"
edition = "2018"
build = "build.rs"
[dependencies]
atk-sys = "0.8"