1. 01 8月, 2014 24 次提交
    • K
      Add is_unique(), try_unwrap(), get_mut() to alloc::rc · 192a8a5d
      Kevin Ballard 提交于
      Add a few new free functions to alloc::rc for manipulating
      uniquely-owned Rc values. is_unique() can be used to test if the Rc is
      uniquely-owned, try_unwrap() can remove the value from a uniquely-owned
      Rc, and get_mut() can return a &mut for a uniquely-owned Rc.
      
      These are all free functions, because smart pointers should avoid having
      methods when possible. They can't be static methods because UFCS will
      remove that distinction. I think we should probably change downgrade()
      and make_unique() into free functions as well, but that's out of scope.
      192a8a5d
    • A
    • A
      libserialize: add `error()` to `Decoder` · 5bd8edc1
      Andrew Poelstra 提交于
      A quick and dirty fix for #15036 until we get serious decoder reform.
      
      Right now it is impossible for a Decodable to signal a decode error,
      for example if it has only finitely many allowed values, is a string
      which must be encoded a certain way, needs a valid checksum, etc. For
      example in the libuuid implementation of Decodable an Option is
      unwrapped, meaning that a decode of a malformed UUID will cause the
      task to fail.
      
      Since this adds a method to the `Decoder` trait, all users will need
      to update their implementations to add it. The strategy used for the
      current implementations for JSON and EBML is to add a new entry to
      the error enum `ApplicationError(String)` which stores the string
      provided to `.error()`.
      
      [breaking-change]
      5bd8edc1
    • K
      Stop using the Show impl for ast::Name in our symbols · ff3d902f
      Kevin Ballard 提交于
      When generating a unique symbol for things like closures or glue_drop,
      we call token::gensym() to create a crate-unique Name. Recently, Name
      changed its Show impl so it no longer prints as a number. This caused
      symbols like glue_drop:1542 to become glue_drop:"glue_drop"(1542), or in
      mangled form, glue_drop.$x22glue_drop$x22$LP$1542$RP$.
      ff3d902f
    • T
      doc: fix typos in std::num::Int · 4dc323f0
      Tshepang Lekhonkhobe 提交于
      4dc323f0
    • K
      Add some benchmarks for TLD · e65bcff7
      Kevin Ballard 提交于
      e65bcff7
    • K
      Tweak error reporting in io::net::tcp tests · 24a62e17
      Kevin Ballard 提交于
      Errors can be printed with {}, printing with {:?} does not work very
      well.
      
      Not actually related to this PR, but it came up when running the tests
      and now is as good a time to fix it as any.
      24a62e17
    • K
      Rewrite the local_data implementation · 4b74dc16
      Kevin Ballard 提交于
      This was motivated by a desire to remove allocation in the common
      pattern of
      
          let old = key.replace(None)
          do_something();
          key.replace(old);
      
      This also switched the map representation from a Vec to a TreeMap. A Vec
      may be reasonable if there's only a couple TLD keys, but a TreeMap
      provides better behavior as the number of keys increases.
      
      Like the Vec, this TreeMap implementation does not shrink the container
      when a value is removed. Unlike Vec, this TreeMap implementation cannot
      reuse an empty node for a different key. Therefore any key that has been
      inserted into the TLD at least once will continue to take up space in
      the Map until the task ends. The expectation is that the majority of
      keys that are inserted into TLD will be expected to have a value for
      most of the rest of the task's lifetime. If this assumption is wrong,
      there are two reasonable ways to fix this that could be implemented in
      the future:
      
      1. Provide an API call to either remove a specific key from the TLD and
         destruct its node (e.g. `remove()`), or instead to explicitly clean
         up all currently-empty nodes in the map (e.g. `compact()`). This is
         simple, but requires the user to explicitly call it.
      2. Keep track of the number of empty nodes in the map and when the map
         is mutated (via `replace()`), if the number of empty nodes passes
         some threshold, compact it automatically. Alternatively, whenever a
         new key is inserted that hasn't been used before, compact the map at
         that point.
      
      ---
      
      Benchmarks:
      
      I ran 3 benchmarks. tld_replace_none just replaces the tld key with None
      repeatedly. tld_replace_some replaces it with Some repeatedly. And
      tld_replace_none_some simulates the common behavior of replacing with
      None, then replacing with the previous value again (which was a Some).
      
      Old implementation:
      
          test tld_replace_none      ... bench:        20 ns/iter (+/- 0)
          test tld_replace_none_some ... bench:        77 ns/iter (+/- 4)
          test tld_replace_some      ... bench:        57 ns/iter (+/- 2)
      
      New implementation:
      
          test tld_replace_none      ... bench:        11 ns/iter (+/- 0)
          test tld_replace_none_some ... bench:        23 ns/iter (+/- 0)
          test tld_replace_some      ... bench:        12 ns/iter (+/- 0)
      4b74dc16
    • A
      Test fixes from the rollup · ec79d368
      Alex Crichton 提交于
      Closes #16097 (fix variable name in tutorial)
      Closes #16100 (More defailbloating)
      Closes #16104 (Fix deprecation commment on `core::cmp::lexical_ordering`)
      Closes #16105 (fix formatting in pointer guide table)
      Closes #16107 (remove serialize::ebml, add librbml)
      Closes #16108 (Fix heading levels in pointer guide)
      Closes #16109 (rustrt: Don't conditionally init the at_exit QUEUE)
      Closes #16111 (hexfloat: Deprecate to move out of the repo)
      Closes #16113 (Add examples for GenericPath methods.)
      Closes #16115 (Byte literals!)
      Closes #16116 (Add a non-regression test for issue #8372)
      Closes #16120 (Deprecate semver)
      Closes #16124 (Deprecate uuid)
      Closes #16126 (Deprecate fourcc)
      Closes #16127 (Remove incorrect example)
      Closes #16129 (Add note about production deployments.)
      Closes #16131 (librustc: Don't ICE when trying to subst regions in destructor call.)
      Closes #16133 (librustc: Don't ICE with struct exprs where the name is not a valid struct.)
      Closes #16136 (Implement slice::Vector for Option<T> and CVec<T>)
      Closes #16137 (alloc, arena, test, url, uuid: Elide lifetimes.)
      ec79d368
    • O
      f8618486
    • D
      Implement slice::Vector for Option<T> and CVec<T> · 2467c6e5
      Derek Harland 提交于
      2467c6e5
    • L
    • L
    • S
      Add note about production deployments. · fd08d5fb
      Steve Klabnik 提交于
      Fixes #11511.
      fd08d5fb
    • S
      Remove incorrect example · daaa20e5
      Steve Klabnik 提交于
      This now works because of elision.
      
      Fixes #16117
      daaa20e5
    • I
      Deprecate fourcc. · a5e74a93
      Ilya Dmitrichenko 提交于
      a5e74a93
    • I
      Deprecate uuid. · a8f58a05
      Ilya Dmitrichenko 提交于
      a8f58a05
    • I
      Deprecate semver. · 5446aed2
      Ilya Dmitrichenko 提交于
      5446aed2
    • S
      Add a non-regression test for issue #8372 · cdb8a887
      Simon Sapin 提交于
      cdb8a887
    • S
      Byte literals! · efd42a35
      Simon Sapin 提交于
      efd42a35
    • N
    • N
    • N
      Add examples for GenericPath methods. · 9956aff1
      nham 提交于
      9956aff1
    • A
      hexfloat: Deprecate to move out of the repo · c3fcc0bc
      Alex Crichton 提交于
      This deprecates the hexfloat library as it is now located in the rust-lang
      organization as a cargo package
      c3fcc0bc
  2. 31 7月, 2014 16 次提交