blob: e932a9c29ea6a0d25e19620c7ce424042c0e09cb [file] [log] [blame]
Graydon Hoared1affff2012-12-11 01:32:481// 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.
4//
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.
10
Corey Richardsondee11072013-12-17 21:40:3311#[crate_id="issue_2526#0.2"];
Tim Chevalier6f95c792012-06-13 18:20:2112#[crate_type = "lib"];
13
Patrick Walton1be40be2013-05-21 00:07:2414extern mod extra;
Tim Chevalier6f95c792012-06-13 18:20:2115
Patrick Walton6ce74462013-01-28 18:46:4316struct arc_destruct<T> {
Brian Anderson2572e802012-09-07 02:40:1517 _data: int,
Ben Striegelf4a5a762012-11-14 06:22:3718}
19
Patrick Waltond4fee242013-03-21 01:18:5720#[unsafe_destructor]
Patrick Walton1eec3bb2013-06-05 22:53:1721impl<T:Freeze> Drop for arc_destruct<T> {
Daniel Micay4e161a42013-09-17 01:18:0722 fn drop(&mut self) {}
Tim Chevalier588c1eb2012-06-22 20:11:2923}
Tim Chevalier6f95c792012-06-13 18:20:2124
Patrick Walton1eec3bb2013-06-05 22:53:1725fn arc_destruct<T:Freeze>(data: int) -> arc_destruct<T> {
Brian Andersonb4e547d2012-09-05 22:58:4326 arc_destruct {
27 _data: data
28 }
29}
30
Patrick Walton1eec3bb2013-06-05 22:53:1731fn arc<T:Freeze>(_data: T) -> arc_destruct<T> {
Tim Chevalier6f95c792012-06-13 18:20:2132 arc_destruct(0)
33}
34
Graydon Hoare721c1742013-01-24 00:28:1035fn init() -> arc_destruct<context_res> {
Erick Tryzelaarad5c6762013-08-17 15:37:4236 arc(context_res())
Tim Chevalier6f95c792012-06-13 18:20:2137}
38
Brian Anderson3ab4b012012-08-16 01:46:5539struct context_res {
Brian Anderson2572e802012-09-07 02:40:1540 ctx : int,
Ben Striegelf4a5a762012-11-14 06:22:3741}
Tim Chevalier6f95c792012-06-13 18:20:2142
Patrick Walton91436882013-02-14 19:47:0043impl Drop for context_res {
Daniel Micay4e161a42013-09-17 01:18:0744 fn drop(&mut self) {}
Tim Chevalier6f95c792012-06-13 18:20:2145}
46
Brian Andersonb4e547d2012-09-05 22:58:4347fn context_res() -> context_res {
48 context_res {
49 ctx: 0
50 }
51}
52
Patrick Walton49472ec2013-01-31 01:20:0253pub type context = arc_destruct<context_res>;