Skip to content
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

Remove deriving(ToStr) #12412

Merged
merged 2 commits into from
Feb 24, 2014
Merged

Remove deriving(ToStr) #12412

merged 2 commits into from
Feb 24, 2014

Commits on Feb 24, 2014

  1. Remove all ToStr impls, add Show impls

    This commit changes the ToStr trait to:
    
        impl<T: fmt::Show> ToStr for T {
            fn to_str(&self) -> ~str { format!("{}", *self) }
        }
    
    The ToStr trait has been on the chopping block for quite awhile now, and this is
    the final nail in its coffin. The trait and the corresponding method are not
    being removed as part of this commit, but rather any implementations of the
    `ToStr` trait are being forbidden because of the generic impl. The new way to
    get the `to_str()` method to work is to implement `fmt::Show`.
    
    Formatting into a `&mut Writer` (as `format!` does) is much more efficient than
    `ToStr` when building up large strings. The `ToStr` trait forces many
    intermediate allocations to be made while the `fmt::Show` trait allows
    incremental buildup in the same heap allocated buffer. Additionally, the
    `fmt::Show` trait is much more extensible in terms of interoperation with other
    `Writer` instances and in more situations. By design the `ToStr` trait requires
    at least one allocation whereas the `fmt::Show` trait does not require any
    allocations.
    
    Closes rust-lang#8242
    Closes rust-lang#9806
    alexcrichton committed Feb 24, 2014
    Configuration menu
    Copy the full SHA
    b78b749 View commit details
    Browse the repository at this point in the history
  2. Remove deriving(ToStr)

    This has been superseded by deriving(Show).
    
    cc rust-lang#9806
    alexcrichton committed Feb 24, 2014
    9 Configuration menu
    Copy the full SHA
    8761f79 View commit details
    Browse the repository at this point in the history