1. 06 11月, 2014 12 次提交
    • J
      4c3b4227
    • J
      1e5f311d
    • J
      DSTify PartialEq, PartialOrd, Eq, Ord · 28962783
      Jorge Aparicio 提交于
      28962783
    • J
      1a943754
    • J
      88ed2d1c
    • B
      auto merge of #18486 : nikomatsakis/rust/operator-dispatch, r=pcwalton · 63c4f22f
      bors 提交于
      This branch cleans up overloaded operator resolution so that it is strictly based on the traits in `ops`, rather than going through the normal method lookup mechanism. It also adds full support for autoderef to overloaded index (whereas before autoderef only worked for non-overloaded index) as well as for the slicing operators.
      
      This is a [breaking-change]: in the past, we were accepting combinations of operands that were not intended to be accepted. For example, it was possible to compare a fixed-length array and a slice, or apply the `!` operator to a `&int`. See the first two commits in this pull-request for examples.
      
      One downside of this change is that comparing fixed-length arrays doesn't always work as smoothly as it did before. Before this, comparisons sometimes worked due to various coercions to slices. I've added impls for `Eq`, `Ord`, etc for fixed-lengths arrays up to and including length 32, but if the array is longer than that you'll need to either newtype the array or convert to slices. Note that this plays better with deriving in any case than the previous scheme.
      
      Fixes #4920.
      Fixes #16821.
      Fixes #15757.
      
      cc @alexcrichton 
      cc @aturon 
      63c4f22f
    • B
      auto merge of #18462 : netvl/rust/to-socket-addr, r=alexcrichton · 5c1fd5f8
      bors 提交于
      This is a follow-up to [RFC PR #173](https://github.com/rust-lang/rfcs/pull/173). I was told there that changes like this don't need to go through the RFC process, so I'm submitting this directly.
      
      This PR introduces `ToSocketAddr` trait as defined in said RFC. This trait defines a conversion from different types like `&str`, `(&str, u16)` or even `SocketAddr` to `SocketAddr`. Then this trait is used in all constructor methods for `TcpStream`, `TcpListener` and `UdpSocket`.
      
      This unifies these constructor methods - previously they were using different types of input parameters (TCP ones used `(&str, u16)` pair while UDP ones used `SocketAddr`), which is not consistent by itself and sometimes inconvenient - for example, when the address initially is available as `SocketAddr`, you still need to convert it to string to pass it to e.g. `TcpStream`. This is very prominently demonstrated by the unit tests for TCP functionality. This PR makes working with network objects much like with `Path`, which also uses similar trait to be able to be constructed from `&[u8]`, `Vec<u8>` and other `Path`s.
      
      This is a breaking change. If constant literals were used before, like this:
      ```rust
      TcpStream::connect("localhost", 12345)
      ```
      then the nicest fix is to change it to this:
      ```rust
      TcpStream::connect("localhost:12345")
      ```
      
      If variables were used before, like this:
      ```rust
      TcpStream::connect(some_address, some_port)
      ```
      then the arguments should be wrapped in another set of parentheses:
      ```rust
      TcpStream::connect((some_address, some_port))
      ```
      
      `UdpSocket` usages won't break because its constructor method accepted `SocketAddr` which implements `ToSocketAddr`, so `bind()` calls:
      ```rust
      UdpSocket::bind(some_socket_addr)
      ```
      will continue working as before.
      
      I haven't changed `UdpStream` constructor because it is deprecated anyway.
      5c1fd5f8
    • N
      Better debug printouts · 81c00e66
      Niko Matsakis 提交于
      81c00e66
    • N
    • N
      Update the guide examples and try not to leave user hanging as to what · 63718792
      Niko Matsakis 提交于
      this `&x` sigil is all about.
      63718792
    • N
      Implement new operator dispatch semantics. · 0b5bc331
      Niko Matsakis 提交于
      Key points are:
      1. `a + b` maps directly to `Add<A,B>`, where `A` and `B` are the types of `a` and `b`.
      2. Indexing and slicing autoderefs consistently.
      0b5bc331
    • V
      Fixed not compiling code in docstring · 0f610f3c
      Vladimir Matveev 提交于
      0f610f3c
  2. 05 11月, 2014 19 次提交
  3. 04 11月, 2014 9 次提交