mozilla/rust — pull request #14217 by chris-morgan (2014-05-15 01:02:52+00:00)
Title: Add methods for unchecked casting of Any objects.

This is definitely unsafe behaviour, but for certain cases it can be
useful, such as when boxing a value and immediately wanting a reference
to the value as the appropriate type, or when one has already used `is`
and is thus certain of the type and so wishes to skip the redundant
check.

It'd be handy if we could then implement the checked ones (`as_ref`,
`as_mut_ref` and `move`) on the traits as default methods, but no can do
there, because of the `is(self)` method calling: an implementation for
the trait objects it will autoreborrow, but in a default implementation
it will consume, so we can't do it that way without restructuring at
least `is` to take `&self`, which may have other issues (?), and making
`AnyMutRefExt` and `AnyOwnExt` extend `AnyRefExt`.