drop
import std::core::drop; — in the prelude · source
Drop
type trait Drop {
drop(mut &this) -> void;
}
Drop is the destructor: drop(mut &this) -> void, the last operation performed on a value. The compiler synthesises the call at scope exit - including the early exits ? and return take - and a manual .drop() remains available for early release. See Ownership, Copy, and Drop for when the call is inserted and what a move does to it.
Every primitive gets a trivial no-op impl so generic containers can write where K: Drop, V: Drop without locking out useful instantiations like HashMap<u32, V>; when the value carries no resource, the call lowers to no IR at all. The unit type () has one for the same reason - HashSet<T> is a HashMap<T, ()>.
The module is in the prelude because an implement trait Drop for X head has to resolve the trait name in every file that owns a resource, and the compiler reasons about Drop by identity rather than by spelling.
Implementors
Every owning type in the library. The primitive impls are the no-ops described above; the 128-bit and pointer-width integers have no explicit impl and need none.
implement trait Drop for i8
implement trait Drop for i16
implement trait Drop for i32
implement trait Drop for i64
implement trait Drop for u8
implement trait Drop for u16
implement trait Drop for u32
implement trait Drop for u64
implement trait Drop for f32
implement trait Drop for f64
implement trait Drop for boolean
implement trait Drop for char
implement trait Drop for string
implement trait Drop for ()
implement<T, A> trait Drop for struct Arc<T, A>
where T: Drop, A: Allocator // std::alloc::arc
implement<T, A> trait Drop for struct Weak<T, A>
where T: Drop, A: Allocator // std::alloc::arc
implement trait Drop for struct Arena // std::alloc::arena_alloc
implement<T, A> trait Drop for struct Box<T, A>
where T: Drop, A: Allocator // std::alloc::box
implement trait Drop for struct Pool // std::alloc::pool
implement<T, A> trait Drop for struct Rc<T, A>
where T: Drop, A: Allocator // std::alloc::rc
implement<T, A> trait Drop for struct Weak<T, A>
where T: Drop, A: Allocator // std::alloc::rc
implement<T, A> trait Drop for struct Array<T, A>
where T: Drop, A: Allocator // std::collections::array
implement<K, V, A> trait Drop for struct HashMap<K, V, A>
where K: Drop, V: Drop, A: Allocator // std::collections::hashmap
implement<T, A> trait Drop for struct HashSet<T, A>
where T: Drop, A: Allocator // std::collections::hashset
implement<A, B> trait Drop for struct Pair<A, B>
where A: Drop, B: Drop // std::collections::pair
implement<T, A> trait Drop for struct RawBuffer<T, A>
where A: Allocator // std::collections::raw_buffer
implement<A> trait Drop for struct String<A>
where A: Allocator // std::collections::string
implement trait Drop for VaArgs // std::core::varargs
implement trait Drop for struct DirEntry // std::fs::dir
implement trait Drop for struct ReadDir // std::fs::dir
implement trait Drop for struct File // std::fs::file
implement<A> trait Drop for struct PathBuf<A>
where A: Allocator // std::fs::path
implement trait Drop for struct Task // std::future::executor
implement<O> trait Drop for struct JoinHandle<O> // std::future::executor
implement trait Drop for struct Executor // std::future::executor
implement trait Drop for struct Sleep // std::future::timer
implement trait Drop for struct Waker // std::future::waker
implement<W> trait Drop for struct BufWriter<W> // std::io::buf
implement<W> trait Drop for struct LineWriter<W> // std::io::buf
implement<R> trait Drop for struct BufReader<R> // std::io::buf
implement trait Drop for struct BufStream<S> // std::io::buf
implement trait Drop for struct Cursor // std::io::cursor
implement trait Drop for struct StdinLock // std::io::stdio
implement trait Drop for struct StdoutLock // std::io::stdio
implement trait Drop for struct StderrLock // std::io::stdio
implement trait Drop for struct JsonError // std::json::error
implement trait Drop for struct JsonObject // std::json::value
implement trait Drop for enum JsonValue // std::json::value
implement trait Drop for struct Resolve // std::net::dns
implement trait Drop for struct HeaderField // std::net::http2::hpack
implement trait Drop for struct Headers // std::net::http::headers
implement trait Drop for struct Request // std::net::http::request
implement trait Drop for struct Response // std::net::http::response
implement trait Drop for struct Route // std::net::http::router
implement trait Drop for struct Router // std::net::http::router
implement trait Drop for struct TcpRead // std::net::socket::tcp
implement trait Drop for struct TcpWrite // std::net::socket::tcp
implement trait Drop for struct TcpAccept // std::net::socket::tcp
implement trait Drop for struct TcpConnect // std::net::socket::tcp
implement trait Drop for struct UdpSendTo // std::net::socket::udp
implement trait Drop for struct UdpSend // std::net::socket::udp
implement trait Drop for struct UdpRecvFrom // std::net::socket::udp
implement trait Drop for struct UdpRecv // std::net::socket::udp
implement trait Drop for struct TlsHandshake // std::net::tls::future
implement trait Drop for struct TlsRead // std::net::tls::future
implement trait Drop for struct TlsWrite // std::net::tls::future
implement trait Drop for struct WebSocket<S> // std::net::ws::conn
implement trait Drop for struct ChildWait // std::process::child
implement trait Drop for struct PipeDrain // std::process::child
implement trait Drop for struct ChildStdin // std::process::child
implement trait Drop for struct ChildStdout // std::process::child
implement trait Drop for struct ChildStderr // std::process::child
implement trait Drop for struct Child // std::process::child
implement trait Drop for struct EnvEntry // std::process::command
implement trait Drop for struct Command // std::process::command
implement trait Drop for struct Output // std::process::command
implement trait Drop for struct PipePair // std::process::command
implement trait Drop for struct WeightedIndex // std::random::distribution
implement trait Drop for struct Atomic<T> // std::sync::atomic
implement trait Drop for struct Barrier // std::sync::barrier
implement trait Drop for struct CondVar // std::sync::condvar
implement<T> trait Drop for struct Sender<T> // std::sync::mpsc
implement<T> trait Drop for struct Receiver<T>
where T: Drop // std::sync::mpsc
implement<T, A> trait Drop for struct MutexGuard<T, A> // std::sync::mutex
implement<T, A> trait Drop for struct Mutex<T, A>
where T: Drop, A: Allocator // std::sync::mutex
implement trait Drop for struct Once // std::sync::once
implement<T, A> trait Drop for struct RwLockReadGuard<T, A> // std::sync::rwlock
implement<T, A> trait Drop for struct RwLockWriteGuard<T, A> // std::sync::rwlock
implement<T, A> trait Drop for struct RwLock<T, A>
where T: Drop, A: Allocator // std::sync::rwlock
implement trait Drop for enum TestError // std::test::error
implement trait Drop for struct RunOptions // std::test::runner
implement trait Drop for struct TestRun // std::test::runner
implement trait Drop for struct ReporterState // std::test::runner
implement trait Drop for struct WorkerResult // std::test::runner
implement trait Drop for struct TestRunner // std::test::runner
implement<T> trait Drop for struct JoinHandle<T> // std::thread
implement trait Drop for struct Scope // std::thread
implement<T> trait Drop for struct ThreadLocal<T> // std::thread::local