Skip to content

Instantly share code, notes, and snippets.

extern mod extra;
use std::vec;
use extra::test::BenchHarness;
pub fn crc32(bytes : &[u8]) -> u32 {
crc32_end(crc32_chunk(crc32_begin(), bytes))
}
pub fn crc32_begin() -> u32 {
0xffffffff
@karablin
karablin / defer.rs
Last active January 2, 2021 02:10
go-like defer for rust
#[feature(macro_rules)];
struct ScopeCall<'cls> {
c: 'cls ||
}
#[unsafe_destructor]
impl<'cls> Drop for ScopeCall<'cls> {
fn drop(&mut self) {
(self.c)();
}