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.
13 // pretty-expanded FIXME #23616
18 use core
::ops
::{Index, IndexMut, Range, RangeTo, RangeFrom, RangeFull}
;
20 static mut COUNT
: usize = 0;
24 impl Index
<Range
<Foo
>> for Foo
{
26 fn index(&self, index
: Range
<Foo
>) -> &Foo
{
27 unsafe { COUNT += 1; }
31 impl Index
<RangeTo
<Foo
>> for Foo
{
33 fn index(&self, index
: RangeTo
<Foo
>) -> &Foo
{
34 unsafe { COUNT += 1; }
38 impl Index
<RangeFrom
<Foo
>> for Foo
{
40 fn index(&self, index
: RangeFrom
<Foo
>) -> &Foo
{
41 unsafe { COUNT += 1; }
45 impl Index
<RangeFull
> for Foo
{
47 fn index(&self, _index
: RangeFull
) -> &Foo
{
48 unsafe { COUNT += 1; }
53 impl IndexMut
<Range
<Foo
>> for Foo
{
54 fn index_mut(&mut self, index
: Range
<Foo
>) -> &mut Foo
{
55 unsafe { COUNT += 1; }
59 impl IndexMut
<RangeTo
<Foo
>> for Foo
{
60 fn index_mut(&mut self, index
: RangeTo
<Foo
>) -> &mut Foo
{
61 unsafe { COUNT += 1; }
65 impl IndexMut
<RangeFrom
<Foo
>> for Foo
{
66 fn index_mut(&mut self, index
: RangeFrom
<Foo
>) -> &mut Foo
{
67 unsafe { COUNT += 1; }
71 impl IndexMut
<RangeFull
> for Foo
{
72 fn index_mut(&mut self, _index
: RangeFull
) -> &mut Foo
{
73 unsafe { COUNT += 1; }