Skip to content

Commit

Permalink
Merge pull request #131 from bluss/rust-2018
Browse files Browse the repository at this point in the history
Update to Rust 2018
  • Loading branch information
bluss committed Sep 17, 2019
2 parents c7424b8 + 0622478 commit 75a6fcd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "arrayvec"
version = "0.4.11"
authors = ["bluss"]
license = "MIT/Apache-2.0"
edition = "2018"

description = "A vector with fixed capacity, backed by an array (it can be stored on the stack too). Implements fixed capacity ArrayVec and ArrayString."
documentation = "https://docs.rs/arrayvec/"
Expand Down
2 changes: 1 addition & 1 deletion src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub unsafe trait Array {

pub trait Index : PartialEq + Copy {
fn to_usize(self) -> usize;
fn from(usize) -> Self;
fn from(_: usize) -> Self;
}

impl Index for () {
Expand Down
10 changes: 5 additions & 5 deletions src/array_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use std::str::FromStr;
use std::str::Utf8Error;
use std::slice;

use array::Array;
use array::Index;
use CapacityError;
use char::encode_utf8;
use crate::array::Array;
use crate::array::Index;
use crate::CapacityError;
use crate::char::encode_utf8;

#[cfg(feature="serde-1")]
use serde::{Serialize, Deserialize, Serializer, Deserializer};
Expand Down Expand Up @@ -559,7 +559,7 @@ impl<'de, A> Deserialize<'de> for ArrayString<A>
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
where E: de::Error,
{
let s = try!(str::from_utf8(v).map_err(|_| E::invalid_value(de::Unexpected::Bytes(v), &self)));
let s = str::from_utf8(v).map_err(|_| E::invalid_value(de::Unexpected::Bytes(v), &self))?;

ArrayString::from(s).map_err(|_| E::invalid_length(s.len(), &self))
}
Expand Down
15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
//!
#![doc(html_root_url="https://docs.rs/arrayvec/0.4/")]
#![cfg_attr(not(feature="std"), no_std)]
#![cfg_attr(has_union_feature, feature(untagged_unions))]

#[cfg(feature="serde-1")]
extern crate serde;
Expand Down Expand Up @@ -48,7 +47,7 @@ use std::io;


mod maybe_uninit;
use maybe_uninit::MaybeUninit;
use crate::maybe_uninit::MaybeUninit;

#[cfg(feature="serde-1")]
use serde::{Serialize, Deserialize, Serializer, Deserializer};
Expand All @@ -59,11 +58,11 @@ mod char;
mod range;
mod errors;

pub use array::Array;
pub use range::RangeArgument;
use array::Index;
pub use array_string::ArrayString;
pub use errors::CapacityError;
pub use crate::array::Array;
pub use crate::range::RangeArgument;
use crate::array::Index;
pub use crate::array_string::ArrayString;
pub use crate::errors::CapacityError;


/// A vector with a fixed capacity.
Expand Down Expand Up @@ -1127,7 +1126,7 @@ impl<'de, T: Deserialize<'de>, A: Array<Item=T>> Deserialize<'de> for ArrayVec<A
{
let mut values = ArrayVec::<A>::new();

while let Some(value) = try!(seq.next_element()) {
while let Some(value) = seq.next_element()? {
if let Err(_) = values.try_push(value) {
return Err(SA::Error::invalid_length(A::CAPACITY + 1, &self));
}
Expand Down
2 changes: 1 addition & 1 deletion src/maybe_uninit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


use array::Array;
use crate::array::Array;
use std::mem::MaybeUninit as StdMaybeUninit;

#[derive(Copy)]
Expand Down
8 changes: 4 additions & 4 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ fn test_extend() {
#[test]
fn test_is_send_sync() {
let data = ArrayVec::<[Vec<i32>; 5]>::new();
&data as &Send;
&data as &Sync;
&data as &dyn Send;
&data as &dyn Sync;
}

#[test]
Expand Down Expand Up @@ -470,9 +470,9 @@ fn test_string() {
assert_eq!(tmut, "ab");

// Test Error trait / try
let t = || -> Result<(), Box<Error>> {
let t = || -> Result<(), Box<dyn Error>> {
let mut t = ArrayString::<[_; 2]>::new();
try!(t.try_push_str(text));
t.try_push_str(text)?;
Ok(())
}();
assert!(t.is_err());
Expand Down

0 comments on commit 75a6fcd

Please sign in to comment.