Fix ref_filter_map tests

This commit is contained in:
Simon Sapin
2016-03-07 16:23:35 +01:00
parent c58ebf84ba
commit b1a12403e5
3 changed files with 19 additions and 6 deletions
+8 -1
View File
@@ -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
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "ref_filter_map"
version = "1.0.0"
version = "1.0.1"
authors = ["Simon Sapin <simon.sapin@exyr.org>"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/SimonSapin/rust-std-candidates"
+10 -4
View File
@@ -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<Result<u32, ()>> = c.borrow();
/// let b2: Ref<u32> = Ref::filter_map(b1, |o| o.as_ref().ok()).unwrap();
/// let b2: Ref<u32> = 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<Result<u32, ()>> = c.borrow_mut();
/// let mut b2: RefMut<u32> = RefMut::filter_map(b1, |o| o.as_mut().ok()).unwrap();
/// let mut b2: RefMut<u32> = ref_mut_filter_map(b1, |o| o.as_mut().ok()).unwrap();
/// assert_eq!(*b2, 5);
/// *b2 = 42;
/// }