1 // Copyright 2014 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 // Test slicing sugar.
14 use core::ops::{Slice,SliceMut};
16 static mut COUNT: uint = 0;
20 impl Slice<Foo, Foo> for Foo {
21 fn as_slice_<'a>(&'a self) -> &'a Foo {
22 unsafe { COUNT += 1; }
25 fn slice_from_<'a>(&'a self, _from: &Foo) -> &'a Foo {
26 unsafe { COUNT += 1; }
29 fn slice_to_<'a>(&'a self, _to: &Foo) -> &'a Foo {
30 unsafe { COUNT += 1; }
33 fn slice_<'a>(&'a self, _from: &Foo, _to: &Foo) -> &'a Foo {
34 unsafe { COUNT += 1; }
39 impl SliceMut<Foo, Foo> for Foo {
40 fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Foo {
41 unsafe { COUNT += 1; }
44 fn slice_from_mut_<'a>(&'a mut self, _from: &Foo) -> &'a mut Foo {
45 unsafe { COUNT += 1; }
48 fn slice_to_mut_<'a>(&'a mut self, _to: &Foo) -> &'a mut Foo {
49 unsafe { COUNT += 1; }
52 fn slice_mut_<'a>(&'a mut self, _from: &Foo, _to: &Foo) -> &'a mut Foo {
53 unsafe { COUNT += 1; }