These are chat archives for rust-lang/rust
unsafein Rust is isolated from the consumer: "here is my module, the implementation uses
unsafeinside, but you don't need to care, all the external interfaces are safe".
Vecs which look safe, but actually are not. There's a contract that memory safety depends upon - "just mutating the vectors w/o pushing or removing any item" - that the function's consumer needs to follow, but the compiler knows nothing about and cannot enforce.
@tanriol so remember a while ago I asked about a
CoerceToSomeTrait trait and you suggested any? I have this https://play.rust-lang.org/?gist=78aa0cbbe3e658dcd511994e117b55f4&version=nightly but it only works for stuff where you have the concrete type -- I.e I can't do
let x: &TraitB = &MyStruct; x.coerce().unwrap();
Any suggestions? I don't want to use Any preferably because it limits usages to
let x: &TraitA = &MyStruct, it contains a pointer to the object and a pointer to the vtable of the
impl TraitA for MyStruct. However, that vtable knows nothing about
TraitBand does not contain a vtable pointer for the
impl TraitB for MyStruct.
'staticlimitation is very simple: the lifetimes information is not available at runtime at all. As a result, Rust can't check during downcasting whether the lifetime you suggest is valid or not.