From b1a12403e5cdc3024ca51d2179be04e891de5ee8 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 7 Mar 2016 16:23:35 +0100 Subject: [PATCH] Fix ref_filter_map tests --- Makefile | 9 ++++++++- ref_filter_map/Cargo.toml | 2 +- ref_filter_map/lib.rs | 14 ++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0732261..5d7dce1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,13 @@ RUST_CHANNEL ?= nightly -CRATES = matches show text_writer triable return_if_ok string-wrapper ref_filter_map +CRATES = matches show text_writer triable return_if_ok string-wrapper + +# FIXME: Make this unconditional when 1.8 hits the stable channel. +# ref_filter_map uses Ref::map which is stable since 1.8 +ifneq "$(RUST_CHANNEL)" "stable" + CRATES += ref_filter_map +endif + ifeq "$(RUST_CHANNEL)" "nightly" CRATES += zip_longest endif diff --git a/ref_filter_map/Cargo.toml b/ref_filter_map/Cargo.toml index 315069f..28cc7c5 100644 --- a/ref_filter_map/Cargo.toml +++ b/ref_filter_map/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ref_filter_map" -version = "1.0.0" +version = "1.0.1" authors = ["Simon Sapin "] license = "MIT OR Apache-2.0" repository = "https://github.com/SimonSapin/rust-std-candidates" diff --git a/ref_filter_map/lib.rs b/ref_filter_map/lib.rs index cee4459..32c17d4 100644 --- a/ref_filter_map/lib.rs +++ b/ref_filter_map/lib.rs @@ -26,6 +26,12 @@ //! //! Internally they use a raw pointer and some `unsafe` code, //! but the API they provide is believed to be safe. +//! +//! This was once part of `std::cell` but has been deprecated there since it makes `Option` +//! too much of a special case. +//! +//! https://github.com/rust-lang/rust/pull/25747 +//! https://github.com/rust-lang/rust/issues/27746 use std::cell::{Ref, RefMut}; @@ -40,12 +46,12 @@ use std::cell::{Ref, RefMut}; /// # Example /// /// ``` -/// # #![feature(cell_extras)] /// use std::cell::{RefCell, Ref}; +/// use ref_filter_map::ref_filter_map; /// /// let c = RefCell::new(Ok(5)); /// let b1: Ref> = c.borrow(); -/// let b2: Ref = Ref::filter_map(b1, |o| o.as_ref().ok()).unwrap(); +/// let b2: Ref = ref_filter_map(b1, |o| o.as_ref().ok()).unwrap(); /// assert_eq!(*b2, 5) /// ``` pub fn ref_filter_map< @@ -69,13 +75,13 @@ pub fn ref_filter_map< /// # Example /// /// ``` -/// # #![feature(cell_extras)] /// use std::cell::{RefCell, RefMut}; +/// use ref_filter_map::ref_mut_filter_map; /// /// let c = RefCell::new(Ok(5)); /// { /// let b1: RefMut> = c.borrow_mut(); -/// let mut b2: RefMut = RefMut::filter_map(b1, |o| o.as_mut().ok()).unwrap(); +/// let mut b2: RefMut = ref_mut_filter_map(b1, |o| o.as_mut().ok()).unwrap(); /// assert_eq!(*b2, 5); /// *b2 = 42; /// }