Skip to content

Commit e1d3a4f

Browse files
committed
auto merge of #5156 : pcwalton/rust/method-privacy, r=pcwalton
r? @brson
2 parents b171d0e + 2859c1a commit e1d3a4f

File tree

123 files changed

+349
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+349
-214
lines changed

doc/tutorial.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,11 +2304,10 @@ mod farm {
23042304
farmer: Human
23052305
}
23062306
2307-
// Note - visibility modifiers on impls currently have no effect
23082307
impl Farm {
23092308
priv fn feed_chickens(&self) { ... }
23102309
priv fn feed_cows(&self) { ... }
2311-
fn add_chicken(&self, c: Chicken) { ... }
2310+
pub fn add_chicken(&self, c: Chicken) { ... }
23122311
}
23132312
23142313
pub fn feed_animals(farm: &Farm) {

src/libcore/cell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub pure fn empty_cell<T>() -> Cell<T> {
2828
Cell { value: None }
2929
}
3030

31-
impl<T> Cell<T> {
31+
pub impl<T> Cell<T> {
3232
/// Yields the value, failing if the cell is empty.
3333
fn take() -> T {
3434
if self.is_empty() {

src/libcore/comm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub fn PortSet<T: Owned>() -> PortSet<T>{
190190
}
191191
}
192192
193-
impl<T: Owned> PortSet<T> {
193+
pub impl<T: Owned> PortSet<T> {
194194
195195
fn add(port: Port<T>) {
196196
self.ports.push(port)
@@ -323,12 +323,12 @@ pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
323323
(port, chan)
324324
}
325325
326-
impl<T: Owned> PortOne<T> {
326+
pub impl<T: Owned> PortOne<T> {
327327
fn recv(self) -> T { recv_one(self) }
328328
fn try_recv(self) -> Option<T> { try_recv_one(self) }
329329
}
330330
331-
impl<T: Owned> ChanOne<T> {
331+
pub impl<T: Owned> ChanOne<T> {
332332
fn send(self, data: T) { send_one(self, data) }
333333
fn try_send(self, data: T) -> bool { try_send_one(self, data) }
334334
}

src/libcore/condition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub struct Condition<T, U> {
2525
key: task::local_data::LocalDataKey<Handler<T, U>>
2626
}
2727

28-
impl<T, U> Condition<T, U> {
28+
pub impl<T, U> Condition<T, U> {
2929
fn trap(&self, h: &self/fn(T) -> U) -> Trap/&self<T, U> {
3030
unsafe {
3131
let p : *RustClosure = ::cast::transmute(&h);
@@ -69,7 +69,7 @@ struct Trap<T, U> {
6969
handler: @Handler<T, U>
7070
}
7171

72-
impl<T, U> Trap<T, U> {
72+
pub impl<T, U> Trap<T, U> {
7373
fn in<V>(&self, inner: &self/fn() -> V) -> V {
7474
unsafe {
7575
let _g = Guard { cond: self.cond };

src/libcore/dlist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ priv impl<T> DListNode<T> {
6262
}
6363
}
6464
65-
impl<T> DListNode<T> {
65+
pub impl<T> DListNode<T> {
6666
/// Get the next node in the list, if there is one.
6767
pure fn next_link(@mut self) -> DListLink<T> {
6868
self.assert_links();
@@ -208,7 +208,7 @@ priv impl<T> DList<T> {
208208
}
209209
}
210210
211-
impl<T> DList<T> {
211+
pub impl<T> DList<T> {
212212
/// Get the size of the list. O(1).
213213
pure fn len(@mut self) -> uint { self.size }
214214
/// Returns true if the list is empty. O(1).
@@ -457,7 +457,7 @@ impl<T> DList<T> {
457457
}
458458
}
459459

460-
impl<T:Copy> DList<T> {
460+
pub impl<T:Copy> DList<T> {
461461
/// Remove data from the head of the list. O(1).
462462
fn pop(@mut self) -> Option<T> {
463463
self.pop_n().map(|nobe| nobe.data)

src/libcore/dvec.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,6 @@ priv impl<A> DVec<A> {
9292
}
9393
}
9494
95-
#[inline(always)]
96-
fn check_out<B>(f: &fn(v: ~[A]) -> B) -> B {
97-
unsafe {
98-
let mut data = cast::reinterpret_cast(&null::<()>());
99-
data <-> self.data;
100-
let data_ptr: *() = cast::reinterpret_cast(&data);
101-
if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
102-
return f(data);
103-
}
104-
}
105-
10695
#[inline(always)]
10796
fn give_back(data: ~[A]) {
10897
unsafe {
@@ -117,7 +106,19 @@ priv impl<A> DVec<A> {
117106
// In theory, most everything should work with any A, but in practice
118107
// almost nothing works without the copy bound due to limitations
119108
// around closures.
120-
impl<A> DVec<A> {
109+
pub impl<A> DVec<A> {
110+
// FIXME (#3758): This should not need to be public.
111+
#[inline(always)]
112+
fn check_out<B>(f: &fn(v: ~[A]) -> B) -> B {
113+
unsafe {
114+
let mut data = cast::reinterpret_cast(&null::<()>());
115+
data <-> self.data;
116+
let data_ptr: *() = cast::reinterpret_cast(&data);
117+
if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
118+
return f(data);
119+
}
120+
}
121+
121122
/// Reserves space for N elements
122123
fn reserve(count: uint) {
123124
vec::reserve(&mut self.data, count)
@@ -215,7 +216,7 @@ impl<A> DVec<A> {
215216
}
216217
}
217218
218-
impl<A:Copy> DVec<A> {
219+
pub impl<A:Copy> DVec<A> {
219220
/**
220221
* Append all elements of a vector to the end of the list
221222
*

src/libcore/mutable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn unwrap<T>(m: Mut<T>) -> T {
4343
value
4444
}
4545

46-
impl<T> Data<T> {
46+
pub impl<T> Data<T> {
4747
fn borrow_mut<R>(op: &fn(t: &mut T) -> R) -> R {
4848
match self.mode {
4949
Immutable => fail!(fmt!("%? currently immutable",

src/libcore/option.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ pub pure fn expect<T>(opt: Option<T>, reason: &str) -> T {
281281
}
282282
}
283283
284-
impl<T> Option<T> {
284+
pub impl<T> Option<T> {
285285
/// Returns true if the option equals `none`
286286
#[inline(always)]
287287
pure fn is_none(&self) -> bool { is_none(self) }
@@ -393,7 +393,7 @@ impl<T> Option<T> {
393393
pure fn expect(self, reason: &str) -> T { expect(self, reason) }
394394
}
395395
396-
impl<T:Copy> Option<T> {
396+
pub impl<T:Copy> Option<T> {
397397
/**
398398
Gets the value out of an option
399399
@@ -421,7 +421,7 @@ impl<T:Copy> Option<T> {
421421
}
422422
}
423423
424-
impl<T:Copy + Zero> Option<T> {
424+
pub impl<T:Copy + Zero> Option<T> {
425425
#[inline(always)]
426426
pure fn get_or_zero(self) -> T { get_or_zero(self) }
427427
}

src/libcore/path.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ mod stat {
241241
}
242242

243243

244-
impl Path {
244+
pub impl Path {
245245
fn stat(&self) -> Option<libc::stat> {
246246
unsafe {
247247
do str::as_c_str(self.to_str()) |buf| {
@@ -290,7 +290,7 @@ impl Path {
290290
#[cfg(target_os = "freebsd")]
291291
#[cfg(target_os = "linux")]
292292
#[cfg(target_os = "macos")]
293-
impl Path {
293+
pub impl Path {
294294
fn get_atime(&self) -> Option<(i64, int)> {
295295
match self.stat() {
296296
None => None,
@@ -324,7 +324,7 @@ impl Path {
324324

325325
#[cfg(target_os = "freebsd")]
326326
#[cfg(target_os = "macos")]
327-
impl Path {
327+
pub impl Path {
328328
fn get_birthtime(&self) -> Option<(i64, int)> {
329329
match self.stat() {
330330
None => None,
@@ -337,7 +337,7 @@ impl Path {
337337
}
338338

339339
#[cfg(target_os = "win32")]
340-
impl Path {
340+
pub impl Path {
341341
fn get_atime(&self) -> Option<(i64, int)> {
342342
match self.stat() {
343343
None => None,

src/libcore/pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ pub fn SendPacketBuffered<T,Tbuffer>(p: *Packet<T>)
800800
}
801801
}
802802
803-
impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
803+
pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
804804
fn unwrap() -> *Packet<T> {
805805
let mut p = None;
806806
p <-> self.p;
@@ -857,7 +857,7 @@ impl<T:Owned,Tbuffer:Owned> ::ops::Drop for RecvPacketBuffered<T,Tbuffer> {
857857
}
858858
}
859859
860-
impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
860+
pub impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
861861
fn unwrap() -> *Packet<T> {
862862
let mut p = None;
863863
p <-> self.p;

0 commit comments

Comments
 (0)