Skip to content

Commit

Permalink
Update to 2018 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Apr 30, 2019
1 parent 83c3547 commit c827282
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 36 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ language: rust

matrix:
include:
- rust: 1.15.0
- rust: 1.31.0
- rust: stable
- rust: beta
- rust: nightly

script:
- |
case "$TRAVIS_RUST_VERSION" in
1.15.0)
cargo build
;;
nightly)
cargo test
cargo clean
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "ref-cast"
version = "0.2.5" # remember to update html_root_url
authors = ["David Tolnay <[email protected]>"]
edition = "2018"
license = "MIT/Apache-2.0"
description = "Safely cast &T to &U where the struct U contains a single field of type T."
repository = "https://github.com/dtolnay/ref-cast"
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ ref-cast = "0.2"
## Basic example

```rust
#[macro_use]
extern crate ref_cast;
use ref_cast::RefCast;

#[derive(RefCast)]
Expand Down
2 changes: 1 addition & 1 deletion compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ name = "ref-cast-compiletest"
path = "main.rs"

[dependencies]
compiletest_rs = { version = "0.3", features = ["stable"] }
compiletest = { package = "compiletest_rs", version = "0.3", features = ["stable"] }
ref-cast = { path = ".." }
2 changes: 0 additions & 2 deletions compiletest/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![cfg(test)]

extern crate compiletest_rs as compiletest;

#[test]
fn compile_fail() {
let mut config = compiletest::Config {
Expand Down
1 change: 1 addition & 0 deletions derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "ref-cast-impl"
version = "0.2.5"
authors = ["David Tolnay <[email protected]>"]
edition = "2018"
license = "MIT/Apache-2.0"
description = "Derive implementation for ref_cast::RefCast."
repository = "https://github.com/dtolnay/ref-cast"
Expand Down
14 changes: 3 additions & 11 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#![recursion_limit = "128"]

extern crate proc_macro;
use proc_macro::TokenStream;

#[macro_use]
extern crate syn;

#[macro_use]
extern crate quote;

use syn::{Data, DeriveInput, Fields, Meta, NestedMeta, Type};
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, Data, DeriveInput, Fields, Meta, NestedMeta, Type};

#[proc_macro_derive(RefCast)]
pub fn derive_ref_cast(input: TokenStream) -> TokenStream {
Expand All @@ -29,8 +24,6 @@ pub fn derive_ref_cast(input: TokenStream) -> TokenStream {

#[inline]
fn ref_cast(_from: &Self::From) -> &Self {
extern crate core as _core;

// TODO: assert that `Self::From` and `Self` have the same size
// and alignment.
//
Expand Down Expand Up @@ -58,7 +51,6 @@ pub fn derive_ref_cast(input: TokenStream) -> TokenStream {

#[inline]
fn ref_cast_mut(_from: &mut Self::From) -> &mut Self {
extern crate core as _core;
unsafe {
&mut *(_from as *mut Self::From as *mut Self)
}
Expand Down
22 changes: 6 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! # Basic example
//!
//! ```rust
//! #[macro_use]
//! extern crate ref_cast;
//! ```
//! use ref_cast::RefCast;
//!
//! #[derive(RefCast)]
Expand All @@ -24,7 +22,7 @@
//! operation that works in column-major order because it is more intuitive in
//! the context of our application.
//!
//! ```rust
//! ```
//! const MAP_WIDTH: usize = 4;
//!
//! struct Tile(u8);
Expand All @@ -42,7 +40,7 @@
//!
//! [`Index`]: https://doc.rust-lang.org/std/ops/trait.Index.html
//!
//! ```rust
//! ```
//! # const MAP_WIDTH: usize = 4;
//! #
//! # struct Tile(u8);
Expand Down Expand Up @@ -90,11 +88,8 @@
//!
//! Here is a working approach using `RefCast`.
//!
//! ```rust
//! # #[macro_use]
//! # extern crate ref_cast;
//! ```
//! # use ref_cast::RefCast;
//! #
//! # use std::ops::Index;
//! #
//! # const MAP_WIDTH: usize = 4;
Expand Down Expand Up @@ -130,19 +125,14 @@
#![doc(html_root_url = "https://docs.rs/ref-cast/0.2.5")]

#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
#[allow(unused_imports)]
#[macro_use]
extern crate ref_cast_impl;
#[doc(hidden)]
pub use ref_cast_impl::*;

/// Safely cast `&T` to `&U` where the struct `U` contains a single field of
/// type `T`.
///
/// ```rust
/// # #[macro_use]
/// # extern crate ref_cast;
/// ```
/// # use ref_cast::RefCast;
/// #
/// // `&String` can be cast to `&U`.
/// #[derive(RefCast)]
Expand Down

0 comments on commit c827282

Please sign in to comment.