This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct TTestSyncClient { | |
i_prot: Rc<RefCell<Box<TProtocol>>>, | |
o_prot: Rc<RefCell<Box<TProtocol>>>, | |
sequence_number: i32, | |
} | |
impl TTestSyncClient { | |
fn send_testVoid(&mut self) -> rift::Result<()> { | |
self.sequence_number = self.sequence_number + 1; | |
let message_ident = TMessageIdentifier { name:"testVoid".to_owned(), message_type: TMessageType::Call, sequence_number: self.sequence_number }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl<T: Transport> BufferedTransport<T> { | |
fn get_bytes(&mut self) -> io::Result<&[u8]> { | |
if self.rpos == self.rbuf.len() { | |
self.rpos = 0; | |
self.rcap = try!(self.underlying.read(&mut self.rbuf)); | |
} | |
Ok(&self.rbuf[self.rpos..self.rcap]) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+- protocol | |
| +- mod.rs | |
| +- binary.rs <--- I want to use Transport (from transport module here) | |
+- transport | |
| +- mod.rs <--- pub trait Transport defined here | |
+- lib.rs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn iter<'a>(&'a self) -> Iter<'a, T> { | |
let y: Option<&Box<Node<T>>> = self.head.as_ref(); | |
Iter { next: y.map(|b: &Box<Node<T>>| { | |
let n: Node<T> = *b; | |
&n | |
}) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn header_name<T: Header>() -> &'static str { | |
<T as Header>::header_name() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(dead_code)] | |
use std::f32::INFINITY; | |
use std::sync::Arc; | |
use std::thread; | |
use std::sync::mpsc::channel; | |
struct Store { | |
name: String, | |
items: Vec<Item>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(dead_code)] | |
use std::f32::INFINITY; | |
use std::sync::{Arc, Mutex}; | |
use std::thread; | |
struct Store { | |
name: String, | |
items: Vec<Item>, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let best: (Option<String>, f32) = (None, INFINITY); | |
let best = Arc::new(Mutex::new(best)); | |
let mut handles = vec![]; | |
for store in stores { | |
let best = best.clone(); | |
let shopping_list = shopping_list.clone(); | |
handles.push(thread::spawn(move || { | |
let sum = store.total_price(&shopping_list); | |
let (ref mut prev_best_store, ref mut prev_best_price) = *best.lock().unwrap(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.RuntimeException: java.lang.AssertionError: | |
Expecting: | |
<""> | |
to contain: | |
<"Hello, world!"> | |
at com.intellij.openapi.application.impl.LaterInvocator.invokeAndWait(LaterInvocator.java:177) | |
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:642) | |
at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:42) | |
at com.intellij.testFramework.EdtTestUtil$Companion.runInEdtAndWait(EdtTestUtil.kt:29) | |
at com.intellij.testFramework.EdtTestUtil.runInEdtAndWait(EdtTestUtil.kt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2016 Allen A. George. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |