summary refs log tree commit diff
path: root/src/libstd/io/comm_adapters.rs
AgeCommit message (Collapse)AuthorLines
2014-10-07Use slice syntax instead of slice_to, etc.Nick Cameron-5/+4
2014-10-02Revert "Use slice syntax instead of slice_to, etc."Aaron Turon-4/+5
This reverts commit 40b9f5ded50ac4ce8c9323921ec556ad611af6b7.
2014-10-02Use slice syntax instead of slice_to, etc.Nick Cameron-5/+4
2014-09-21Fix fallout from Vec stabilizationAlex Crichton-2/+2
2014-09-16Fallout from renamingAaron Turon-1/+1
2014-08-26Use temp vars for implicit coercion to ^[T]Nick Cameron-5/+8
2014-08-13std: Rename various slice traits for consistencyBrian Anderson-1/+1
ImmutableVector -> ImmutableSlice ImmutableEqVector -> ImmutableEqSlice ImmutableOrdVector -> ImmutableOrdSlice MutableVector -> MutableSlice MutableVectorAllocating -> MutableSliceAllocating MutableCloneableVector -> MutableCloneableSlice MutableOrdVector -> MutableOrdSlice These are all in the prelude so most code will not break. [breaking-change]
2014-06-28librustc: Match trait self types exactly.Patrick Walton-1/+4
This can break code that looked like: impl Foo for Box<Any> { fn f(&self) { ... } } let x: Box<Any + Send> = ...; x.f(); Change such code to: impl Foo for Box<Any> { fn f(&self) { ... } } let x: Box<Any> = ...; x.f(); That is, upcast before calling methods. This is a conservative solution to #5781. A more proper treatment (see the xfail'd `trait-contravariant-self.rs`) would take variance into account. This change fixes the soundness hole. Some library changes had to be made to make this work. In particular, `Box<Any>` is no longer showable, and only `Box<Any+Send>` is showable. Eventually, this restriction can be lifted; for now, it does not prove too onerous, because `Any` is only used for propagating the result of task failure. This patch also adds a test for the variance inference work in #12828, which accidentally landed as part of DST. Closes #5781. [breaking-change]
2014-06-11rustc: Remove ~[T] from the languageAlex Crichton-4/+4
The following features have been removed * box [a, b, c] * ~[a, b, c] * box [a, ..N] * ~[a, ..N] * ~[T] (as a type) * deprecated_owned_vector lint All users of ~[T] should move to using Vec<T> instead.
2014-06-09auto merge of #14709 : alexcrichton/rust/collections, r=brsonbors-1/+1
This is mostly just a cosmetic change, continuing the work from #14333.
2014-06-08core: Rename `container` mod to `collections`. Closes #12543Brian Anderson-1/+1
Also renames the `Container` trait to `Collection`. [breaking-change]
2014-06-09Converted PortReader and ChanWriter to use Vec.Raphael Speyer-22/+23
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-12/+12
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-0/+1
2014-04-14Use new attribute syntax in python files in src/etc too (#13478)Manish Goregaokar-1/+1
2014-04-10std: Make std::comm return types consistentAlex Crichton-7/+5
There are currently a number of return values from the std::comm methods, not all of which are necessarily completely expressive: Sender::try_send(t: T) -> bool This method currently doesn't transmit back the data `t` if the send fails due to the other end having disconnected. Additionally, this shares the name of the synchronous try_send method, but it differs in semantics in that it only has one failure case, not two (the buffer can never be full). SyncSender::try_send(t: T) -> TrySendResult<T> This method accurately conveys all possible information, but it uses a custom type to the std::comm module with no convenience methods on it. Additionally, if you want to inspect the result you're forced to import something from `std::comm`. SyncSender::send_opt(t: T) -> Option<T> This method uses Some(T) as an "error value" and None as a "success value", but almost all other uses of Option<T> have Some/None the other way Receiver::try_recv(t: T) -> TryRecvResult<T> Similarly to the synchronous try_send, this custom return type is lacking in terms of usability (no convenience methods). With this number of drawbacks in mind, I believed it was time to re-work the return types of these methods. The new API for the comm module is: Sender::send(t: T) -> () Sender::send_opt(t: T) -> Result<(), T> SyncSender::send(t: T) -> () SyncSender::send_opt(t: T) -> Result<(), T> SyncSender::try_send(t: T) -> Result<(), TrySendError<T>> Receiver::recv() -> T Receiver::recv_opt() -> Result<T, ()> Receiver::try_recv() -> Result<T, TryRecvError> The notable changes made are: * Sender::try_send => Sender::send_opt. This renaming brings the semantics in line with the SyncSender::send_opt method. An asychronous send only has one failure case, unlike the synchronous try_send method which has two failure cases (full/disconnected). * Sender::send_opt returns the data back to the caller if the send is guaranteed to fail. This method previously returned `bool`, but then it was unable to retrieve the data if the data was guaranteed to fail to send. There is still a race such that when `Ok(())` is returned the data could still fail to be received, but that's inherent to an asynchronous channel. * Result is now the basis of all return values. This not only adds lots of convenience methods to all return values for free, but it also means that you can inspect the return values with no extra imports (Ok/Err are in the prelude). Additionally, it's now self documenting when something failed or not because the return value has "Err" in the name. Things I'm a little uneasy about: * The methods send_opt and recv_opt are not returning options, but rather results. I felt more strongly that Option was the wrong return type than the _opt prefix was wrong, and I coudn't think of a much better name for these methods. One possible way to think about them is to read the _opt suffix as "optionally". * Result<T, ()> is often better expressed as Option<T>. This is only applicable to the recv_opt() method, but I thought it would be more consistent for everything to return Result rather than one method returning an Option. Despite my two reasons to feel uneasy, I feel much better about the consistency in return values at this point, and I think the only real open question is if there's a better suffix for {send,recv}_opt. Closes #11527
2014-03-31std: Switch field privacy as necessaryAlex Crichton-5/+5
2014-03-20rename std::vec -> std::sliceDaniel Micay-1/+1
Closes #12702
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-38/+39
* Chan<T> => Sender<T> * Port<T> => Receiver<T> * Chan::new() => channel() * constructor returns (Sender, Receiver) instead of (Receiver, Sender) * local variables named `port` renamed to `rx` * local variables named `chan` renamed to `tx` Closes #11765
2014-02-28std: Improve some I/O documentationAlex Crichton-1/+3
This lowers the #[allow(missing_doc)] directive into some of the lower modules which are less mature. Most I/O modules now require comprehensive documentation.
2014-02-14Fix all code examplesAlex Crichton-4/+13
2014-02-14extra: Capture stdout/stderr of tests by defaultAlex Crichton-0/+6
When tests fail, their stdout and stderr is printed as part of the summary, but this helps suppress failure messages from #[should_fail] tests and generally clean up the output of the test runner.
2014-02-03std: Fix tests with io_error usageAlex Crichton-28/+17
2014-02-03std: Remove io::io_errorAlex Crichton-8/+9
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-01-29auto merge of #11893 : Armavica/rust/copyable-cloneable, r=huonwbors-1/+1
I found awkward to have `MutableCloneableVector` and `CloneableIterator` on the one hand, and `CopyableVector` etc. on the other hand. The concerned traits are: * `CopyableVector` --> `CloneableVector` * `OwnedCopyableVector` --> `OwnedCloneableVector` * `ImmutableCopyableVector` --> `ImmutableCloneableVector` * `CopyableTuple` --> `CloneableTuple`
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-3/+3
2014-01-28Rename CopyableVector to CloneableVectorVirgile Andreani-1/+1
2014-01-09Remove eof() from io::ReaderAlex Crichton-9/+0
2013-12-26std: remove some test warningsErick Tryzelaar-2/+1
2013-12-19Get comm_adapters building againAlex Crichton-2/+2
I accidentally removed this module from compilation awhile back, this adds it back in. Closes #11076
2013-12-16Fallout of rewriting std::commAlex Crichton-35/+13
2013-12-15std::vec: remove unnecessary count parameter on {bytes,Huon Wilson-1/+1
raw}::copy_memory. Slices carry their length with them, so we can just use that information.
2013-12-10Implement PortReader and ChanWriterRaphael Speyer-11/+172
2013-12-08Remove dead codesKiet Tran-4/+4
2013-11-11Move std::rt::io to std::ioAlex Crichton-0/+57