Skip to content

librustc: Mark all type implementations public. rs=impl-publicity #5136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ points to.

~~~
let managed = @mut 10;
let owned = ~mut 20;
let mut owned = ~20;

let mut value = 30;
let borrowed = &mut value;
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub mod traits {
use kinds::Copy;
use ops::Add;

pub impl<T:Copy> Add<&[const T],@[T]> for @[T] {
impl<T:Copy> Add<&[const T],@[T]> for @[T] {
#[inline(always)]
pure fn add(&self, rhs: & &self/[const T]) -> @[T] {
append(*self, (*rhs))
Expand Down
14 changes: 1 addition & 13 deletions src/libcore/dvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,6 @@ impl<A> DVec<A> {
self.check_out(|v| self.give_back(f(v)))
}

/**
* Swaps out the current vector and hands it off to a user-provided
* function `f`. The function should transform it however is desired
* and return a new vector to replace it with.
*/
#[inline(always)]
fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut A]) {
do self.swap |v| {
vec::cast_from_mut(f(vec::cast_to_mut(v)))
}
}

/// Returns the number of elements currently in the dvec
#[inline(always)]
pure fn len() -> uint {
Expand Down Expand Up @@ -217,7 +205,7 @@ impl<A> DVec<A> {
}

/// Gives access to the vector as a slice with mutable contents
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
fn borrow_mut<R>(op: &fn(x: &mut [A]) -> R) -> R {
do self.check_out |v| {
let mut v = v;
let result = op(v);
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl num::One for f32 {
static pure fn one() -> f32 { 1.0 }
}

pub impl NumCast for f32 {
impl NumCast for f32 {
/**
* Cast `n` to an `f32`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl cmp::Ord for f64 {
pure fn gt(&self, other: &f64) -> bool { (*self) > (*other) }
}

pub impl NumCast for f64 {
impl NumCast for f64 {
/**
* Cast `n` to an `f64`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl num::One for float {
static pure fn one() -> float { 1.0 }
}

pub impl NumCast for float {
impl NumCast for float {
/**
* Cast `n` to a `float`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/int-template/i16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod inst {
pub const bits: uint = ::u16::bits;
}

pub impl NumCast for i16 {
impl NumCast for i16 {
/**
* Cast `n` to a `i16`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/int-template/i32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod inst {
pub const bits: uint = ::u32::bits;
}

pub impl NumCast for i32 {
impl NumCast for i32 {
/**
* Cast `n` to a `i32`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/int-template/i64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod inst {
pub const bits: uint = ::u64::bits;
}

pub impl NumCast for i64 {
impl NumCast for i64 {
/**
* Cast `n` to a `i64`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/int-template/i8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod inst {
pub const bits: uint = ::u8::bits;
}

pub impl NumCast for i8 {
impl NumCast for i8 {
/**
* Cast `n` to a `i8`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/int-template/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mod inst {
}
}

pub impl NumCast for int {
impl NumCast for int {
/**
* Cast `n` to a `int`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/uint-template/u16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod inst {
pub const bits: uint = 16;
}

pub impl NumCast for u16 {
impl NumCast for u16 {
/**
* Cast `n` to a `u16`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/uint-template/u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod inst {
pub const bits: uint = 32;
}

pub impl NumCast for u32 {
impl NumCast for u32 {
/**
* Cast `n` to a `u32`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/uint-template/u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod inst {
pub const bits: uint = 64;
}

pub impl NumCast for u64 {
impl NumCast for u64 {
/**
* Cast `n` to a `u64`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/uint-template/u8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod inst {
pub pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; }
}

pub impl NumCast for u8 {
impl NumCast for u8 {
/**
* Cast `n` to a `u8`
*/
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/uint-template/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub mod inst {
return true;
}

pub impl iter::Times for uint {
impl iter::Times for uint {
#[inline(always)]
/**
* A convenience form for basic iteration. Given a uint `x`,
Expand Down Expand Up @@ -209,7 +209,7 @@ pub mod inst {
}
}

pub impl NumCast for uint {
impl NumCast for uint {
/**
* Cast `n` to a `uint`
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub enum Option<T> {
Some(T),
}

pub impl<T:Ord> Ord for Option<T> {
impl<T:Ord> Ord for Option<T> {
pure fn lt(&self, other: &Option<T>) -> bool {
match (self, other) {
(&None, &None) => false,
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub mod win32 {
let mut done = false;
while !done {
let mut k: DWORD = 0;
let buf = vec::cast_to_mut(vec::from_elem(n as uint, 0u16));
let mut buf = vec::from_elem(n as uint, 0u16);
do vec::as_mut_buf(buf) |b, _sz| {
k = f(b, TMPBUF_SZ as DWORD);
if k == (0 as DWORD) {
Expand Down
16 changes: 8 additions & 8 deletions src/libcore/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
use cmp::{Eq, Ord};

#[cfg(notest)]
impl<T:Eq> Eq for ~const T {
impl<T:Eq> Eq for ~T {
#[inline(always)]
pure fn eq(&self, other: &~const T) -> bool { *(*self) == *(*other) }
pure fn eq(&self, other: &~T) -> bool { *(*self) == *(*other) }
#[inline(always)]
pure fn ne(&self, other: &~const T) -> bool { *(*self) != *(*other) }
pure fn ne(&self, other: &~T) -> bool { *(*self) != *(*other) }
}

#[cfg(notest)]
impl<T:Ord> Ord for ~const T {
impl<T:Ord> Ord for ~T {
#[inline(always)]
pure fn lt(&self, other: &~const T) -> bool { *(*self) < *(*other) }
pure fn lt(&self, other: &~T) -> bool { *(*self) < *(*other) }
#[inline(always)]
pure fn le(&self, other: &~const T) -> bool { *(*self) <= *(*other) }
pure fn le(&self, other: &~T) -> bool { *(*self) <= *(*other) }
#[inline(always)]
pure fn ge(&self, other: &~const T) -> bool { *(*self) >= *(*other) }
pure fn ge(&self, other: &~T) -> bool { *(*self) >= *(*other) }
#[inline(always)]
pure fn gt(&self, other: &~const T) -> bool { *(*self) > *(*other) }
pure fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) }
}

2 changes: 1 addition & 1 deletion src/libcore/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ pub trait OwnedStr {
fn push_char(&mut self, c: char);
}

pub impl OwnedStr for ~str {
impl OwnedStr for ~str {
fn push_str(&mut self, v: &str) {
push_str(self, v);
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/to_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl IterBytes for char {
pub mod x32 {
use to_bytes::{Cb, IterBytes};

pub impl IterBytes for uint {
impl IterBytes for uint {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u32).iter_bytes(lsb0, f)
Expand All @@ -182,7 +182,7 @@ pub mod x32 {
pub mod x64 {
use to_bytes::{Cb, IterBytes};

pub impl IterBytes for uint {
impl IterBytes for uint {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u64).iter_bytes(lsb0, f)
Expand Down
45 changes: 8 additions & 37 deletions src/libcore/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,6 @@ pub pure fn build_sized_opt<A>(size: Option<uint>,
build_sized(size.get_or_default(4), builder)
}

/// Produces a mut vector from an immutable vector.
pub pure fn cast_to_mut<T>(v: ~[T]) -> ~[mut T] {
unsafe { ::cast::transmute(v) }
}

/// Produces an immutable vector from a mut vector.
pub pure fn cast_from_mut<T>(v: ~[mut T]) -> ~[T] {
unsafe { ::cast::transmute(v) }
}

// Accessors

/// Returns the first element of a vector
Expand Down Expand Up @@ -274,9 +264,10 @@ pub pure fn slice<T>(v: &r/[T], start: uint, end: uint) -> &r/[T] {

/// Return a slice that points into another slice.
#[inline(always)]
pub pure fn mut_slice<T>(v: &r/[mut T], start: uint,
end: uint) -> &r/[mut T] {

pub pure fn mut_slice<T>(v: &r/mut [T],
start: uint,
end: uint)
-> &r/mut [T] {
assert (start <= end);
assert (end <= len(v));
do as_mut_buf(v) |p, _len| {
Expand All @@ -290,8 +281,10 @@ pub pure fn mut_slice<T>(v: &r/[mut T], start: uint,

/// Return a slice that points into another slice.
#[inline(always)]
pub pure fn const_slice<T>(v: &r/[const T], start: uint,
end: uint) -> &r/[const T] {
pub pure fn const_slice<T>(v: &r/[const T],
start: uint,
end: uint)
-> &r/[const T] {
assert (start <= end);
assert (end <= len(v));
do as_const_buf(v) |p, _len| {
Expand Down Expand Up @@ -3337,28 +3330,6 @@ mod tests {
let _x = windowed (0u, ~[1u,2u,3u,4u,5u,6u]);
}

#[test]
fn cast_to_mut_no_copy() {
unsafe {
let x = ~[1, 2, 3];
let addr = raw::to_ptr(x);
let x_mut = cast_to_mut(x);
let addr_mut = raw::to_ptr(x_mut);
assert addr == addr_mut;
}
}

#[test]
fn cast_from_mut_no_copy() {
unsafe {
let x = ~[mut 1, 2, 3];
let addr = raw::to_ptr(x);
let x_imm = cast_from_mut(x);
let addr_imm = raw::to_ptr(x_imm);
assert addr == addr_imm;
}
}

#[test]
fn test_unshift() {
let mut x = ~[1, 2, 3];
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ impl LoanKind {

/// Creates and returns a new root_map

pub impl to_bytes::IterBytes for root_map_key {
impl to_bytes::IterBytes for root_map_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f);
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ pub trait ast_node {
fn span(&self) -> span;
}

pub impl ast_node for @ast::expr {
impl ast_node for @ast::expr {
fn id(&self) -> ast::node_id { self.id }
fn span(&self) -> span { self.span }
}

pub impl ast_node for @ast::pat {
impl ast_node for @ast::pat {
fn id(&self) -> ast::node_id { self.id }
fn span(&self) -> span { self.span }
}
Expand All @@ -295,7 +295,7 @@ pub trait get_type_for_node {
fn ty<N:ast_node>(&self, node: N) -> ty::t;
}

pub impl get_type_for_node for ty::ctxt {
impl get_type_for_node for ty::ctxt {
fn ty<N:ast_node>(&self, node: N) -> ty::t {
ty::node_id_to_type(*self, node.id())
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub trait get_insn_ctxt {
fn insn_ctxt(&self, s: &str) -> icx_popper;
}

pub impl get_insn_ctxt for @CrateContext {
impl get_insn_ctxt for @CrateContext {
fn insn_ctxt(&self, s: &str) -> icx_popper {
debug!("new insn_ctxt: %s", s);
if self.sess.count_llvm_insns() {
Expand All @@ -117,13 +117,13 @@ pub impl get_insn_ctxt for @CrateContext {
}
}

pub impl get_insn_ctxt for block {
impl get_insn_ctxt for block {
fn insn_ctxt(&self, s: &str) -> icx_popper {
self.ccx().insn_ctxt(s)
}
}

pub impl get_insn_ctxt for fn_ctxt {
impl get_insn_ctxt for fn_ctxt {
fn insn_ctxt(&self, s: &str) -> icx_popper {
self.ccx.insn_ctxt(s)
}
Expand Down
Loading