Skip to content

Instantly share code, notes, and snippets.

View stepancheg's full-sized avatar

Stepan Koltsov stepancheg

View GitHub Profile
Compiling glob v0.0.1 (https://github.com/rust-lang/glob#5d7ad1dc)
Compiling tar v0.0.1 (https://github.com/alexcrichton/tar-rs#868632ea)
/Users/yozh/.cargo/git/checkouts/tar-rs-6e41f0ca8f00e811/master/src/lib.rs:190:43: 190:48 error: mismatched types: expected `&mut [u8]`, found `[_, ..512]` (expected &-ptr, found array of 512 elements)
/Users/yozh/.cargo/git/checkouts/tar-rs-6e41f0ca8f00e811/master/src/lib.rs:190 if try!(Reader::read(&mut me, chunk)) != 512 {
^~~~~
<std macros>:1:1: 8:2 note: in expansion of try!
/Users/yozh/.cargo/git/checkouts/tar-rs-6e41f0ca8f00e811/master/src/lib.rs:190:16: 190:53 note: expansion site
/Users/yozh/.cargo/git/checkouts/glob-53436a21832a74ca/master/src/lib.rs:110:14: 110:46 error: type `core::result::Result<std::path::posix::Path, std::io::IoError>` does not implement any method in scope named `push`
/Users/yozh/.cargo/git/checkouts/glo
#![feature(unsafe_destructor)]
#[deriving(Show)]
struct Uninit<T> {
pub value: T
}
impl<T> Uninit<T> {
unsafe fn new() -> Uninit<T> {
Uninit {
public class MutexWithData<A> {
private final ReentrantLock lock = new ReentrantLock();
private final A data;
public MutexWithData(A data) {
this.data = data;
}
public Guard lock() {
tmp.rs:8:9: 8:13 error: `copy` does not live long enough
tmp.rs:8 copy.walk(|a| callback(a));
^~~~
tmp.rs:6:45: 9:6 note: reference must be valid for the lifetime 'a as defined on the block at 6:44...
tmp.rs:6 fn walk(&'a self, callback: |&Aaa<'a>|) {
tmp.rs:7 let copy = Aaa { dummy: self.dummy };
tmp.rs:8 copy.walk(|a| callback(a));
tmp.rs:9 }
tmp.rs:6:45: 9:6 note: ...but borrowed value is only valid for the block at 6:44
tmp.rs:6 fn walk(&'a self, callback: |&Aaa<'a>|) {
num #instances #bytes class name
----------------------------------------------
1: 2909942 600375552 [B
2: 2690939 236802632 ru.yandex.kiwi.proto.KwcalcUdfSensors$TUdfInfo$TExecStats
3: 2177790 156883824 [C
4: 1376766 149649528 [Ljava.lang.Object;
5: 1345474 129165504 ru.yandex.kiwi.proto.KwcalcUdfSensors$TUdfInfo
6: 3747636 89943264 java.lang.Long
7: 2836212 68069088 com.google.protobuf.LiteralByteString
@stepancheg
stepancheg / explicit-is-better.txt
Last active August 29, 2015 14:03
Keep explicit lifetimes
https://github.com/rust-lang/rfcs/blob/master/active/0039-lifetime-elision.md
* Typechecker does not cross function signature
* What Rust could have to simplify developer's job, but it doesn't (return type inference, any T)
[vagrant@vagrant-ubuntu-precise-64:...ust-protobuf/src/perftest;master:0]% ./perftest-cxx
test1 write: 122 ns per iter
test1 read: 424 ns per iter
test1 read reuse: 37 ns per iter
test_repeated_bool write: 144 ns per iter
test_repeated_bool read: 475 ns per iter
test_repeated_bool read reuse: 56 ns per iter
test_repeated_packed_int32 write: 272 ns per iter
test_repeated_packed_int32 read: 796 ns per iter
test_repeated_packed_int32 read reuse: 74 ns per iter
lib/descriptorx.rs:70:26: 70:71 error: cannot infer an appropriate lifetime due to conflicting requirements
lib/descriptorx.rs:70 .map(|e| EnumWithPath { path: m.to_path(), en: e })));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/descriptorx.rs:70:51: 70:62 note: first, the lifetime cannot outlive the method call at 70:50...
lib/descriptorx.rs:70 .map(|e| EnumWithPath { path: m.to_path(), en: e })));
^~~~~~~~~~~
lib/descriptorx.rs:70:51: 70:52 note: ...so that method receiver is valid for the method call
lib/descriptorx.rs:70 .map(|e| EnumWithPath { path: m.to_path(), en: e })));
^
lib/descriptorx.rs:69:27: 70:72 note: but, the lifetime must be valid for the method call at 69:26...
extern crate protobuf; | #include <iostream>
extern crate rand; | #include <fstream>
extern crate time; | #include <random>
| #include <sstream>
use std::io::File; | #include <chrono>
use std::io::MemWriter; |
use std::io::BufReader; | #include <google/protobuf/message.h>
use std::default::Default; | #include <google/protobuf/io/zero_copy_stream_impl.h>
|
use rand::Rng; | #include <stdio.h>
import org.rrd4j.core.jrrd.ConsolidationFunctionType;
import org.rrd4j.core.jrrd.DataChunk;
import org.rrd4j.core.jrrd.RRDatabase;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* @author Stepan Koltsov
*/