Skip to content

Instantly share code, notes, and snippets.

View panicbit's full-sized avatar
:shipit:
Ship it

panicbit

:shipit:
Ship it
  • Dortmund, Germany, ᐰ
View GitHub Profile
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = llvm::PointerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
let mut request = ...;
match request.dispatch() {
// On auth errors, dispatch request again
Err(RequestError::Auth) => request.dispatch(),
// Ignore other errors
request => request
};
// Instead of this fuss:
let prefix = Cursor::new("foo".to_owned().into_bytes());
let data = Cursor::new((...).into_bytes()); // Some big Vec/String
let body: Box<Read + Send> = Box::new(prefix.chain(data));
// We can now just write:
let prefix = "foo";
let data = ...; // Some big Vec/String
use std::io::{self,Read};
use std::borrow::Borrow;
use iron::response::{WriteBody,ResponseBody};
pub struct BodyChain<T, U>(pub T, pub U);
impl <T: WriteBody, U: WriteBody> WriteBody for BodyChain<T, U> {
fn write_body(&mut self, res: &mut ResponseBody) -> io::Result<()> {
let &mut BodyChain(ref mut a, ref mut b) = self;
a.write_body(res).and_then(|_| b.write_body(res))
pub fn foo_handler(api: Arc<Api>) -> Box<Handler> {
Box::new(move |_: &mut Request| {
// do stuff
Ok(Response::with((status::Ok, result)))
})
}

Keybase proof

I hereby claim:

  • I am panicbit on github.
  • I am panicbit (https://keybase.io/panicbit) on keybase.
  • I have a public key whose fingerprint is 3C1A A5AB 6903 540F 9C0E 00FE 7FCE 5195 1A29 7D69

To claim this, I am signing this object:

$chrome_cmd = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" /high-dpi-support=1 /force-device-scale-factor=1 -- '
$safe_cmd = $chrome_cmd & '%*'
$unsafe_cmd = $chrome_cmd & '"%1"'
$key = "HKCR\Chrome\.exe\shell\open\command\"
RegWrite($key, "", "REG_SZ", $safe_cmd)
RegDelete($key, "DelegateExecute")
$key = "HKCR\Chrome\.exe\shell\opennewwindow\command\"
RegWrite($key, "", "REG_SZ", $safe_cmd)
extern {
pub fn cdev_alloc() -> *mut cdev;
pub fn cdev_init(cdev: *mut cdev, fops: *const file_operations);
pub fn cdev_add(cdev: *mut cdev, dev: dev_t, count: c_uint) -> c_int;
pub fn cdev_del(cdev: *mut cdev);
pub fn rustko_extended_cdev_init(
cdev: *mut cdev,
owner: *mut module,
llseek: Option<extern fn(*mut file, loff_t, c_int) -> loff_t>,
read: Option<extern fn(*mut file, /* __user */ *mut char, size_t, *mut loff_t) -> ssize_t>,
cdev::cdev_init(
cdev,
raw::this_module(),
None,
None,
None,
None,
None,
None,
None,
WARNING: "_ZN6option13_$LT$impl$GT$6unwrap14_MSG_FILE_LINE20h3802c1360ab7cb7436ME" [~/tmp/rust.ko/hello.ko] undefined!
WARNING: "_ZN9panicking5panic20hfc2e8d4afaad003aKDKE" [~/tmp/rust.ko/hello.ko] undefined!