(index<- ) ./libstd/ops.rs
git branch: * master c7553ea auto merge of #13609 : richo/rust/str-type-vim, r=alexcrichton
modified: Sat Apr 19 11:22:39 2014
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.
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
11 /*!
12 *
13 * Traits representing built-in operators, useful for overloading
14 *
15 * Implementing these traits allows you to get an effect similar to
16 * overloading operators.
17 *
18 * The values for the right hand side of an operator are automatically
19 * borrowed, so `a + b` is sugar for `a.add(&b)`.
20 *
21 * All of these traits are imported by the prelude, so they are available in
22 * every Rust program.
23 *
24 * # Example
25 *
26 * This example creates a `Point` struct that implements `Add` and `Sub`, and then
27 * demonstrates adding and subtracting two `Point`s.
28 *
29 * ```rust
30 * struct Point {
31 * x: int,
32 * y: int
33 * }
34 *
35 * impl Add<Point, Point> for Point {
36 * fn add(&self, other: &Point) -> Point {
37 * Point {x: self.x + other.x, y: self.y + other.y}
38 * }
39 * }
40 *
41 * impl Sub<Point, Point> for Point {
42 * fn sub(&self, other: &Point) -> Point {
43 * Point {x: self.x - other.x, y: self.y - other.y}
44 * }
45 * }
46 * fn main() {
47 * println!("{:?}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
48 * println!("{:?}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
49 * }
50 * ```
51 *
52 * See the documentation for each trait for a minimum implementation that prints
53 * something to the screen.
54 *
55 */
56
57 /**
58 *
59 * The `Drop` trait is used to run some code when a value goes out of scope. This
60 * is sometimes called a 'destructor'.
61 *
62 * # Example
63 *
64 * A trivial implementation of `Drop`. The `drop` method is called when `_x` goes
65 * out of scope, and therefore `main` prints `Dropping!`.
66 *
67 * ```rust
68 * struct HasDrop;
69 *
70 * impl Drop for HasDrop {
71 * fn drop(&mut self) {
72 * println!("Dropping!");
73 * }
74 * }
75 *
76 * fn main() {
77 * let _x = HasDrop;
78 * }
79 * ```
80 */
81 #[lang="drop"]
82 pub trait Drop {
83 /// The `drop` method, called when the value goes out of scope.
84 fn drop(&mut self);
85 }
86
87 /**
88 *
89 * The `Add` trait is used to specify the functionality of `+`.
90 *
91 * # Example
92 *
93 * A trivial implementation of `Add`. When `Foo + Foo` happens, it ends up
94 * calling `add`, and therefore, `main` prints `Adding!`.
95 *
96 * ```rust
97 * struct Foo;
98 *
99 * impl Add<Foo, Foo> for Foo {
100 * fn add(&self, _rhs: &Foo) -> Foo {
101 * println!("Adding!");
102 * *self
103 * }
104 * }
105 *
106 * fn main() {
107 * Foo + Foo;
108 * }
109 * ```
110 */
111 #[lang="add"]
112 pub trait Add<RHS,Result> {
113 /// The method for the `+` operator
114 fn add(&self, rhs: &RHS) -> Result;
115 }
116
117 /**
118 *
119 * The `Sub` trait is used to specify the functionality of `-`.
120 *
121 * # Example
122 *
123 * A trivial implementation of `Sub`. When `Foo - Foo` happens, it ends up
124 * calling `sub`, and therefore, `main` prints `Subtracting!`.
125 *
126 * ```rust
127 * struct Foo;
128 *
129 * impl Sub<Foo, Foo> for Foo {
130 * fn sub(&self, _rhs: &Foo) -> Foo {
131 * println!("Subtracting!");
132 * *self
133 * }
134 * }
135 *
136 * fn main() {
137 * Foo - Foo;
138 * }
139 * ```
140 */
141 #[lang="sub"]
142 pub trait Sub<RHS,Result> {
143 /// The method for the `-` operator
144 fn sub(&self, rhs: &RHS) -> Result;
145 }
146
147 /**
148 *
149 * The `Mul` trait is used to specify the functionality of `*`.
150 *
151 * # Example
152 *
153 * A trivial implementation of `Mul`. When `Foo * Foo` happens, it ends up
154 * calling `mul`, and therefore, `main` prints `Multiplying!`.
155 *
156 * ```rust
157 * struct Foo;
158 *
159 * impl Mul<Foo, Foo> for Foo {
160 * fn mul(&self, _rhs: &Foo) -> Foo {
161 * println!("Multiplying!");
162 * *self
163 * }
164 * }
165 *
166 * fn main() {
167 * Foo * Foo;
168 * }
169 * ```
170 */
171 #[lang="mul"]
172 pub trait Mul<RHS,Result> {
173 /// The method for the `*` operator
174 fn mul(&self, rhs: &RHS) -> Result;
175 }
176
177 /**
178 *
179 * The `Div` trait is used to specify the functionality of `/`.
180 *
181 * # Example
182 *
183 * A trivial implementation of `Div`. When `Foo / Foo` happens, it ends up
184 * calling `div`, and therefore, `main` prints `Dividing!`.
185 *
186 * ```
187 * struct Foo;
188 *
189 * impl Div<Foo, Foo> for Foo {
190 * fn div(&self, _rhs: &Foo) -> Foo {
191 * println!("Dividing!");
192 * *self
193 * }
194 * }
195 *
196 * fn main() {
197 * Foo / Foo;
198 * }
199 * ```
200 */
201 #[lang="div"]
202 pub trait Div<RHS,Result> {
203 /// The method for the `/` operator
204 fn div(&self, rhs: &RHS) -> Result;
205 }
206
207 /**
208 *
209 * The `Rem` trait is used to specify the functionality of `%`.
210 *
211 * # Example
212 *
213 * A trivial implementation of `Rem`. When `Foo % Foo` happens, it ends up
214 * calling `rem`, and therefore, `main` prints `Remainder-ing!`.
215 *
216 * ```
217 * struct Foo;
218 *
219 * impl Rem<Foo, Foo> for Foo {
220 * fn rem(&self, _rhs: &Foo) -> Foo {
221 * println!("Remainder-ing!");
222 * *self
223 * }
224 * }
225 *
226 * fn main() {
227 * Foo % Foo;
228 * }
229 * ```
230 */
231 #[lang="rem"]
232 pub trait Rem<RHS,Result> {
233 /// The method for the `%` operator
234 fn rem(&self, rhs: &RHS) -> Result;
235 }
236
237 /**
238 *
239 * The `Neg` trait is used to specify the functionality of unary `-`.
240 *
241 * # Example
242 *
243 * A trivial implementation of `Neg`. When `-Foo` happens, it ends up calling
244 * `neg`, and therefore, `main` prints `Negating!`.
245 *
246 * ```
247 * struct Foo;
248 *
249 * impl Neg<Foo> for Foo {
250 * fn neg(&self) -> Foo {
251 * println!("Negating!");
252 * *self
253 * }
254 * }
255 *
256 * fn main() {
257 * -Foo;
258 * }
259 * ```
260 */
261 #[lang="neg"]
262 pub trait Neg<Result> {
263 /// The method for the unary `-` operator
264 fn neg(&self) -> Result;
265 }
266
267 /**
268 *
269 * The `Not` trait is used to specify the functionality of unary `!`.
270 *
271 * # Example
272 *
273 * A trivial implementation of `Not`. When `!Foo` happens, it ends up calling
274 * `not`, and therefore, `main` prints `Not-ing!`.
275 *
276 * ```
277 * struct Foo;
278 *
279 * impl Not<Foo> for Foo {
280 * fn not(&self) -> Foo {
281 * println!("Not-ing!");
282 * *self
283 * }
284 * }
285 *
286 * fn main() {
287 * !Foo;
288 * }
289 * ```
290 */
291 #[lang="not"]
292 pub trait Not<Result> {
293 /// The method for the unary `!` operator
294 fn not(&self) -> Result;
295 }
296
297 /**
298 *
299 * The `BitAnd` trait is used to specify the functionality of `&`.
300 *
301 * # Example
302 *
303 * A trivial implementation of `BitAnd`. When `Foo & Foo` happens, it ends up
304 * calling `bitand`, and therefore, `main` prints `Bitwise And-ing!`.
305 *
306 * ```
307 * struct Foo;
308 *
309 * impl BitAnd<Foo, Foo> for Foo {
310 * fn bitand(&self, _rhs: &Foo) -> Foo {
311 * println!("Bitwise And-ing!");
312 * *self
313 * }
314 * }
315 *
316 * fn main() {
317 * Foo & Foo;
318 * }
319 * ```
320 */
321 #[lang="bitand"]
322 pub trait BitAnd<RHS,Result> {
323 /// The method for the `&` operator
324 fn bitand(&self, rhs: &RHS) -> Result;
325 }
326
327 /**
328 *
329 * The `BitOr` trait is used to specify the functionality of `|`.
330 *
331 * # Example
332 *
333 * A trivial implementation of `BitOr`. When `Foo | Foo` happens, it ends up
334 * calling `bitor`, and therefore, `main` prints `Bitwise Or-ing!`.
335 *
336 * ```
337 * struct Foo;
338 *
339 * impl BitOr<Foo, Foo> for Foo {
340 * fn bitor(&self, _rhs: &Foo) -> Foo {
341 * println!("Bitwise Or-ing!");
342 * *self
343 * }
344 * }
345 *
346 * fn main() {
347 * Foo | Foo;
348 * }
349 * ```
350 */
351 #[lang="bitor"]
352 pub trait BitOr<RHS,Result> {
353 /// The method for the `|` operator
354 fn bitor(&self, rhs: &RHS) -> Result;
355 }
356
357 /**
358 *
359 * The `BitXor` trait is used to specify the functionality of `^`.
360 *
361 * # Example
362 *
363 * A trivial implementation of `BitXor`. When `Foo ^ Foo` happens, it ends up
364 * calling `bitxor`, and therefore, `main` prints `Bitwise Xor-ing!`.
365 *
366 * ```
367 * struct Foo;
368 *
369 * impl BitXor<Foo, Foo> for Foo {
370 * fn bitxor(&self, _rhs: &Foo) -> Foo {
371 * println!("Bitwise Xor-ing!");
372 * *self
373 * }
374 * }
375 *
376 * fn main() {
377 * Foo ^ Foo;
378 * }
379 * ```
380 */
381 #[lang="bitxor"]
382 pub trait BitXor<RHS,Result> {
383 /// The method for the `^` operator
384 fn bitxor(&self, rhs: &RHS) -> Result;
385 }
386
387 /**
388 *
389 * The `Shl` trait is used to specify the functionality of `<<`.
390 *
391 * # Example
392 *
393 * A trivial implementation of `Shl`. When `Foo << Foo` happens, it ends up
394 * calling `shl`, and therefore, `main` prints `Shifting left!`.
395 *
396 * ```
397 * struct Foo;
398 *
399 * impl Shl<Foo, Foo> for Foo {
400 * fn shl(&self, _rhs: &Foo) -> Foo {
401 * println!("Shifting left!");
402 * *self
403 * }
404 * }
405 *
406 * fn main() {
407 * Foo << Foo;
408 * }
409 * ```
410 */
411 #[lang="shl"]
412 pub trait Shl<RHS,Result> {
413 /// The method for the `<<` operator
414 fn shl(&self, rhs: &RHS) -> Result;
415 }
416
417 /**
418 *
419 * The `Shr` trait is used to specify the functionality of `>>`.
420 *
421 * # Example
422 *
423 * A trivial implementation of `Shr`. When `Foo >> Foo` happens, it ends up
424 * calling `shr`, and therefore, `main` prints `Shifting right!`.
425 *
426 * ```
427 * struct Foo;
428 *
429 * impl Shr<Foo, Foo> for Foo {
430 * fn shr(&self, _rhs: &Foo) -> Foo {
431 * println!("Shifting right!");
432 * *self
433 * }
434 * }
435 *
436 * fn main() {
437 * Foo >> Foo;
438 * }
439 * ```
440 */
441 #[lang="shr"]
442 pub trait Shr<RHS,Result> {
443 /// The method for the `>>` operator
444 fn shr(&self, rhs: &RHS) -> Result;
445 }
446
447 /**
448 *
449 * The `Index` trait is used to specify the functionality of indexing operations
450 * like `arr[idx]`.
451 *
452 * # Example
453 *
454 * A trivial implementation of `Index`. When `Foo[Foo]` happens, it ends up
455 * calling `index`, and therefore, `main` prints `Indexing!`.
456 *
457 * ```
458 * struct Foo;
459 *
460 * impl Index<Foo, Foo> for Foo {
461 * fn index(&self, _rhs: &Foo) -> Foo {
462 * println!("Indexing!");
463 * *self
464 * }
465 * }
466 *
467 * fn main() {
468 * Foo[Foo];
469 * }
470 * ```
471 */
472 #[lang="index"]
473 pub trait Index<Index,Result> {
474 /// The method for the indexing (`Foo[Bar]`) operation
475 fn index(&self, index: &Index) -> Result;
476 }
477
478 /**
479 *
480 * The `Deref` trait is used to specify the functionality of dereferencing
481 * operations like `*v`.
482 *
483 * # Example
484 *
485 * A struct with a single field which is accessible via dereferencing the
486 * struct.
487 *
488 * ```
489 * struct DerefExample<T> {
490 * value: T
491 * }
492 *
493 * impl<T> Deref<T> for DerefExample<T> {
494 * fn deref<'a>(&'a self) -> &'a T {
495 * &self.value
496 * }
497 * }
498 *
499 * fn main() {
500 * let x = DerefExample { value: 'a' };
501 * assert_eq!('a', *x);
502 * }
503 * ```
504 */
505 #[lang="deref"]
506 pub trait Deref<Result> {
507 /// The method called to dereference a value
508 fn deref<'a>(&'a self) -> &'a Result;
509 }
510
511 /**
512 *
513 * The `DerefMut` trait is used to specify the functionality of dereferencing
514 * mutably like `*v = 1;`
515 *
516 * # Example
517 *
518 * A struct with a single field which is modifiable via dereferencing the
519 * struct.
520 *
521 * ```
522 * struct DerefMutExample<T> {
523 * value: T
524 * }
525 *
526 * impl<T> Deref<T> for DerefMutExample<T> {
527 * fn deref<'a>(&'a self) -> &'a T {
528 * &self.value
529 * }
530 * }
531 *
532 * impl<T> DerefMut<T> for DerefMutExample<T> {
533 * fn deref_mut<'a>(&'a mut self) -> &'a mut T {
534 * &mut self.value
535 * }
536 * }
537 *
538 * fn main() {
539 * let mut x = DerefMutExample { value: 'a' };
540 * *x = 'b';
541 * assert_eq!('b', *x);
542 * }
543 * ```
544 */
545 #[lang="deref_mut"]
546 pub trait DerefMut<Result>: Deref<Result> {
547 /// The method called to mutably dereference a value
548 fn deref_mut<'a>(&'a mut self) -> &'a mut Result;
549 }
550
551 #[cfg(test)]
552 mod bench {
553 extern crate test;
554 use self::test::Bencher;
555 use ops::Drop;
556
557 // Overhead of dtors
558
559 struct HasDtor {
560 x: int
561 }
562
563 impl Drop for HasDtor {
564 fn drop(&mut self) {
565 }
566 }
567
568 #[bench]
569 fn alloc_obj_with_dtor(b: &mut Bencher) {
570 b.iter(|| {
571 HasDtor { x : 10 };
572 })
573 }
574 }
libstd/ops.rs:381:17-381:17 -trait- definition:
pub trait BitXor<RHS,Result> {
/// The method for the `^` operator
fn bitxor(&self, rhs: &RHS) -> Result;
references:- 12libstd/num/mod.rs:
220: + BitOr<Self,Self>
221: + BitXor<Self,Self>
222: + Shl<Self,Self>
libstd/num/int_macros.rs:
200: impl BitXor<$T,$T> for $T {
201: #[inline]
libstd/num/uint_macros.rs:
116: impl BitXor<$T,$T> for $T {
117: #[inline]
libstd/bool.rs:
137: impl BitXor<bool, bool> for bool {
138: /// An 'exclusive or' of two boolean values.
libstd/num/int_macros.rs:
200: impl BitXor<$T,$T> for $T {
201: #[inline]
libstd/ops.rs:231:14-231:14 -trait- definition:
pub trait Rem<RHS,Result> {
/// The method for the `%` operator
fn rem(&self, rhs: &RHS) -> Result;
references:- 16libstd/num/mod.rs:
40: pub fn div_rem<T: Div<T, T> + Rem<T, T>>(x: T, y: T) -> (T, T) {
41: (x / y, x % y)
libstd/num/strconv.rs:
261: pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
262: Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
263: num: T, radix: uint, negative_zero: bool,
--
494: pub fn float_to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Float+Round+
495: Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
496: num: T, radix: uint, negative_zero: bool,
libstd/num/int_macros.rs:
114: impl Rem<$T,$T> for $T {
115: /// Returns the integer remainder after division, satisfying:
libstd/num/uint_macros.rs:
90: impl Rem<$T,$T> for $T {
91: #[inline]
libstd/num/f32.rs:
202: impl Rem<f32,f32> for f32 {
203: #[inline]
libstd/num/f64.rs:
211: impl Rem<f64,f64> for f64 {
212: #[inline]
libstd/num/uint_macros.rs:
90: impl Rem<$T,$T> for $T {
91: #[inline]
libstd/ops.rs:81:15-81:15 -trait- definition:
pub trait Drop {
/// The `drop` method, called when the value goes out of scope.
fn drop(&mut self);
references:- 39libstd/cell.rs:
libstd/comm/mod.rs:
libstd/comm/select.rs:
libstd/comm/oneshot.rs:
libstd/comm/stream.rs:
libstd/comm/shared.rs:
libstd/comm/sync.rs:
libstd/sync/arc.rs:
libstd/sync/atomics.rs:
libstd/sync/deque.rs:
libstd/sync/mpsc_queue.rs:
libstd/sync/spsc_queue.rs:
libstd/c_str.rs:
libstd/c_vec.rs:
libstd/io/buffered.rs:
libstd/io/tempfile.rs:
libstd/io/process.rs:
libstd/unstable/dynamic_lib.rs:
libstd/unstable/finally.rs:
libstd/unstable/mutex.rs:
libstd/rt/task.rs:
libstd/rt/rtio.rs:
libstd/rt/thread.rs:
libstd/rt/local_heap.rs:
libstd/rt/local_ptr.rs:
libstd/slice.rs:
libstd/vec.rs:
libstd/rc.rs:
libstd/os.rs:
libstd/ops.rs:111:14-111:14 -trait- definition:
pub trait Add<RHS,Result> {
/// The method for the `+` operator
fn add(&self, rhs: &RHS) -> Result;
references:- 26libstd/num/mod.rs:
50: /// the documentation for `Zero::zero` still hold.
51: pub trait Zero: Add<Self, Self> {
52: /// Returns the additive identity element of `Self`, `0`.
--
1103: /// Performs addition that returns `None` instead of wrapping around on overflow.
1104: pub trait CheckedAdd: Add<Self, Self> {
1105: /// Adds two numbers, checking for overflow. If overflow happens, `None` is returned.
libstd/num/strconv.rs:
756: pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+Mul<T,T>+
757: Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv+Clone>(
758: buf: &str, radix: uint, negative: bool, fractional: bool,
libstd/iter.rs:
1943: pub fn range<A: Add<A, A> + Ord + Clone + One>(start: A, stop: A) -> Range<A> {
1944: Range{state: start, stop: stop, one: One::one()}
--
2016: pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One + ToPrimitive>(start: A, stop: A)
2017: -> RangeInclusive<A> {
--
2021: impl<A: Add<A, A> + Ord + Clone + ToPrimitive> Iterator<A> for RangeInclusive<A> {
2022: #[inline]
libstd/num/int_macros.rs:
75: impl Add<$T,$T> for $T {
76: #[inline]
libstd/num/uint_macros.rs:
66: impl Add<$T,$T> for $T {
67: #[inline]
libstd/num/f32.rs:
178: impl Add<f32,f32> for f32 {
179: #[inline]
libstd/num/f64.rs:
191: impl Add<f64,f64> for f64 {
192: #[inline]
libstd/slice.rs:
601: impl<T:Clone, V: Vector<T>> Add<V, ~[T]> for ~[T] {
602: #[inline]
libstd/str.rs:
1474: impl<'a> Add<&'a str,~str> for &'a str {
1475: #[inline]
libstd/num/uint_macros.rs:
66: impl Add<$T,$T> for $T {
67: #[inline]
libstd/ops.rs:545:20-545:20 -trait- definition:
pub trait DerefMut<Result>: Deref<Result> {
/// The method called to mutably dereference a value
fn deref_mut<'a>(&'a mut self) -> &'a mut Result;
references:- 2libstd/rt/local_ptr.rs:
59: impl<T> DerefMut<T> for Borrowed<T> {
60: fn deref_mut<'a>(&'a mut self) -> &'a mut T {
libstd/cell.rs:
217: impl<'b, T> DerefMut<T> for RefMut<'b, T> {
218: #[inline]
libstd/ops.rs:441:14-441:14 -trait- definition:
pub trait Shr<RHS,Result> {
/// The method for the `>>` operator
fn shr(&self, rhs: &RHS) -> Result;
references:- 11libstd/num/mod.rs:
222: + Shl<Self,Self>
223: + Shr<Self,Self> {
224: /// Returns the number of ones in the binary representation of the number.
libstd/num/int_macros.rs:
212: impl Shr<$T,$T> for $T {
213: #[inline]
libstd/num/uint_macros.rs:
128: impl Shr<$T,$T> for $T {
129: #[inline]
libstd/ops.rs:261:14-261:14 -trait- definition:
pub trait Neg<Result> {
/// The method for the unary `-` operator
fn neg(&self) -> Result;
references:- 18libstd/num/mod.rs:
30: pub trait Num: Eq + Zero + One
31: + Neg<Self>
32: + Add<Self,Self>
--
99: /// Useful functions for signed numbers (i.e. numbers that can be negative).
100: pub trait Signed: Num + Neg<Self> {
101: /// Computes the absolute value.
libstd/num/strconv.rs:
549: pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
550: Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
551: NumStrConv+Clone>(
--
756: pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+Mul<T,T>+
757: Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv+Clone>(
758: buf: &str, radix: uint, negative: bool, fractional: bool,
libstd/num/int_macros.rs:
141: impl Neg<$T> for $T {
142: #[inline]
libstd/num/uint_macros.rs:
96: impl Neg<$T> for $T {
97: #[inline]
libstd/num/f32.rs:
208: impl Neg<f32> for f32 {
209: #[inline]
libstd/num/f64.rs:
216: impl Neg<f64> for f64 {
217: #[inline]
libstd/num/uint_macros.rs:
96: impl Neg<$T> for $T {
97: #[inline]
libstd/ops.rs:321:17-321:17 -trait- definition:
pub trait BitAnd<RHS,Result> {
/// The method for the `&` operator
fn bitand(&self, rhs: &RHS) -> Result;
references:- 12libstd/num/mod.rs:
218: + Not<Self>
219: + BitAnd<Self,Self>
220: + BitOr<Self,Self>
libstd/num/int_macros.rs:
194: impl BitAnd<$T,$T> for $T {
195: #[inline]
libstd/num/uint_macros.rs:
110: impl BitAnd<$T,$T> for $T {
111: #[inline]
libstd/bool.rs:
95: impl BitAnd<bool, bool> for bool {
96: /// Conjunction of two boolean values.
libstd/num/uint_macros.rs:
110: impl BitAnd<$T,$T> for $T {
111: #[inline]
libstd/ops.rs:141:14-141:14 -trait- definition:
pub trait Sub<RHS,Result> {
/// The method for the `-` operator
fn sub(&self, rhs: &RHS) -> Result;
references:- 17libstd/num/mod.rs:
32: + Add<Self,Self>
33: + Sub<Self,Self>
34: + Mul<Self,Self>
--
1109: /// Performs subtraction that returns `None` instead of wrapping around on underflow.
1110: pub trait CheckedSub: Sub<Self, Self> {
1111: /// Subtracts two numbers, checking for underflow. If underflow happens, `None` is returned.
libstd/num/strconv.rs:
756: pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+Mul<T,T>+
757: Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv+Clone>(
758: buf: &str, radix: uint, negative: bool, fractional: bool,
libstd/iter.rs:
2053: impl<A: Sub<A, A> + Int + Ord + Clone + ToPrimitive> DoubleEndedIterator<A>
2054: for RangeInclusive<A> {
libstd/num/int_macros.rs:
81: impl Sub<$T,$T> for $T {
82: #[inline]
libstd/num/uint_macros.rs:
72: impl Sub<$T,$T> for $T {
73: #[inline]
libstd/num/f32.rs:
184: impl Sub<f32,f32> for f32 {
185: #[inline]
libstd/num/f64.rs:
196: impl Sub<f64,f64> for f64 {
197: #[inline]
libstd/num/strconv.rs:
549: pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
550: Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
551: NumStrConv+Clone>(
libstd/ops.rs:411:14-411:14 -trait- definition:
pub trait Shl<RHS,Result> {
/// The method for the `<<` operator
fn shl(&self, rhs: &RHS) -> Result;
references:- 11libstd/num/mod.rs:
221: + BitXor<Self,Self>
222: + Shl<Self,Self>
223: + Shr<Self,Self> {
libstd/num/int_macros.rs:
206: impl Shl<$T,$T> for $T {
207: #[inline]
libstd/num/uint_macros.rs:
122: impl Shl<$T,$T> for $T {
123: #[inline]
libstd/ops.rs:171:14-171:14 -trait- definition:
pub trait Mul<RHS,Result> {
/// The method for the `*` operator
fn mul(&self, rhs: &RHS) -> Result;
references:- 21libstd/num/mod.rs:
194: pub fn pow<T: One + Mul<T, T>>(mut base: T, mut exp: uint) -> T {
195: if exp == 1 { base }
--
1116: /// overflow.
1117: pub trait CheckedMul: Mul<Self, Self> {
1118: /// Multiplies two numbers, checking for underflow or overflow. If underflow or overflow
libstd/num/strconv.rs:
261: pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
262: Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
263: num: T, radix: uint, negative_zero: bool,
--
494: pub fn float_to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Float+Round+
495: Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
496: num: T, radix: uint, negative_zero: bool,
--
549: pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
550: Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
551: NumStrConv+Clone>(
--
756: pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+Mul<T,T>+
757: Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv+Clone>(
libstd/iter.rs:
840: impl<A: Mul<A, A> + One, T: Iterator<A>> MultiplicativeIterator<A> for T {
841: #[inline]
libstd/num/int_macros.rs:
87: impl Mul<$T,$T> for $T {
88: #[inline]
libstd/num/uint_macros.rs:
78: impl Mul<$T,$T> for $T {
79: #[inline]
libstd/num/f32.rs:
190: impl Mul<f32,f32> for f32 {
191: #[inline]
libstd/num/f64.rs:
201: impl Mul<f64,f64> for f64 {
202: #[inline]
libstd/num/mod.rs:
33: + Sub<Self,Self>
34: + Mul<Self,Self>
35: + Div<Self,Self>
libstd/ops.rs:201:14-201:14 -trait- definition:
pub trait Div<RHS,Result> {
/// The method for the `/` operator
fn div(&self, rhs: &RHS) -> Result;
references:- 19libstd/num/mod.rs:
34: + Mul<Self,Self>
35: + Div<Self,Self>
36: + Rem<Self,Self> {}
--
40: pub fn div_rem<T: Div<T, T> + Rem<T, T>>(x: T, y: T) -> (T, T) {
41: (x / y, x % y)
--
1123: /// Performs division that returns `None` instead of wrapping around on underflow or overflow.
1124: pub trait CheckedDiv: Div<Self, Self> {
1125: /// Divides two numbers, checking for underflow or overflow. If underflow or overflow happens,
libstd/num/strconv.rs:
548: */
549: pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
550: Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
--
756: pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+Mul<T,T>+
757: Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv+Clone>(
libstd/num/int_macros.rs:
93: impl Div<$T,$T> for $T {
94: /// Integer division, truncated towards 0.
libstd/num/uint_macros.rs:
84: impl Div<$T,$T> for $T {
85: #[inline]
libstd/num/f32.rs:
196: impl Div<f32,f32> for f32 {
197: #[inline]
libstd/num/f64.rs:
206: impl Div<f64,f64> for f64 {
207: #[inline]
libstd/num/uint_macros.rs:
84: impl Div<$T,$T> for $T {
85: #[inline]
libstd/ops.rs:505:16-505:16 -trait- definition:
pub trait Deref<Result> {
/// The method called to dereference a value
fn deref<'a>(&'a self) -> &'a Result;
references:- 5libstd/cell.rs:
210: impl<'b, T> Deref<T> for RefMut<'b, T> {
211: #[inline]
libstd/rt/local_ptr.rs:
53: impl<T> Deref<T> for Borrowed<T> {
54: fn deref<'a>(&'a self) -> &'a T {
libstd/rc.rs:
85: impl<T> Deref<T> for Rc<T> {
86: /// Borrow the value contained in the reference-counted box
libstd/ops.rs:
546: pub trait DerefMut<Result>: Deref<Result> {
547: /// The method called to mutably dereference a value
libstd/ops.rs:351:16-351:16 -trait- definition:
pub trait BitOr<RHS,Result> {
/// The method for the `|` operator
fn bitor(&self, rhs: &RHS) -> Result;
references:- 12libstd/num/mod.rs:
219: + BitAnd<Self,Self>
220: + BitOr<Self,Self>
221: + BitXor<Self,Self>
libstd/num/int_macros.rs:
188: impl BitOr<$T,$T> for $T {
189: #[inline]
libstd/num/uint_macros.rs:
104: impl BitOr<$T,$T> for $T {
105: #[inline]
libstd/bool.rs:
116: impl BitOr<bool, bool> for bool {
117: /// Disjunction of two boolean values.
libstd/num/uint_macros.rs:
104: impl BitOr<$T,$T> for $T {
105: #[inline]
libstd/ops.rs:291:14-291:14 -trait- definition:
pub trait Not<Result> {
/// The method for the unary `!` operator
fn not(&self) -> Result;
references:- 12libstd/num/mod.rs:
217: pub trait Bitwise: Bounded
218: + Not<Self>
219: + BitAnd<Self,Self>
libstd/num/int_macros.rs:
218: impl Not<$T> for $T {
219: #[inline]
libstd/num/uint_macros.rs:
134: impl Not<$T> for $T {
135: #[inline]
libstd/bool.rs:
81: impl Not<bool> for bool {
82: /// The logical complement of a boolean value.
libstd/num/uint_macros.rs:
134: impl Not<$T> for $T {
135: #[inline]