Camel case core::ops
This commit is contained in:
parent
cb0eb66672
commit
f393100b7c
|
@ -133,7 +133,7 @@ pure fn from_elem<T: copy>(n_elts: uint, t: T) -> @[T] {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl<T: copy> @[T]: add<&[const T],@[T]> {
|
impl<T: copy> @[T]: Add<&[const T],@[T]> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn add(rhs: &[const T]) -> @[T] {
|
pure fn add(rhs: &[const T]) -> @[T] {
|
||||||
append(self, rhs)
|
append(self, rhs)
|
||||||
|
|
|
@ -44,28 +44,28 @@ export ToStr;
|
||||||
// The compiler has special knowlege of these so we must not duplicate them
|
// The compiler has special knowlege of these so we must not duplicate them
|
||||||
// when compiling for testing
|
// when compiling for testing
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
import ops::{const, copy, send, owned};
|
import ops::{Const, Copy, Send, Owned};
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
import ops::{add, sub, mul, div, modulo, neg, bitand, bitor, bitxor};
|
import ops::{Add, Sub, Mul, Div, Modulo, Neg, BitAnd, BitOr, BitXor};
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
import ops::{shl, shr, index};
|
import ops::{Shl, Shr, Index};
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
export const, copy, send, owned;
|
export Const, Copy, Send, Owned;
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
export add, sub, mul, div, modulo, neg, bitand, bitor, bitxor;
|
export Add, Sub, Mul, Div, Modulo, Neg, BitAnd, BitOr, BitXor;
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
export shl, shr, index;
|
export Shl, Shr, Index;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use coreops(name = "core", vers = "0.4");
|
use coreops(name = "core", vers = "0.4");
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
import coreops::ops::{const, copy, send, owned};
|
import coreops::ops::{Const, Copy, Send, Owned};
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
import coreops::ops::{add, sub, mul, div, modulo, neg, bitand, bitor, bitxor};
|
import coreops::ops::{Add, Sub, Mul, Div, Modulo, Neg, BitAnd, BitOr, BitXor};
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
import coreops::ops::{shl, shr, index};
|
import coreops::ops::{Shl, Shr, Index};
|
||||||
|
|
||||||
|
|
||||||
// Export the log levels as global constants. Higher levels mean
|
// Export the log levels as global constants. Higher levels mean
|
||||||
|
|
|
@ -327,7 +327,7 @@ impl<A: copy> DVec<A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A:copy> DVec<A>: index<uint,A> {
|
impl<A:copy> DVec<A>: Index<uint,A> {
|
||||||
pure fn index(&&idx: uint) -> A {
|
pure fn index(&&idx: uint) -> A {
|
||||||
self.get_elt(idx)
|
self.get_elt(idx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,100 +1,98 @@
|
||||||
// Core operators and kinds.
|
// Core operators and kinds.
|
||||||
|
|
||||||
#[allow(non_camel_case_types)];
|
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="const"]
|
#[lang="const"]
|
||||||
trait const {
|
trait Const {
|
||||||
// Empty.
|
// Empty.
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="copy"]
|
#[lang="copy"]
|
||||||
trait copy {
|
trait Copy {
|
||||||
// Empty.
|
// Empty.
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="send"]
|
#[lang="send"]
|
||||||
trait send {
|
trait Send {
|
||||||
// Empty.
|
// Empty.
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="owned"]
|
#[lang="owned"]
|
||||||
trait owned {
|
trait Owned {
|
||||||
// Empty.
|
// Empty.
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="add"]
|
#[lang="add"]
|
||||||
trait add<RHS,Result> {
|
trait Add<RHS,Result> {
|
||||||
pure fn add(rhs: RHS) -> Result;
|
pure fn add(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="sub"]
|
#[lang="sub"]
|
||||||
trait sub<RHS,Result> {
|
trait Sub<RHS,Result> {
|
||||||
pure fn sub(rhs: RHS) -> Result;
|
pure fn sub(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="mul"]
|
#[lang="mul"]
|
||||||
trait mul<RHS,Result> {
|
trait Mul<RHS,Result> {
|
||||||
pure fn mul(rhs: RHS) -> Result;
|
pure fn mul(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="div"]
|
#[lang="div"]
|
||||||
trait div<RHS,Result> {
|
trait Div<RHS,Result> {
|
||||||
pure fn div(rhs: RHS) -> Result;
|
pure fn div(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="modulo"]
|
#[lang="modulo"]
|
||||||
trait modulo<RHS,Result> {
|
trait Modulo<RHS,Result> {
|
||||||
pure fn modulo(rhs: RHS) -> Result;
|
pure fn modulo(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="neg"]
|
#[lang="neg"]
|
||||||
trait neg<Result> {
|
trait Neg<Result> {
|
||||||
pure fn neg() -> Result;
|
pure fn neg() -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="bitand"]
|
#[lang="bitand"]
|
||||||
trait bitand<RHS,Result> {
|
trait BitAnd<RHS,Result> {
|
||||||
pure fn bitand(rhs: RHS) -> Result;
|
pure fn bitand(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="bitor"]
|
#[lang="bitor"]
|
||||||
trait bitor<RHS,Result> {
|
trait BitOr<RHS,Result> {
|
||||||
pure fn bitor(rhs: RHS) -> Result;
|
pure fn bitor(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="bitxor"]
|
#[lang="bitxor"]
|
||||||
trait bitxor<RHS,Result> {
|
trait BitXor<RHS,Result> {
|
||||||
pure fn bitxor(rhs: RHS) -> Result;
|
pure fn bitxor(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="shl"]
|
#[lang="shl"]
|
||||||
trait shl<RHS,Result> {
|
trait Shl<RHS,Result> {
|
||||||
pure fn shl(rhs: RHS) -> Result;
|
pure fn shl(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="shr"]
|
#[lang="shr"]
|
||||||
trait shr<RHS,Result> {
|
trait Shr<RHS,Result> {
|
||||||
pure fn shr(rhs: RHS) -> Result;
|
pure fn shr(rhs: RHS) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
#[lang="index"]
|
#[lang="index"]
|
||||||
trait index<Index,Result> {
|
trait Index<Index,Result> {
|
||||||
pure fn index(index: Index) -> Result;
|
pure fn index(index: Index) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2065,7 +2065,7 @@ impl ~str: UniqueStr {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl ~str: add<&str,~str> {
|
impl ~str: Add<&str,~str> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn add(rhs: &str) -> ~str {
|
pure fn add(rhs: &str) -> ~str {
|
||||||
append(copy self, rhs)
|
append(copy self, rhs)
|
||||||
|
|
|
@ -1480,14 +1480,14 @@ impl<T: Ord> @[T]: Ord {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl<T: copy> ~[T]: add<&[const T],~[T]> {
|
impl<T: copy> ~[T]: Add<&[const T],~[T]> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn add(rhs: &[const T]) -> ~[T] {
|
pure fn add(rhs: &[const T]) -> ~[T] {
|
||||||
append(copy self, rhs)
|
append(copy self, rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: copy> ~[mut T]: add<&[const T],~[mut T]> {
|
impl<T: copy> ~[mut T]: Add<&[const T],~[mut T]> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn add(rhs: &[const T]) -> ~[mut T] {
|
pure fn add(rhs: &[const T]) -> ~[mut T] {
|
||||||
append_mut(self, rhs)
|
append_mut(self, rhs)
|
||||||
|
|
|
@ -469,7 +469,7 @@ pure fn land(w0: uint, w1: uint) -> uint { return w0 & w1; }
|
||||||
|
|
||||||
pure fn right(_w0: uint, w1: uint) -> uint { return w1; }
|
pure fn right(_w0: uint, w1: uint) -> uint { return w1; }
|
||||||
|
|
||||||
impl Bitv: ops::index<uint,bool> {
|
impl Bitv: ops::Index<uint,bool> {
|
||||||
pure fn index(&&i: uint) -> bool {
|
pure fn index(&&i: uint) -> bool {
|
||||||
self.get(i)
|
self.get(i)
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ type Doc = {data: @~[u8], start: uint, end: uint};
|
||||||
|
|
||||||
type TaggedDoc = {tag: uint, doc: Doc};
|
type TaggedDoc = {tag: uint, doc: Doc};
|
||||||
|
|
||||||
impl Doc: ops::index<uint,Doc> {
|
impl Doc: ops::Index<uint,Doc> {
|
||||||
pure fn index(&&tag: uint) -> Doc {
|
pure fn index(&&tag: uint) -> Doc {
|
||||||
unchecked {
|
unchecked {
|
||||||
get_doc(self, tag)
|
get_doc(self, tag)
|
||||||
|
|
|
@ -367,7 +367,7 @@ mod chained {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K: copy, V: copy> t<K, V>: ops::index<K, V> {
|
impl<K: copy, V: copy> t<K, V>: ops::Index<K, V> {
|
||||||
pure fn index(&&k: K) -> V {
|
pure fn index(&&k: K) -> V {
|
||||||
unchecked {
|
unchecked {
|
||||||
self.get(k)
|
self.get(k)
|
||||||
|
|
|
@ -134,7 +134,7 @@ impl<V: copy> smallintmap<V>: map::map<uint, V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: copy> smallintmap<V>: ops::index<uint, V> {
|
impl<V: copy> smallintmap<V>: ops::Index<uint, V> {
|
||||||
pure fn index(&&key: uint) -> V {
|
pure fn index(&&key: uint) -> V {
|
||||||
unchecked {
|
unchecked {
|
||||||
get(self, key)
|
get(self, key)
|
||||||
|
|
|
@ -1605,7 +1605,7 @@ fn remove_copyable(k: kind) -> kind {
|
||||||
k - kind_(KIND_MASK_COPY | KIND_MASK_DEFAULT_MODE)
|
k - kind_(KIND_MASK_COPY | KIND_MASK_DEFAULT_MODE)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl kind: ops::bitand<kind,kind> {
|
impl kind: ops::BitAnd<kind,kind> {
|
||||||
pure fn bitand(other: kind) -> kind {
|
pure fn bitand(other: kind) -> kind {
|
||||||
unchecked {
|
unchecked {
|
||||||
lower_kind(self, other)
|
lower_kind(self, other)
|
||||||
|
@ -1613,7 +1613,7 @@ impl kind: ops::bitand<kind,kind> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl kind: ops::bitor<kind,kind> {
|
impl kind: ops::BitOr<kind,kind> {
|
||||||
pure fn bitor(other: kind) -> kind {
|
pure fn bitor(other: kind) -> kind {
|
||||||
unchecked {
|
unchecked {
|
||||||
raise_kind(self, other)
|
raise_kind(self, other)
|
||||||
|
@ -1621,7 +1621,7 @@ impl kind: ops::bitor<kind,kind> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl kind: ops::sub<kind,kind> {
|
impl kind: ops::Sub<kind,kind> {
|
||||||
pure fn sub(other: kind) -> kind {
|
pure fn sub(other: kind) -> kind {
|
||||||
unchecked {
|
unchecked {
|
||||||
kind_(*self & !*other)
|
kind_(*self & !*other)
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct cmplx {
|
||||||
im: f64;
|
im: f64;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cmplx : ops::mul<cmplx,cmplx> {
|
impl cmplx : ops::Mul<cmplx,cmplx> {
|
||||||
pure fn mul(x: cmplx) -> cmplx {
|
pure fn mul(x: cmplx) -> cmplx {
|
||||||
cmplx {
|
cmplx {
|
||||||
re: self.re*x.re - self.im*x.im,
|
re: self.re*x.re - self.im*x.im,
|
||||||
|
@ -30,7 +30,7 @@ impl cmplx : ops::mul<cmplx,cmplx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cmplx : ops::add<cmplx,cmplx> {
|
impl cmplx : ops::Add<cmplx,cmplx> {
|
||||||
pure fn add(x: cmplx) -> cmplx {
|
pure fn add(x: cmplx) -> cmplx {
|
||||||
cmplx {
|
cmplx {
|
||||||
re: self.re + x.re,
|
re: self.re + x.re,
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct Point {
|
||||||
y: int;
|
y: int;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Point : ops::add<int,int> {
|
impl Point : ops::Add<int,int> {
|
||||||
pure fn add(&&z: int) -> int {
|
pure fn add(&&z: int) -> int {
|
||||||
self.x + self.y + z
|
self.x + self.y + z
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,25 +3,25 @@ struct Point {
|
||||||
y: int;
|
y: int;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Point : ops::add<Point,Point> {
|
impl Point : ops::Add<Point,Point> {
|
||||||
pure fn add(other: Point) -> Point {
|
pure fn add(other: Point) -> Point {
|
||||||
Point {x: self.x + other.x, y: self.y + other.y}
|
Point {x: self.x + other.x, y: self.y + other.y}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Point : ops::sub<Point,Point> {
|
impl Point : ops::Sub<Point,Point> {
|
||||||
pure fn sub(other: Point) -> Point {
|
pure fn sub(other: Point) -> Point {
|
||||||
Point {x: self.x - other.x, y: self.y - other.y}
|
Point {x: self.x - other.x, y: self.y - other.y}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Point : ops::neg<Point> {
|
impl Point : ops::Neg<Point> {
|
||||||
pure fn neg() -> Point {
|
pure fn neg() -> Point {
|
||||||
Point {x: -self.x, y: -self.y}
|
Point {x: -self.x, y: -self.y}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Point : ops::index<bool,int> {
|
impl Point : ops::Index<bool,int> {
|
||||||
pure fn index(&&x: bool) -> int {
|
pure fn index(&&x: bool) -> int {
|
||||||
if x { self.x } else { self.y }
|
if x { self.x } else { self.y }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue