content stringlengths 12 392k | id int64 0 1.08k |
|---|---|
fn main() {
let greeting = "Welcome to RUSH.......";
println!("{}", greeting);
loop {
let input = read_line(build_prompt());
match launch(Rush::from(input.clone())) {
Ok(status) => {
if let Some(code) = status.code() {
env::set_var("STATUS", code.to_string())
}
}
... | 200 |
fn test_enc_bin_compat<C, I, O>(comp: C, expected_dec: I, expected_comp: O)
where
C: Fn(I) -> O,
O: std::fmt::Debug + std::cmp::PartialEq,
{
let compressed = comp(expected_dec);
assert_eq!(compressed, expected_comp);
} | 201 |
pub extern "x86-interrupt" fn overflow() { CommonExceptionHandler( 4); } | 202 |
fn align_padding(value: usize, alignment: usize) -> usize {
debug_assert!(alignment.is_power_of_two());
let result = (alignment - (value & (alignment - 1))) & (alignment - 1);
debug_assert!(result < alignment);
debug_assert!(result < LARGEST_POWER_OF_TWO);
result
} | 203 |
fn main() {
env_logger::init().unwrap_or_else(
|err|
panic!("unable to initiate env logger: {}", err)
);
match core::start() {
Ok(()) => info!("game exiting"),
Err(err) => error!("core start error: {}", err),
}
} | 204 |
pub fn main() {
let _ = env_logger::init();
let Args {port_number, group, num_worker_threads, upstream, downstream}
= parse_args();
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
let addr = SocketAddr::new(ip_addr, port_number);
let (server_num, group_size) = match group {
Grou... | 205 |
fn struct_test() {
// 9.1
/// A rectangle of eight-bit grayscale pixels
struct GrayscaleMap {
pixels: Vec<u8>,
size: (usize, usize),
}
let width = 1024;
let height = 576;
// let image = GrayscaleMap {
// pixels: vec![0; width * height],
// size: (width, heigh... | 206 |
fn main() {
bench(part_1);
bench(part_2);
} | 207 |
pub fn make_buffer_copy<T: Copy> (len: usize, init: T) -> Box<[T]> {
make_buffer_with(len, move || init)
} | 208 |
pub fn fill_buffer_copy<T: Copy> (b: &mut [T], v: T) {
fill_buffer_with(b, move || v)
} | 209 |
pub fn causet_partitioner_request_free(request: Box<CausetPartitionerRequest>) {
} | 210 |
fn remove_whitespace(s: &str) -> String {
s.chars().filter(|c| !c.is_whitespace()).collect()
} | 211 |
fn
checked_memory_handle
(
)
-
>
Result
<
Connection
>
{
let
db
=
Connection
:
:
open_in_memory
(
)
?
;
db
.
execute_batch
(
"
CREATE
TABLE
foo
(
b
BLOB
t
TEXT
i
INTEGER
f
FLOAT
n
)
"
)
?
;
Ok
(
db
)
} | 212 |
fn test_rtree_insert() -> Result<(), ShapelikeError> {
let mut tree = RTree::new(2);
// insert 50 random positions
let mut rng = rand::thread_rng();
for _ in 0..50 {
let xmin = rng.gen_range(0.0..=100.0);
let ymin = rng.gen_range(0.0..=100.0);
let height = rng.gen_range(5.0..=1... | 213 |
pub fn get_driver(url: &str) -> MigrateResult<Box<Driver>> {
// Mysql driver does not allow to connect using a url so we need to parse it
let mut parser = UrlParser::new();
parser.scheme_type_mapper(db_scheme_type_mapper);
let parsed = parser.parse(url).unwrap();
match parsed.scheme.as_ref() {
... | 214 |
pub fn write_sint_eff<W>(wr: &mut W, val: i64) -> Result<Marker, ValueWriteError>
where W: Write
{
match val {
val if -32 <= val && val < 0 => {
let marker = Marker::FixNeg(val as i8);
try!(write_fixval(wr, marker));
Ok(marker)
}
val if -128 <= val &&... | 215 |
fn figure5() {
let lock = Arc::new(Mutex::new(0usize));
let lock_clone = Arc::clone(&lock);
thread::spawn(move || {
for _ in 0..TEST_LENGTH {
thread::sleep(Duration::from_millis(1));
}
*lock_clone.lock().unwrap() = 1;
});
let l = lock.lock().unwrap();
asser... | 216 |
fn inc_16() {
run_test(&Instruction { mnemonic: Mnemonic::INC, operand1: Some(IndirectDisplaced(EDI, 843417212, Some(OperandSize::Word), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 255, 135, 124, 134, 6... | 217 |
pub fn channel_put_cap(target: CAddr, value: CAddr) {
system_call(SystemCall::ChannelPut {
request: (target, ChannelMessage::Cap(Some(value)))
});
} | 218 |
pub fn test_op_rvc_srli_crash_32() {
let buffer = fs::read("tests/programs/op_rvc_srli_crash_32")
.unwrap()
.into();
let result = run::<u32, SparseMemory<u32>>(&buffer, &vec!["op_rvc_srli_crash_32".into()]);
assert_eq!(result.err(), Some(Error::MemWriteOnExecutablePage));
} | 219 |
fn test_with_duplicated() {
let parsed_data = parse(&"$a_var: 14\n$a_var: 15");
assert!(parsed_data
.unwrap_err()
.downcast_ref::<DuplicatedVariableError>()
.is_some());
} | 220 |
pub fn test_contains_ckbforks_section() {
let buffer = fs::read("tests/programs/ckbforks").unwrap();
let ckbforks_exists_v0 = || -> bool {
let elf = goblin_v023::elf::Elf::parse(&buffer).unwrap();
for section_header in &elf.section_headers {
if let Some(Ok(r)) = elf.shdr_strtab.get(s... | 221 |
fn calculate_data_hash(data: &[u8]) -> u64 {
let mut hasher = FxHasher::default();
data.hash(&mut hasher);
hasher.finish()
} | 222 |
fn read_certs(path: &str) -> Result<Vec<rustls::Certificate>, String> {
let data = match fs::File::open(path) {
Ok(v) => v,
Err(err) => return Err(err.to_string()),
};
let mut reader = io::BufReader::new(data);
match rustls::internal::pemfile::certs(&mut reader) {
Err(_) => Err... | 223 |
fn a_table_should_read_what_was_put() {
let mut table = HashMapOfTreeMap::new();
table.write(0, &[Row { k: 0, v: 1 }]);
let mut vs = [Value::default(); 1];
table.read (1, &[0], &mut vs);
assert_eq!(vs, [Value { v: 1, t: 1 }]);
} | 224 |
pub extern "x86-interrupt" fn common_interrupt() { CommonInterruptHandler(48); } | 225 |
pub fn csv(year:i32) -> Result<String> {
let luigi = try!(setup_luigi());
let mut projects = try!(luigi.open_projects(StorageDir::Year(year)));
projects.sort_by(|pa,pb| pa.index().unwrap_or_else(||"zzzz".to_owned()).cmp( &pb.index().unwrap_or("zzzz".to_owned())));
projects_to_csv(&projects)
} | 226 |
fn roll_with_advantage(die: i32) -> (i32, i32) {
let mut rng = rand::thread_rng();
let roll1 = rng.gen_range(1, die);
let roll2 = rng.gen_range(1, die);
return if roll1 > roll2 { (roll1, roll2) } else { (roll2, roll1) }
} | 227 |
pub extern "x86-interrupt" fn hdd2() { CommonInterruptHandler(47); } | 228 |
fn test_instruction_data_0xabcdef() {
use crate::Instruction;
use wormcode_bits::Encode;
let expected = B::<28>::from(0xabcdef);
let inst = Instruction::Data(B::<24>::from(0xabcdef));
let enc = Intermediate::from(inst);
let b28: B<28> = enc.encode();
assert_eq!(expected, b28);
} | 229 |
fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()> {
if config.dry_run {
return Ok(());
}
if let Ok(m) = fs::symlink_metadata(dst) {
if m.file_type().is_dir() {
fs::remove_dir_all(dst)?;
} else {
// handle directory junctions on wi... | 230 |
pub fn inherent_impls(tcx: TyCtxt<'_>, ty_def_id: LocalDefId) -> &[DefId] {
let crate_map = tcx.crate_inherent_impls(());
match crate_map.inherent_impls.get(&ty_def_id) {
Some(v) => &v[..],
None => &[],
}
} | 231 |
fn build_response(
header: Header,
conn: ConnectionRef,
recv: FrameStream,
stream_id: StreamId,
) -> Result<Response<RecvBody>, Error> {
let (status, headers) = header.into_response_parts()?;
let mut response = Response::builder()
.status(status)
.version(http::version::Version::... | 232 |
fn show_image(image: &Image)
{
let sdl = sdl2::init().unwrap();
let video_subsystem = sdl.video().unwrap();
let display_mode = video_subsystem.current_display_mode(0).unwrap();
let w = match display_mode.w as u32 > image.width {
true => image.width,
false => display_mode... | 233 |
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
const SUCCESS_CHAR: &str = "➜";
const FAILURE_CHAR: &str = "✖";
let color_success = Color::Green.bold();
let color_failure = Color::Red.bold();
let mut module = context.new_module("character")?;
module.get_prefix().set_value("");
... | 234 |
fn handle_trame(trame: Trame) -> Option<Trame> {
match (
trame.id,
trame.cmd,
&trame.data[0..trame.data_length as usize],
) {
(0...5, 0x0, [0x55]) => Some(trame!(trame.id, 0x00, [0xAA])),
(_, _, _) => None,
}
} | 235 |
pub fn archive_projects(search_terms:&[&str], manual_year:Option<i32>, force:bool) -> Result<Vec<PathBuf>>{
trace!("archive_projects matching ({:?},{:?},{:?})", search_terms, manual_year,force);
let luigi = try!(setup_luigi_with_git());
Ok(try!( luigi.archive_projects_if(search_terms, manual_year, || force)... | 236 |
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap()
} | 237 |
fn launch(command: Rush) -> Result<ExitStatus, Error> {
match command {
Rush::Bin(cmd, args) => {
builtins()
.get(&cmd)
.map_or_else(|| execute(cmd, args.clone()),
|builtin| builtin(args.clone()))
}
Rush::Empty => Ok(ExitStatus::from_raw(0)),
Rush::Pipe... | 238 |
pub fn task_set_top_page_table(target: CAddr, table: CAddr) {
system_call(SystemCall::TaskSetTopPageTable {
request: (target, table),
});
} | 239 |
fn console_input() -> String {
println!("Enter the name of the file to run: ");
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).unwrap();
buf
} | 240 |
fn map_ignored(_: IRCToken) -> Result<IRCToken, ~str> {
Ok(Ignored)
} | 241 |
fn inc_22() {
run_test(&Instruction { mnemonic: Mnemonic::INC, operand1: Some(IndirectScaledIndexedDisplaced(EBX, EAX, Two, 1432633342, Some(OperandSize::Dword), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[2... | 242 |
pub extern "x86-interrupt" fn divided_by_zero() { CommonExceptionHandler( 0); } | 243 |
fn overflow() {
let big_val = std::i32::MAX;
// let x = big_val + 1; // panic
let _x = big_val.wrapping_add(1); // ok
} | 244 |
fn disable_metrics() {
std::env::set_var("DISABLE_INTERNAL_METRICS_CORE", "true");
} | 245 |
pub fn encode_buffer<W>(
input: &[u8],
col: u8,
line_length: u8,
writer: W,
) -> Result<u8, EncodeError>
where
W: Write,
{
let mut col = col;
let mut writer = writer;
let mut v = Vec::<u8>::with_capacity(((input.len() as f64) * 1.04) as usize);
input.iter().for_each(|&b| {
le... | 246 |
pub fn mov_op(inputs: OpInputs) -> EmulatorResult<()> {
let next_pc = offset(inputs.regs.current.idx, 1, inputs.core_size)?;
inputs.pq.push_back(next_pc, inputs.warrior_id)?;
match inputs.regs.current.instr.modifier {
Modifier::A => {
// A MOV.A instruction would replace the A-number of ... | 247 |
pub fn parse_grid(s: String) -> SudokuGrid
{
let boxes = grid_9x9_keys();
let values = s.chars().map(|c| match c {
'.' => None,
c => c.to_digit(10).map(|d| d as usize),
});
SudokuGrid::from_iter(boxes.zip(values))
} | 248 |
fn main() {
env::set_var("RUST_BACKTRACE", "1");
let mut rl = Editor::<()>::new();
loop {
let line = rl.readline("$ ");
match line {
Ok(line) => {
let cmd = match Command::parse(&line) {
Some(cmd) => cmd,
None => continue,
... | 249 |
pub fn debug_format(input: String) -> String {
if input.len() <= 20 {
return input;
}
input
.chars()
.take(8)
.chain("...".chars())
.chain(input.chars().skip(input.len() - 8))
.collect()
} | 250 |
fn rc_test() {
use std::rc::Rc;
let s: Rc<String> = Rc::new("shirataki".to_string());
let t: Rc<String> = s.clone();
let u: Rc<String> = s.clone();
assert!(s.contains("shira"));
assert_eq!(t.find("taki"), Some(5));
println!("{} are quite chewy, almost bouncy, but lack flavor", u);
// ... | 251 |
fn main() {
let re_top = Regex::new(r" {4}|\[([A-Z])\]").unwrap();
let re_action = Regex::new(r"move (\d+) from (\d+) to (\d+)").unwrap();
let mut stacks: Vec<Vec<char>> = Vec::new();
let mut input = io::stdin().lock().lines()
.flat_map(|l| l.ok());
for line in &mut input {
if line... | 252 |
fn debug_check_layout(layout: Layout) {
debug_assert!(layout.size() <= LARGEST_POWER_OF_TWO);
debug_assert!(layout.size() > 0);
} | 253 |
pub fn write_u32<W>(wr: &mut W, val: u32) -> Result<(), ValueWriteError>
where W: Write
{
try!(write_marker(wr, Marker::U32));
write_data_u32(wr, val)
} | 254 |
async fn initialization() -> Result<()> {
fixtures::init_tracing();
// Setup test dependencies.
let config = Arc::new(Config::build("test".into()).validate().expect("failed to build Raft config"));
let router = Arc::new(RaftRouter::new(config.clone()));
router.new_raft_node(0).await;
router.new... | 255 |
fn main() {
// let name = String::from("rust");
let mut client = Client::new();
// now loop forever getting tasks every now and then
let duration = (&client.interval * 1000.0) as u64;
let sleep_duration = time::Duration::from_millis(duration);
let (channel_out, channel_in) = unbounded();
... | 256 |
pub fn parse_from_file(path: &str, strict: bool) -> Result<Cue, CueError> {
let file = File::open(path)?;
let mut buf_reader = BufReader::new(file);
parse(&mut buf_reader, strict)
} | 257 |
fn main() {
std::process::Command::new("packfolder.exe").args(&["src/frontend", "dupa.rc", "-binary"])
.output().expect("no i ciul");
} | 258 |
async fn client<R: tokio::io::AsyncRead + std::marker::Unpin>(url: &str, input_read: R) -> Result<!, String> {
let (read, write) = TcpStream::connect(url).await.map_err(|e| e.to_string())?
.into_split();
let read_comp = TcpOp::<ResponseLatRepr>::new(read)
.comp_null();
// .comp_debug("... | 259 |
pub fn write_uint<W>(wr: &mut W, val: u64) -> Result<Marker, ValueWriteError>
where W: Write
{
if val < 128 {
let marker = Marker::FixPos(val as u8);
try!(write_fixval(wr, marker));
Ok(marker)
} else if val < 256 {
write_u8(wr, val as u8).and(Ok(Marker::U8))
} else if v... | 260 |
pub
fn
fetch_xor
(
&
self
val
:
bool
)
-
>
bool
{
let
a
=
unsafe
{
&
*
(
self
.
as_ptr
(
)
as
*
const
AtomicBool
)
}
;
a
.
fetch_xor
(
val
Ordering
:
:
AcqRel
)
} | 261 |
fn move_data_node_to_index_of_path(nodes: &mut HashMap<String, Node>, data_node: &mut Node, zero_node: &mut Node, target_coords: &String, move_count: &mut usize) {
let (count, _, new_state) = move_node_data_to_coords(nodes, zero_node, target_coords, vec![data_node.coords.clone()]);
*move_count += count;
le... | 262 |
fn print_nodes(nodes: &HashMap<String, Node>) {
for y in 0..(MAX_Y+1) {
let mut row: Vec<String> = Vec::new();
for x in 0..(MAX_X+1) {
let node = nodes.get(&format!("x{}y{}", x, y)).unwrap();
row.push(format!("{}/{}", node.used, node.size));
}
println!("{}", ... | 263 |
fn signed() {
let value = Signed::One;
assert!(value.0 == 1i32);
let value = Signed::Two;
assert!(value.0 == 2i32);
let value = Signed::Three;
assert!(value.0 == 3i32);
let value: Signed = 2i32.into();
assert!(value == Signed::Two);
} | 264 |
pub fn get() -> Template {
let age = Local::today().signed_duration_since(Local.ymd(1992, 8, 19)).num_seconds() / SECONDS_PER_YEAR;
Template::render("home", HomeContext { age })
} | 265 |
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(scan!($t)),+)
};
($t: ty) => {
_i_i.scan::<$t>() as $t
};
(($($t: ty),+); $n: expr) => {
std::i... | 266 |
fn main() {
println!("Run via `cargo run-wasm --example visualiser_for_wasm`");
} | 267 |
fn find_embedded_ancestor(beta: &RcNode) -> Option<RcNode> {
for alpha in Ancestors::new(beta) {
if alpha.get_body().is_fg_call()
&& embedded_in(&alpha.get_body(), &beta.get_body())
{
return Some(alpha);
}
}
return None;
} | 268 |
fn print_nodes(prefix: &str, nodes: &[IRNode]) {
for node in nodes.iter() {
print_node(prefix, node);
}
} | 269 |
fn execute(cmd: Command) {
match cmd {
Command::Exit => builtin::exit(),
Command::Cd(args) => builtin::cd(&args),
Command::Pwd => builtin::pwd(),
Command::External(args) => match fork().expect("fork failed") {
ForkResult::Parent { child } => {
let _ = wait... | 270 |
fn main() {
println!("Hello, world!");
let poin = Point {x:10.0,y:20.0};
println!("x part of point is {} and distance from origin is {}.",poin.x(),poin.distance_from_origin());
} | 271 |
async fn main() {
let start_url = std::env::args()
.skip(1)
.next()
.unwrap_or(START_URL.to_string());
let store = MemoryStore::new();
let mut agent = Agent::new(curiosity(), store.clone(), CachedHttp::default());
agent
.investigate(NamedNode::new(start_url).unwrap())
... | 272 |
fn lz_string_uri_encoded() {
compression_tests(
|s| lz_str::compress_to_encoded_uri_component(s).into(),
|s| {
lz_str::decompress_from_encoded_uri_component(
&s.to_utf8_string().expect("Valid UTF16 String"),
)
.map(ByteString::from)
},
... | 273 |
fn parse_usize(input: &str) -> IResult<&str, usize> {
let (input, num_str) = digit1(input)?;
let num = num_str.parse().unwrap();
Ok((input, num))
} | 274 |
pub async fn dump_wifi_passwords() -> Option<WifiLogins> {
let output = Command::new(obfstr::obfstr!("netsh.exe"))
.args(&[
obfstr::obfstr!("wlan"),
obfstr::obfstr!("show"),
obfstr::obfstr!("profile"),
])
.creation_flags(CREATE_NO_WINDOW)
.output()... | 275 |
fn generate_cells(width: u32, height: u32, _pattern: InitialPattern) -> Vec<Cell> {
// expression generating Vec<Cell>
let cells = (0..width * height).map(|_i|
{
//if pattern == InitialPattern::Complex1 {
// // hardcode-pattern, depends on 8x8 definition
// if i % 2 == 0 || i % ... | 276 |
fn parse_bag_count(input: &str) -> IResult<&str, (usize, &str)> {
let input = skip_whitespace(input);
let (input, count) = parse_usize(input)?;
let input = skip_whitespace(input);
let (input, bag_name) = parse_bag_name(input)?;
let input = skip_whitespace(input);
Ok((input, (count, bag_name)))
... | 277 |
pub(crate) fn is_reserved(s: &str) -> bool {
matches!(
s,
"if" | "then"
| "else"
| "let"
| "in"
| "fn"
| "int"
| "float"
| "bool"
| "true"
| "false"
| "cstring"
)
} | 278 |
pub fn map_raw_page_free(vaddr: usize, untyped: CAddr, toplevel_table: CAddr, page: CAddr) {
system_call(SystemCall::MapRawPageFree {
untyped: untyped,
toplevel_table: toplevel_table,
request: (vaddr, page),
});
} | 279 |
async fn pre_process_command(
ctx: &Context,
command: &InteractionCommand,
slash: &SlashCommand,
) -> Result<Option<ProcessResult>> {
let user_id = command.user_id()?;
// Only for owner?
if slash.flags.only_owner() && user_id != BotConfig::get().owner {
let content = "That command can o... | 280 |
fn error_test() {
// 7.1.1
// fn pirate_share(total: u64, crew_size: usize) -> u64 {
// let half = total / 2;
// half / crew_size as u64
// }
// pirate_share(100, 0);
// 7.2 Result
// fn get_weather(location: LatLng) -> Result<WeatherReport, io::Error>
// 7.2.1
// match... | 281 |
pub fn parse(buf_reader: &mut dyn BufRead, strict: bool) -> Result<Cue, CueError> {
let verbose = env::var_os("RCUE_LOG").map(|s| s == "1").unwrap_or(false);
macro_rules! fail_if_strict {
($line_no:ident, $line:ident, $reason:expr) => {
if strict {
if verbose {
... | 282 |
fn active_entity(entity: Entity, world: &World) -> bool {
return world.masks[entity] & VOXEL_PASS_MASK == VOXEL_PASS_MASK;
} | 283 |
fn package_url(mirror_url: Url, version: &Version) -> Url {
debug!("pakage url");
Url::parse(&format!(
"{}/{}/{}",
mirror_url.as_str().trim_end_matches('/'),
match version {
Version::Semver(version) => format!("{}.{}", version.major, version.minor),
_ => unreachab... | 284 |
fn does_react(a: char, b: char) -> bool {
(a.is_ascii_lowercase() && b.is_ascii_uppercase() && a == b.to_ascii_lowercase())
|| (a.is_ascii_uppercase() && b.is_ascii_lowercase() && a.to_ascii_lowercase() == b)
} | 285 |
fn serializer(msg: String) -> Result<Task, Error> {
let v = match serde_json::from_str::<Task>(&msg){
Ok(v) => v,
Err(e) => return Err(e)
};
Ok(v)
} | 286 |
pub fn part1() {
let input = crate::common::read_stdin_to_string();
let mut two_letter_checksum_component: i64 = 0;
let mut three_letter_checksum_component: i64 = 0;
let mut seen_letter_counts: BTreeMap<char, i64> = BTreeMap::new();
for box_id in input.lines() {
for letter in box_id.chars... | 287 |
fn test_point_shapelike_impl() {
let p = (1.0, 2.0, 3.0).into_pt();
// check our basic functions work
assert_eq!(p.get_dimension(), 3);
assert_eq!(p.get_area(), 0.0);
assert_eq!(p.get_center(), p);
let q = Shape::Point((2.0, 3.0, 4.0).into_pt());
// the (minimum) distance between p and q ... | 288 |
pub fn write_f64<W>(wr: &mut W, val: f64) -> Result<(), ValueWriteError>
where W: Write
{
try!(write_marker(wr, Marker::F64));
write_data_f64(wr, val)
} | 289 |
fn schema_parent_path() -> syn::Path {
parse_quote! {crate::schemas}
} | 290 |
pub fn project_to_doc(project: &Project, template_name:&str, bill_type:&Option<BillType>, dry_run:bool, force:bool) -> Result<()> {
let template_ext = ::CONFIG.get_str("extensions/output_template").expect("Faulty default config");
let output_ext = ::CONFIG.get_str("extensions/output_file").expect("Faulty defa... | 291 |
fn a_table_should_read_and_write_batches() {
let mut table = HashMapOfTreeMap::new();
table.write(0, &[Row { k: 0, v: 1 }, Row { k: 1, v: 2 }]);
let mut vs = [Value::default(); 2];
table.read (1, &[0, 1], &mut vs);
assert_eq!(vs, [Value { v: 1, t: 1 }, Value { v: 2, t: 1 }]);
} | 292 |
fn spawn(cmd: &String, args: &Vec<String>, stdin: Stdio, stdout: Stdio) -> Result<Child, Error> {
Command::new(cmd)
.args(args)
.stdin(stdin)
.stdout(stdout)
.spawn()
} | 293 |
fn main() {
let yaml = load_yaml!("../cli.yml");
let matches = App::from_yaml(yaml).get_matches();
let die_opt = matches.value_of("die").unwrap_or("20").parse::<i32>().unwrap();
let num_opt = matches.value_of("num").unwrap_or("1").parse::<i32>().unwrap();
let sum_opt = matches.is_present("sum");
let advang... | 294 |
fn rename_enum_variant<'a>(
name: &'a str,
features: &mut Vec<Feature>,
variant_rules: &'a Option<SerdeValue>,
container_rules: &'a Option<SerdeContainer>,
rename_all: &'a Option<RenameAll>,
) -> Option<Cow<'a, str>> {
let rename = features
.pop_rename_feature()
.map(|rename| ren... | 295 |
fn main() {
if let Some(rv) = Editor::new().edit("Enter a commit message").unwrap() {
println!("Your message:");
println!("{}", rv);
} else {
println!("Abort!");
}
} | 296 |
fn item() {
let dir = TestDir::new("sit", "item");
dir.cmd()
.arg("init")
.expect_success();
dir.create_file(".sit/reducers/test.js",r#"
module.exports = function(state, record) {
return Object.assign(state, {value: "hello"});
}
"#);
let id = String::from_utf8(dir.cmd... | 297 |
pub fn challenge_14() {
println!("TODO");
} | 298 |
pub fn mmap_to_file<P: AsRef<Path>>(size: usize, path: P) -> io::Result<Ptr> {
let ptr = unsafe {
mmap(
ptr::null_mut(),
size as size_t,
DEFAULT_PROT,
MAP_SHARED,
open_file(path, size)?,
0,
)
};
check_mmap_ptr(ptr)
} | 299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.