1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // This code used to produce the following ICE:
13 // error: internal compiler error: get_unique_type_id_of_type() -
14 // unexpected type: closure,
15 // TyClosure(syntax::ast::DefId{krate: 0, node: 66},
18 // This is a regression test for issue #17021.
23 #![feature(unboxed_closures)]
27 pub fn replace_map
<'a
, T
, F
>(src
: &mut T
, prod
: F
) where F
: FnOnce(T
) -> T
{
28 unsafe { *src = prod(ptr::read(src as *mut T as *const T)); }
34 replace_map(b
, |x
: usize| x
* 2);