file_name large_stringlengths 4 69 | prefix large_stringlengths 0 26.7k | suffix large_stringlengths 0 24.8k | middle large_stringlengths 0 2.12k | fim_type large_stringclasses 4
values |
|---|---|---|---|---|
rust-picotcp-dhcpd.rs | #![feature(globs)]
extern crate libc;
extern crate picotcp;
use picotcp::pico_ip4;
use picotcp::pico_ip6;
use picotcp::pico_dhcp_server::*;
fn main() {
/* Initialize stack */
let pico = picotcp::stack::new();
let my_ip_addr = pico_ip4::new("192.168.2.150");
let my_netmask = pico_ip4::new("255.255.255... |
dhcp_server_initiate(&mut settings);
pico.stack_loop();
} | server_ip: my_ip_addr,
netmask: my_netmask,
flags: 0
}; | random_line_split |
rust-picotcp-dhcpd.rs | #![feature(globs)]
extern crate libc;
extern crate picotcp;
use picotcp::pico_ip4;
use picotcp::pico_ip6;
use picotcp::pico_dhcp_server::*;
fn | () {
/* Initialize stack */
let pico = picotcp::stack::new();
let my_ip_addr = pico_ip4::new("192.168.2.150");
let my_netmask = pico_ip4::new("255.255.255.0");
let my_ip6_addr = pico_ip6 { addr:[0xaa, 0xaa, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] }; // Constructor is still WIP...
let my_6_net... | main | identifier_name |
rust-picotcp-dhcpd.rs | #![feature(globs)]
extern crate libc;
extern crate picotcp;
use picotcp::pico_ip4;
use picotcp::pico_ip6;
use picotcp::pico_dhcp_server::*;
fn main() | pool_start: dhcp_start.clone(),
pool_next: dhcp_start,
pool_end: dhcp_end,
lease_time: 0,
dev: pico_dev_eth,
s: 0,
server_ip: my_ip_addr,
netmask: my_netmask,
flags: 0
};
dhcp_server_initiate(&mut settings);
pico.stack_loop();
}
| {
/* Initialize stack */
let pico = picotcp::stack::new();
let my_ip_addr = pico_ip4::new("192.168.2.150");
let my_netmask = pico_ip4::new("255.255.255.0");
let my_ip6_addr = pico_ip6 { addr:[0xaa, 0xaa, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] }; // Constructor is still WIP...
let my_6_netmas... | identifier_body |
huge-largest-array.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
assert_eq!(size_of::<[u8; (1 << 47) - 1]>(), (1 << 47) - 1);
} | identifier_body | |
huge-largest-array.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
assert_eq!(size_of::<[u8; (1 << 47) - 1]>(), (1 << 47) - 1);
}
| main | identifier_name |
huge-largest-array.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | // except according to those terms.
// run-pass
use std::mem::size_of;
#[cfg(target_pointer_width = "32")]
pub fn main() {
assert_eq!(size_of::<[u8; (1 << 31) - 1]>(), (1 << 31) - 1);
}
#[cfg(target_pointer_width = "64")]
pub fn main() {
assert_eq!(size_of::<[u8; (1 << 47) - 1]>(), (1 << 47) - 1);
} | random_line_split | |
namespaced-enum-glob-import-no-impls.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | } | m::bar(); //~ ERROR unresolved name `m::bar` | random_line_split |
namespaced-enum-glob-import-no-impls.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {}
pub fn bar(&self) {}
}
}
mod m {
pub use m2::Foo::*;
}
pub fn main() {
use m2::Foo::*;
foo(); //~ ERROR unresolved name `foo`
m::foo(); //~ ERROR unresolved name `m::foo`
bar(); //~ ERROR unresolved name `bar`
m::bar(); //~ ERROR unresolved name `m::bar`
}
| foo | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(step_trait)]
#![deny(unsafe_code)]
extern crate heapsize;
#[macro_use] extern crate heapsize_derive;
... | (self) -> usize { self }
}
/// Implements a range index type with operator overloads
#[macro_export]
macro_rules! int_range_index {
($(#[$attr:meta])* struct $Self_:ident($T:ty)) => (
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Debug, Copy)]
$(#[$attr])*
pub struct $Self_(pub $T);
... | get | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(step_trait)]
#![deny(unsafe_code)]
extern crate heapsize;
#[macro_use] extern crate heapsize_derive;
... | else {
Range::new(begin, end - begin)
}
}
}
/// Methods for `Range`s with indices based on integer values
impl<T: Int, I: RangeIndex<Index=T>> Range<I> {
/// Returns an iterater that increments over `[begin, end)`.
#[inline]
pub fn each_index(&self) -> EachIndex<T, I> {
eac... | {
Range::empty()
} | conditional_block |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(step_trait)]
#![deny(unsafe_code)]
extern crate heapsize;
#[macro_use] extern crate heapsize_derive;
... | self.length() == Int::zero()
}
/// Shift the entire range by the supplied index delta.
///
/// ~~~ignore
/// |-- delta ->|
/// | |
/// <- o - +============+ - - - - - | - - - ->
/// |
/// <- o ... | }
/// `true` if the offset from the beginning to the end of the range is zero.
#[inline]
pub fn is_empty(&self) -> bool { | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(step_trait)]
#![deny(unsafe_code)]
extern crate heapsize;
#[macro_use] extern crate heapsize_derive;
... |
#[inline]
fn one() -> usize { 1 }
#[inline]
fn max_value() -> usize { ::std::usize::MAX }
#[inline]
fn from_usize(n: usize) -> Option<usize> { Some(n) }
}
/// An index type to be used by a `Range`
pub trait RangeIndex: Int + fmt::Debug {
type Index;
fn new(x: Self::Index) -> Self;
... | { 0 } | identifier_body |
highlight.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (src: &str, class: Option<&str>, id: Option<&str>) -> String {
debug!("highlighting: ================\n{}\n==============", src);
let sess = parse::new_parse_sess();
let fm = parse::string_to_filemap(&sess,
src.to_string(),
"<stdin>... | highlight | identifier_name |
highlight.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | t::LIT_BYTE(..) | t::LIT_BINARY(..) | t::LIT_BINARY_RAW(..) |
t::LIT_CHAR(..) | t::LIT_STR(..) | t::LIT_STR_RAW(..) => "string",
// number literals
t::LIT_INTEGER(..) | t::LIT_FLOAT(..) => "number",
// keywords are also included in the identifier set
... | }
}
// text literals | random_line_split |
highlight.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
/// Exhausts the `lexer` writing the output into `out`.
///
/// The general structure for this method is to iterate over each token,
/// possibly giving it an HTML span with a class specifying what flavor of token
/// it's used. All source code emission is done as slices from the source map,
/// not from the tokens t... | {
debug!("highlighting: ================\n{}\n==============", src);
let sess = parse::new_parse_sess();
let fm = parse::string_to_filemap(&sess,
src.to_string(),
"<stdin>".to_string());
let mut out = io::MemWriter::new();
... | identifier_body |
task-comm-7.rs | // run-pass
#![allow(unused_must_use)]
#![allow(unused_assignments)]
// ignore-emscripten no threads support
use std::sync::mpsc::{channel, Sender};
use std::thread;
pub fn main() |
fn test00_start(c: &Sender<isize>, start: isize,
number_of_messages: isize) {
let mut i: isize = 0;
while i < number_of_messages { c.send(start + i).unwrap(); i += 1; }
}
fn test00() {
let mut r: isize = 0;
let mut sum: isize = 0;
let (tx, rx) = channel();
let number_of_messag... | { test00(); } | identifier_body |
task-comm-7.rs | // run-pass
#![allow(unused_must_use)]
#![allow(unused_assignments)]
// ignore-emscripten no threads support
use std::sync::mpsc::{channel, Sender}; | use std::thread;
pub fn main() { test00(); }
fn test00_start(c: &Sender<isize>, start: isize,
number_of_messages: isize) {
let mut i: isize = 0;
while i < number_of_messages { c.send(start + i).unwrap(); i += 1; }
}
fn test00() {
let mut r: isize = 0;
let mut sum: isize = 0;
let (... | random_line_split | |
task-comm-7.rs | // run-pass
#![allow(unused_must_use)]
#![allow(unused_assignments)]
// ignore-emscripten no threads support
use std::sync::mpsc::{channel, Sender};
use std::thread;
pub fn main() { test00(); }
fn test00_start(c: &Sender<isize>, start: isize,
number_of_messages: isize) {
let mut i: isize = 0;
... | () {
let mut r: isize = 0;
let mut sum: isize = 0;
let (tx, rx) = channel();
let number_of_messages: isize = 10;
let tx2 = tx.clone();
let t1 = thread::spawn(move|| {
test00_start(&tx2, number_of_messages * 0, number_of_messages);
});
let tx2 = tx.clone();
let t2 = thread::s... | test00 | identifier_name |
vibrance.rs | /*
* Copyright (C) 2012 The Android Open Source Project
*
* 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 app... | B = b;
float Rc = R * (Rt + S) + G * Gt + B * Bt;
float Gc = R * Rt + G * (Gt + S) + B * Bt;
float Bc = R * Rt + G * Gt + B * (Bt + S);
out->r = rsClamp(Rc, 0, 255);
out->g = rsClamp(Gc, 0, 255);
out->b = rsClamp(Bc, 0, 255);
}
void prepareVibrance() {
Vib = vibrance/100.f;
S =... | R = r;
G = g; | random_line_split |
message.rs | use std::str;
use std::str::FromStr;
use std::ascii::AsciiExt;
use IterListHeader;
use Error::{ForbiddenHeader, MissingHeader};
pub trait Message {
fn get_header(&self, &str) -> Option<&Vec<Vec<u8>>>;
fn contains_header(&self, &str) -> bool;
fn get_value_header(&self, name: &str) -> Option<&[u8]> {
... |
}
| {
if let Some(values) = self.get_list_header("Transfer-Encoding") {
for value in values {
if value.eq_ignore_ascii_case(b"chunked") {
return true
}
}
}
false
} | identifier_body |
message.rs | use std::str;
use std::str::FromStr;
use std::ascii::AsciiExt;
use IterListHeader;
use Error::{ForbiddenHeader, MissingHeader};
pub trait Message {
fn get_header(&self, &str) -> Option<&Vec<Vec<u8>>>;
fn contains_header(&self, &str) -> bool;
fn | (&self, name: &str) -> Option<&[u8]> {
let value_header = self.get_header(name);
if value_header.is_none() || value_header.unwrap().len()!= 1 {
return None;
}
Some(&value_header.unwrap()[0])
}
fn get_list_header(&self, name: &str) -> Option<IterListHeader> {
... | get_value_header | identifier_name |
message.rs | use std::str;
use std::str::FromStr;
use std::ascii::AsciiExt;
use IterListHeader;
use Error::{ForbiddenHeader, MissingHeader};
pub trait Message {
fn get_header(&self, &str) -> Option<&Vec<Vec<u8>>>;
fn contains_header(&self, &str) -> bool;
fn get_value_header(&self, name: &str) -> Option<&[u8]> {
... | else {
None
}
}
fn content_length(&self) -> ::Result<usize> {
if self.contains_header("Transfer-Encoding") {
return Err(ForbiddenHeader);
}
let value = try!(self.get_value_header("Content-Length").ok_or(MissingHeader));
FromStr::from_str(try!(str... | {
Some(IterListHeader::new(values))
} | conditional_block |
message.rs | use std::str;
use std::str::FromStr;
use std::ascii::AsciiExt;
use IterListHeader;
use Error::{ForbiddenHeader, MissingHeader};
pub trait Message {
fn get_header(&self, &str) -> Option<&Vec<Vec<u8>>>;
fn contains_header(&self, &str) -> bool;
fn get_value_header(&self, name: &str) -> Option<&[u8]> {
... | let value = try!(self.get_value_header("Content-Length").ok_or(MissingHeader));
FromStr::from_str(try!(str::from_utf8(value))).map_err(From::from)
}
fn is_chunked(&self) -> bool {
if let Some(values) = self.get_list_header("Transfer-Encoding") {
for value in values {
... | return Err(ForbiddenHeader);
} | random_line_split |
executor.rs | use serde::{Serialize, Deserialize};
use std::mem;
use std::fmt::Debug;
use std::sync::mpsc::{Sender, Receiver};
use std::collections::HashMap;
use amy;
use slog;
use time::Duration;
use ferris::{Wheel, CopyWheel, Resolution};
use envelope::Envelope;
use pid::Pid;
use process::Process;
use node_id::NodeId;
use msg::Msg... | <T> {
pid: Pid,
node: NodeId,
envelopes: Vec<Envelope<T>>,
processes: HashMap<Pid, Box<Process<T>>>,
service_senders: HashMap<Pid, amy::Sender<Envelope<T>>>,
tx: Sender<ExecutorMsg<T>>,
rx: Receiver<ExecutorMsg<T>>,
cluster_tx: Sender<ClusterMsg<T>>,
timer_wheel: CopyWheel<(Pid, Opti... | Executor | identifier_name |
executor.rs | use serde::{Serialize, Deserialize};
use std::mem;
use std::fmt::Debug;
use std::sync::mpsc::{Sender, Receiver};
use std::collections::HashMap;
use amy;
use slog;
use time::Duration;
use ferris::{Wheel, CopyWheel, Resolution};
use envelope::Envelope;
use pid::Pid;
use process::Process;
use node_id::NodeId;
use msg::Msg... | match msg {
ExecutorMsg::Envelope(envelope) => {
self.metrics.received_envelopes += 1;
self.route(envelope);
},
ExecutorMsg::Start(pid, process) => self.start(pid, process),
ExecutorMsg::Stop(pid) => self... | ///
///This call blocks the current thread indefinitely.
pub fn run(mut self) {
while let Ok(msg) = self.rx.recv() { | random_line_split |
executor.rs | use serde::{Serialize, Deserialize};
use std::mem;
use std::fmt::Debug;
use std::sync::mpsc::{Sender, Receiver};
use std::collections::HashMap;
use amy;
use slog;
use time::Duration;
use ferris::{Wheel, CopyWheel, Resolution};
use envelope::Envelope;
use pid::Pid;
use process::Process;
use node_id::NodeId;
use msg::Msg... |
/// Route envelopes to local or remote processes
///
/// Retrieve any envelopes from processes handling local messages and put them on either the
/// executor or the cluster channel depending upon whether they are local or remote.
///
/// Note that all envelopes sent to an executor are sent fr... | {
for (pid, c_id) in self.timer_wheel.expire() {
let envelope = Envelope::new(pid, self.pid.clone(), Msg::Timeout, c_id);
let _ = self.route_to_process(envelope);
}
} | identifier_body |
gcthread.rs | //! Garbage collection thread
use std::any::Any;
use std::cmp::min;
use std::mem::size_of;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use num_cpus;
use scoped_pool::Pool;
use appthread::AppThread;
use constants::{MAJOR_COLLECT_THRESHOLD, MAX_SLEEP_DUR, MIN_SLEEP_DUR};
use heap::{CollectOps, Obje... | 3
}
} | pub fn ptr_shift() -> i32 {
if size_of::<usize>() == 32 {
2
} else { | random_line_split |
gcthread.rs | //! Garbage collection thread
use std::any::Any;
use std::cmp::min;
use std::mem::size_of;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use num_cpus;
use scoped_pool::Pool;
use appthread::AppThread;
use constants::{MAJOR_COLLECT_THRESHOLD, MAX_SLEEP_DUR, MIN_SLEEP_DUR};
use heap::{CollectOps, Obje... |
// TODO: base this call on a duration since last call?
let young_count = gc.minor_collection(&mut pool);
// do a major collection if the young count reaches a threshold and we're not just trying
// to keep up with the app threads
// TODO: force a major collection every n minut... | {
// reset next sleep duration on receiving no entries
sleep_dur = MIN_SLEEP_DUR;
} | conditional_block |
gcthread.rs | //! Garbage collection thread
use std::any::Any;
use std::cmp::min;
use std::mem::size_of;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use num_cpus;
use scoped_pool::Pool;
use appthread::AppThread;
use constants::{MAJOR_COLLECT_THRESHOLD, MAX_SLEEP_DUR, MIN_SLEEP_DUR};
use heap::{CollectOps, Obje... |
/// Wait for the GC thread to finish. On success, returns the object that implements
/// `StatsLogger` for the calling thread to examine.
pub fn join(self) -> Result<S, Box<Any + Send +'static>> {
self.handle.join()
}
}
/// Main GC thread loop.
fn gc_thread<S, T>(num_threads: usize, rx_chan:... | {
AppThread::spawn_from_gc(self.tx_chan.clone(), f)
} | identifier_body |
gcthread.rs | //! Garbage collection thread
use std::any::Any;
use std::cmp::min;
use std::mem::size_of;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use num_cpus;
use scoped_pool::Pool;
use appthread::AppThread;
use constants::{MAJOR_COLLECT_THRESHOLD, MAX_SLEEP_DUR, MIN_SLEEP_DUR};
use heap::{CollectOps, Obje... | <S: StatsLogger> {
/// This is cloned and given to app threads.
tx_chan: JournalSender,
/// The GC thread's handle to join on.
handle: thread::JoinHandle<S>,
}
impl GcThread<DefaultLogger> {
/// Spawn a GC thread with default parameters: a `ParHeap` and a `DefaultLogger` parallelized
/// acro... | GcThread | identifier_name |
main.rs | use std::error::Error;
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use std::path::Path;
use std::collections::HashMap;
extern crate regex;
use regex::Regex;
enum Ineq {
Equals(i32),
GreaterThan(i32),
LessThan(i32),
}
// --------------------------------------------------------
fn find_sue... |
let reader = BufReader::new(file);
let lines = reader.lines();
let re = Regex::new(r"(?P<key>[:alpha:]+): (?P<value>\d+)").unwrap();
let mut sue_num = 0;
let mut sue_no_conflict = -1i32;
for line in lines {
let text = line.unwrap();
sue_num += 1;
let mut has_conflict = false;
for cap in re.... | random_line_split | |
main.rs |
use std::error::Error;
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use std::path::Path;
use std::collections::HashMap;
extern crate regex;
use regex::Regex;
enum Ineq {
Equals(i32),
GreaterThan(i32),
LessThan(i32),
}
// --------------------------------------------------------
fn find_su... |
},
_ => {},
}
}
if!has_conflict {
println!("Sue {} has no conflicts", sue_num);
sue_no_conflict = sue_num;
}
}
sue_no_conflict
}
// --------------------------------------------------------
fn main() {
println!("Running part 1...");
let mut sue_stats_exact = HashMap::new();
sue_stats_... | {
has_conflict = true;
} | conditional_block |
main.rs |
use std::error::Error;
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use std::path::Path;
use std::collections::HashMap;
extern crate regex;
use regex::Regex;
enum | {
Equals(i32),
GreaterThan(i32),
LessThan(i32),
}
// --------------------------------------------------------
fn find_sue (constraints: &HashMap<&str, Ineq>, filename: &str) -> i32 {
let path = Path::new(filename);
let display = path.display();
// Open the path in read-only mode, returns `io::Result<Fi... | Ineq | identifier_name |
ascii_chars_increasing.rs | use malachite_base::chars::exhaustive::ascii_chars_increasing;
#[test]
fn | () {
assert_eq!(
ascii_chars_increasing().collect::<String>(),
"\u{0}\u{1}\u{2}\u{3}\u{4}\u{5}\u{6}\u{7}\u{8}\t\n\u{b}\u{c}\r\u{e}\u{f}\u{10}\u{11}\u{12}\
\u{13}\u{14}\u{15}\u{16}\u{17}\u{18}\u{19}\u{1a}\u{1b}\u{1c}\u{1d}\u{1e}\u{1f}!\"#$%&\'()*\
+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO... | test_ascii_chars_increasing | identifier_name |
ascii_chars_increasing.rs | use malachite_base::chars::exhaustive::ascii_chars_increasing;
#[test]
fn test_ascii_chars_increasing() | {
assert_eq!(
ascii_chars_increasing().collect::<String>(),
"\u{0}\u{1}\u{2}\u{3}\u{4}\u{5}\u{6}\u{7}\u{8}\t\n\u{b}\u{c}\r\u{e}\u{f}\u{10}\u{11}\u{12}\
\u{13}\u{14}\u{15}\u{16}\u{17}\u{18}\u{19}\u{1a}\u{1b}\u{1c}\u{1d}\u{1e}\u{1f} !\"#$%&\'()*\
+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQ... | identifier_body | |
ascii_chars_increasing.rs | use malachite_base::chars::exhaustive::ascii_chars_increasing;
#[test]
fn test_ascii_chars_increasing() {
assert_eq!(
ascii_chars_increasing().collect::<String>(),
"\u{0}\u{1}\u{2}\u{3}\u{4}\u{5}\u{6}\u{7}\u{8}\t\n\u{b}\u{c}\r\u{e}\u{f}\u{10}\u{11}\u{12}\
\u{13}\u{14}\u{15}\u{16}\u{17}\u{18... | );
assert_eq!(ascii_chars_increasing().count(), 1 << 7);
} | random_line_split | |
issue-3038.rs | impl HTMLTableElement {
fn func() | last_tbody
.upcast::<Node>()
.AppendChild(new_row.upcast::<Node>())
.expect("InsertRow failed to append first row.");
}
}
}
}
| {
if number_of_row_elements == 0 {
if let Some(last_tbody) = node
.rev_children()
.filter_map(DomRoot::downcast::<Element>)
.find(|n| {
n.is::<HTMLTableSectionElement>() && n.local_name() == &local_name!("tbody")
})
... | identifier_body |
issue-3038.rs | impl HTMLTableElement {
fn func() {
if number_of_row_elements == 0 {
if let Some(last_tbody) = node
.rev_children()
.filter_map(DomRoot::downcast::<Element>)
.find(|n| {
n.is::<HTMLTableSectionElement>() && n.local_name() == &local... | .expect("InsertRow failed to append first row.");
}
}
}
} | n.is::<HTMLTableSectionElement>() && n.local_name() == &local_name!("tbody")
}) {
last_tbody
.upcast::<Node>()
.AppendChild(new_row.upcast::<Node>()) | random_line_split |
issue-3038.rs | impl HTMLTableElement {
fn | () {
if number_of_row_elements == 0 {
if let Some(last_tbody) = node
.rev_children()
.filter_map(DomRoot::downcast::<Element>)
.find(|n| {
n.is::<HTMLTableSectionElement>() && n.local_name() == &local_name!("tbody")
})
... | func | identifier_name |
issue-3038.rs | impl HTMLTableElement {
fn func() {
if number_of_row_elements == 0 {
if let Some(last_tbody) = node
.rev_children()
.filter_map(DomRoot::downcast::<Element>)
.find(|n| {
n.is::<HTMLTableSectionElement>() && n.local_name() == &local... |
}
}
| {
if let Some(last_tbody) = node.find(|n| {
n.is::<HTMLTableSectionElement>() && n.local_name() == &local_name!("tbody")
}) {
last_tbody
.upcast::<Node>()
.AppendChild(new_row.upcast::<Node>())
.expect("I... | conditional_block |
file.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Modules/fs_fat/dir.rs
use kernel::prelude::*;
use kernel::lib::mem::aref::ArefBorrow;
use kernel::vfs::node;
const ERROR_SHORTCHAIN: node::IoError = node::IoError::Unknown("Cluster chain terminated early");
pub type FilesystemInner = super::FilesystemInner;... | impl node::NodeBase for FileNode {
fn get_id(&self) -> node::InodeId {
todo!("FileNode::get_id")
}
}
impl node::File for FileNode {
fn size(&self) -> u64 {
self.size as u64
}
fn truncate(&self, newsize: u64) -> node::Result<u64> {
todo!("FileNode::truncate({:#x})", newsize);
}
fn clear(&self, ofs: u64, siz... | random_line_split | |
file.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Modules/fs_fat/dir.rs
use kernel::prelude::*;
use kernel::lib::mem::aref::ArefBorrow;
use kernel::vfs::node;
const ERROR_SHORTCHAIN: node::IoError = node::IoError::Unknown("Cluster chain terminated early");
pub type FilesystemInner = super::FilesystemInner;... |
{
fs: ArefBorrow<FilesystemInner>,
//parent_dir: u32,
first_cluster: u32,
size: u32,
}
impl FileNode
{
pub fn new_boxed(fs: ArefBorrow<FilesystemInner>, _parent: u32, first_cluster: u32, size: u32) -> Box<FileNode> {
Box::new(FileNode {
fs: fs,
//parent_dir: parent,
first_cluster: first_cluster,
s... | FileNode | identifier_name |
file.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Modules/fs_fat/dir.rs
use kernel::prelude::*;
use kernel::lib::mem::aref::ArefBorrow;
use kernel::vfs::node;
const ERROR_SHORTCHAIN: node::IoError = node::IoError::Unknown("Cluster chain terminated early");
pub type FilesystemInner = super::FilesystemInner;... |
}
impl node::File for FileNode {
fn size(&self) -> u64 {
self.size as u64
}
fn truncate(&self, newsize: u64) -> node::Result<u64> {
todo!("FileNode::truncate({:#x})", newsize);
}
fn clear(&self, ofs: u64, size: u64) -> node::Result<()> {
todo!("FileNode::clear({:#x}+{:#x}", ofs, size);
}
fn read(&self, of... | {
todo!("FileNode::get_id")
} | identifier_body |
function.rs | //! Defines the `FunctionProto` type, which is a garbage-collected version of core's `FnData`, as
//! well as the `Function` type, which is an instantiated, runnable function inside the VM.
use lea_core::fndata::{UpvalDesc, FnData};
use lea_core::opcode::*;
use mem::*;
use Value;
use std::rc::Rc;
use std::cell::Cell... | else {
Rc::new(Cell::new(Upval::Closed(Value::Nil)))
})
}
/// Sets an upvalue to the given value.
pub fn set_upvalue(&mut self, id: usize, val: Upval) {
self.upvalues[id].set(val);
}
}
impl Traceable for Function {
fn trace<T: Tracer>(&self, t: &mut T) {
t.mark... | {
first = false;
Rc::new(Cell::new(Upval::Closed(env)))
} | conditional_block |
function.rs | //! Defines the `FunctionProto` type, which is a garbage-collected version of core's `FnData`, as
//! well as the `Function` type, which is an instantiated, runnable function inside the VM.
use lea_core::fndata::{UpvalDesc, FnData};
use lea_core::opcode::*;
use mem::*;
use Value;
use std::rc::Rc;
use std::cell::Cell... | (&mut self, id: usize, val: Upval) {
self.upvalues[id].set(val);
}
}
impl Traceable for Function {
fn trace<T: Tracer>(&self, t: &mut T) {
t.mark_traceable(self.proto);
for uv in &self.upvalues {
if let Upval::Closed(val) = uv.get() {
val.trace(t);
... | set_upvalue | identifier_name |
function.rs | //! Defines the `FunctionProto` type, which is a garbage-collected version of core's `FnData`, as
//! well as the `Function` type, which is an instantiated, runnable function inside the VM.
use lea_core::fndata::{UpvalDesc, FnData};
use lea_core::opcode::*;
use mem::*;
use Value;
use std::rc::Rc;
use std::cell::Cell... | Open(usize),
/// Closed upvalue, storing its value inline
Closed(Value),
}
/// Instantiated function
#[derive(Debug)]
pub struct Function {
/// The prototype from which this function was instantiated
pub proto: TracedRef<FunctionProto>,
/// Upvalue references, indexed by upvalue ID
pub upva... | random_line_split | |
function.rs | //! Defines the `FunctionProto` type, which is a garbage-collected version of core's `FnData`, as
//! well as the `Function` type, which is an instantiated, runnable function inside the VM.
use lea_core::fndata::{UpvalDesc, FnData};
use lea_core::opcode::*;
use mem::*;
use Value;
use std::rc::Rc;
use std::cell::Cell... |
}
/// An active Upvalue
#[derive(Debug, Clone, Copy)]
pub enum Upval {
/// Upvalue is stored in a stack slot
Open(usize),
/// Closed upvalue, storing its value inline
Closed(Value),
}
/// Instantiated function
#[derive(Debug)]
pub struct Function {
/// The prototype from which this function was i... | {
for ch in &self.child_protos {
t.mark_traceable(*ch);
}
} | identifier_body |
dependent_pairs.rs | use iterators::adaptors::Concat;
use iterators::general::CachedIterator;
use iterators::tuples::{LogPairIndices, ZOrderTupleIndices};
use malachite_base::num::conversion::traits::ExactFrom;
use std::collections::HashMap;
use std::hash::Hash;
pub fn dependent_pairs<'a, I: Iterator + 'a, J: Iterator, F: 'a>(
xs: I,
... | return Some((x, ys.next().unwrap()));
}
let mut ys = (self.f)(&self.data, &x);
let y = ys.next().unwrap();
self.x_to_ys.insert(x.clone(), ys);
Some((x, y))
}
}
pub fn $fn_name<I: Iterator, J:... | let x = self.xs.get(xi).unwrap();
self.i.increment();
if let Some(ys) = self.x_to_ys.get_mut(&x) { | random_line_split |
dependent_pairs.rs | use iterators::adaptors::Concat;
use iterators::general::CachedIterator;
use iterators::tuples::{LogPairIndices, ZOrderTupleIndices};
use malachite_base::num::conversion::traits::ExactFrom;
use std::collections::HashMap;
use std::hash::Hash;
pub fn dependent_pairs<'a, I: Iterator + 'a, J: Iterator, F: 'a>(
xs: I,
... | <I: Iterator, J: Iterator, F, T>
where
F: Fn(&T, &I::Item) -> J,
{
xs: I,
f: F,
data: T,
x_to_ys: HashMap<I::Item, J>,
}
impl<I: Iterator, J: Iterator, F, T> Iterator for RandomDependentPairs<I, J, F, T>
where
F: Fn(&T, &I::Item) -> J,
I::Item: Clone + Eq + Hash,
{
type Item = (I::Item,... | RandomDependentPairs | identifier_name |
main.rs | // Benchmark testing primitives
#![feature(test)]
extern crate test;
#[macro_use]
extern crate maplit;
extern crate bufstream;
extern crate docopt;
extern crate linked_hash_map;
extern crate libc;
extern crate net2;
extern crate rand;
extern crate rustc_serialize;
extern crate time;
mod common;
mod metrics;
mod optio... | opts.get_bind_string(),
opts.get_mem_limit());
let mut listener_task = ListenerTask::new(opts.clone());
listener_task.run();
} | random_line_split | |
main.rs | // Benchmark testing primitives
#![feature(test)]
extern crate test;
#[macro_use]
extern crate maplit;
extern crate bufstream;
extern crate docopt;
extern crate linked_hash_map;
extern crate libc;
extern crate net2;
extern crate rand;
extern crate rustc_serialize;
extern crate time;
mod common;
mod metrics;
mod optio... |
println!("Running tcp server on {} with {}mb capacity...",
opts.get_bind_string(),
opts.get_mem_limit());
let mut listener_task = ListenerTask::new(opts.clone());
listener_task.run();
}
| {
// We're done here :)
return;
} | conditional_block |
main.rs | // Benchmark testing primitives
#![feature(test)]
extern crate test;
#[macro_use]
extern crate maplit;
extern crate bufstream;
extern crate docopt;
extern crate linked_hash_map;
extern crate libc;
extern crate net2;
extern crate rand;
extern crate rustc_serialize;
extern crate time;
mod common;
mod metrics;
mod optio... | () {
println!("{} {}", consts::APP_NAME, consts::APP_VERSION);
}
fn main() {
print_version();
let opts = parse_args();
if opts.flag_version {
// We're done here :)
return;
}
println!("Running tcp server on {} with {}mb capacity...",
opts.get_bind_string(),
... | print_version | identifier_name |
main.rs | // Benchmark testing primitives
#![feature(test)]
extern crate test;
#[macro_use]
extern crate maplit;
extern crate bufstream;
extern crate docopt;
extern crate linked_hash_map;
extern crate libc;
extern crate net2;
extern crate rand;
extern crate rustc_serialize;
extern crate time;
mod common;
mod metrics;
mod optio... | {
print_version();
let opts = parse_args();
if opts.flag_version {
// We're done here :)
return;
}
println!("Running tcp server on {} with {}mb capacity...",
opts.get_bind_string(),
opts.get_mem_limit());
let mut listener_task = ListenerTask::new(opts.... | identifier_body | |
hsts.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use net_traits::IncludeSubdomains;
use rustc_serialize::json::{decode};
use std::net::{Ipv4Addr, Ipv6Addr};
use st... | }
})
}
fn has_domain(&self, host: &str) -> bool {
self.entries.iter().any(|e| {
e.matches_domain(&host)
})
}
fn has_subdomain(&self, host: &str) -> bool {
self.entries.iter().any(|e| {
e.matches_subdomain(host)
})
}
p... | self.entries.iter().any(|e| {
if e.include_subdomains {
e.matches_subdomain(host) || e.matches_domain(host)
} else {
e.matches_domain(host) | random_line_split |
hsts.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use net_traits::IncludeSubdomains;
use rustc_serialize::json::{decode};
use std::net::{Ipv4Addr, Ipv6Addr};
use st... | else if!have_subdomain {
for e in &mut self.entries {
if e.matches_domain(&entry.host) {
e.include_subdomains = entry.include_subdomains;
e.max_age = entry.max_age;
}
}
}
}
}
pub fn preload_hsts_domains() -> Op... | {
self.entries.push(entry);
} | conditional_block |
hsts.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use net_traits::IncludeSubdomains;
use rustc_serialize::json::{decode};
use std::net::{Ipv4Addr, Ipv6Addr};
use st... | {
pub host: String,
pub include_subdomains: bool,
pub max_age: Option<u64>,
pub timestamp: Option<u64>
}
impl HSTSEntry {
pub fn new(host: String, subdomains: IncludeSubdomains, max_age: Option<u64>) -> Option<HSTSEntry> {
if host.parse::<Ipv4Addr>().is_ok() || host.parse::<Ipv6Addr>().is_... | HSTSEntry | identifier_name |
readline.rs | // SairaDB - A distributed database
// Copyright (C) 2015 by Siyu Wang
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later ver... |
}
| {
let mut s = "".to_string();
print!("{}", prompt);
match stdin().read_line(&mut s) {
Ok(_) => {
s.pop(); // pop '\n'
Some(s)
}
Err(_) => None
}
} | conditional_block |
readline.rs | // SairaDB - A distributed database
// Copyright (C) 2015 by Siyu Wang
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later ver... |
pub fn read_line(prompt: &str) -> Option<String> {
if cfg!(unix) {
read_line_unix(prompt)
} else {
let mut s = "".to_string();
print!("{}", prompt);
match stdin().read_line(&mut s) {
Ok(_) => {
s.pop(); // pop '\n'
Some(s)
... | {
let pr = CString::new(prompt.as_bytes()).unwrap();
let sp = unsafe { rl_readline(pr.as_ptr()) };
if sp.is_null() {
None
} else {
let cs = unsafe { CStr::from_ptr(sp) };
let line = from_utf8(cs.to_bytes()).unwrap();
push_history(&line);
Some(line.to_string())
... | identifier_body |
readline.rs | // SairaDB - A distributed database
// Copyright (C) 2015 by Siyu Wang
//
// This program is free software; you can redistribute it and/or | // modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty ... | random_line_split | |
readline.rs | // SairaDB - A distributed database
// Copyright (C) 2015 by Siyu Wang
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later ver... | (prompt: &str) -> Option<String> {
let pr = CString::new(prompt.as_bytes()).unwrap();
let sp = unsafe { rl_readline(pr.as_ptr()) };
if sp.is_null() {
None
} else {
let cs = unsafe { CStr::from_ptr(sp) };
let line = from_utf8(cs.to_bytes()).unwrap();
push_history(&line);
... | read_line_unix | identifier_name |
usbiodef.rs | // Copyright © 2016 winapi-rs developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modi... | pub const USB_GET_DEVICE_HANDLE_EX: ULONG = 269;
pub const USB_GET_TT_DEVICE_HANDLE: ULONG = 270;
pub const USB_GET_TOPOLOGY_ADDRESS: ULONG = 271;
pub const USB_IDLE_NOTIFICATION_EX: ULONG = 272;
pub const USB_REQ_GLOBAL_SUSPEND: ULONG = 273;
pub const USB_REQ_GLOBAL_RESUME: ULONG = 274;
pub const USB_GET_HUB_CONFIG_IN... | random_line_split | |
usbiodef.rs | // Copyright © 2016 winapi-rs developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modi... | id: ULONG) -> ULONG {
CTL_CODE!(FILE_DEVICE_USB, id, METHOD_NEITHER, FILE_ANY_ACCESS)
}
#[inline]
pub fn USB_KERNEL_CTL_BUFFERED(id: ULONG) -> ULONG {
CTL_CODE!(FILE_DEVICE_USB, id, METHOD_BUFFERED, FILE_ANY_ACCESS)
}
// No calling convention was specified in the code
FN!{stdcall USB_IDLE_CALLBACK(
Context:... | SB_KERNEL_CTL( | identifier_name |
usbiodef.rs | // Copyright © 2016 winapi-rs developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modi... | #[inline]
pub fn USB_KERNEL_CTL_BUFFERED(id: ULONG) -> ULONG {
CTL_CODE!(FILE_DEVICE_USB, id, METHOD_BUFFERED, FILE_ANY_ACCESS)
}
// No calling convention was specified in the code
FN!{stdcall USB_IDLE_CALLBACK(
Context: PVOID,
) -> ()}
STRUCT!{struct USB_IDLE_CALLBACK_INFO {
IdleCallback: USB_IDLE_CALLBACK... |
CTL_CODE!(FILE_DEVICE_USB, id, METHOD_NEITHER, FILE_ANY_ACCESS)
}
| identifier_body |
macros.rs | // Bloom
//
// HTTP REST API caching middleware
// Copyright: 2017, Valerian Saliou <valerian@valeriansaliou.name>
// License: Mozilla Public License v2.0 (MPL v2.0)
macro_rules! get_cache_store_client_try {
($pool:expr, $error:expr, $client:ident $code:block) => {
// In the event of a Redis failure, 'try_... | // an operation succeeds (eg. for cache purges).
match $pool.get() {
Ok(mut $client) => $code,
Err(err) => {
error!(
"failed getting a cache store client from pool (wait mode), because: {}",
err
);
... | random_line_split | |
plugins.rs | use settings;
use indy::ErrorCode;
static INIT_PLUGIN: std::sync::Once = std::sync::Once::new();
pub fn init_plugin(library: &str, initializer: &str) {
settings::set_config_value(settings::CONFIG_PAYMENT_METHOD, settings::DEFAULT_PAYMENT_METHOD);
INIT_PLUGIN.call_once(|| {
if let Ok(lib) = _load_lib(... |
}
} else {
error!("Plugin not found: {:?}", library);
std::process::exit(123);
}
});
}
#[cfg(all(unix, test, not(target_os = "android")))]
fn _load_lib(library: &str) -> libloading::Result<libloading::Library> {
libloading::os::unix::Library::open(Some(libra... | {
error!("Init function not found: {:?}", initializer);
std::process::exit(123);
} | conditional_block |
plugins.rs | use settings;
use indy::ErrorCode;
static INIT_PLUGIN: std::sync::Once = std::sync::Once::new();
pub fn init_plugin(library: &str, initializer: &str) {
settings::set_config_value(settings::CONFIG_PAYMENT_METHOD, settings::DEFAULT_PAYMENT_METHOD);
INIT_PLUGIN.call_once(|| {
if let Ok(lib) = _load_lib(... | });
}
#[cfg(all(unix, test, not(target_os = "android")))]
fn _load_lib(library: &str) -> libloading::Result<libloading::Library> {
libloading::os::unix::Library::open(Some(library), libc::RTLD_NOW | libc::RTLD_NODELETE)
.map(libloading::Library::from)
}
#[cfg(any(not(unix), not(test), target_os = "andr... | }
} else {
error!("Plugin not found: {:?}", library);
std::process::exit(123);
} | random_line_split |
plugins.rs | use settings;
use indy::ErrorCode;
static INIT_PLUGIN: std::sync::Once = std::sync::Once::new();
pub fn | (library: &str, initializer: &str) {
settings::set_config_value(settings::CONFIG_PAYMENT_METHOD, settings::DEFAULT_PAYMENT_METHOD);
INIT_PLUGIN.call_once(|| {
if let Ok(lib) = _load_lib(library) {
unsafe {
if let Ok(init_func) = lib.get(initializer.as_bytes()) {
... | init_plugin | identifier_name |
plugins.rs | use settings;
use indy::ErrorCode;
static INIT_PLUGIN: std::sync::Once = std::sync::Once::new();
pub fn init_plugin(library: &str, initializer: &str) {
settings::set_config_value(settings::CONFIG_PAYMENT_METHOD, settings::DEFAULT_PAYMENT_METHOD);
INIT_PLUGIN.call_once(|| {
if let Ok(lib) = _load_lib(... | {
libloading::Library::new(library)
} | identifier_body | |
mod.rs | /*!
Functions to manage large numbers of placable entities.
*/
extern crate image;
use super::*;
use image::Rgba;
use std::cmp;
pub mod gif;
pub mod network;
/**
Returns the underlaying image used for the Map struct.
*/
pub fn gen_map<T: Location + Draw + MinMax>(
list: &[T],
) -> (image::ImageBuffer<Rgba<u8>,... |
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_gen_canvas() {
let image = gen_canvas(50, 50);
assert_eq!(image.width(), 50);
assert_eq!(image.height(), 50);
}
#[test]
fn test_gen_canvas_2() {
let image = gen_canvas(0, 0);
assert_eq!(image.width(... | {
image::DynamicImage::new_rgba8(w, h).to_rgba()
} | identifier_body |
mod.rs | /*!
Functions to manage large numbers of placable entities.
*/
extern crate image;
use super::*;
use image::Rgba;
use std::cmp;
pub mod gif;
pub mod network;
/**
Returns the underlaying image used for the Map struct.
*/
pub fn gen_map<T: Location + Draw + MinMax>(
list: &[T],
) -> (image::ImageBuffer<Rgba<u8>,... | <T: Location + Draw + MinMax>(list: &[T]) -> (Coordinate, Coordinate) {
let mut size: i16 = consts::DEFAULT_SIZE as i16;
let mut min = coordinate!();
let mut max = coordinate!();
for item in list {
size = cmp::max(size, item.size() as i16);
let (imin, imax) = item.min_max();
ma... | min_max | identifier_name |
mod.rs | /*!
Functions to manage large numbers of placable entities.
*/
extern crate image;
use super::*;
use image::Rgba;
use std::cmp;
pub mod gif;
pub mod network;
/**
Returns the underlaying image used for the Map struct.
*/
pub fn gen_map<T: Location + Draw + MinMax>(
list: &[T],
) -> (image::ImageBuffer<Rgba<u8>,... | fn test_gen_canvas() {
let image = gen_canvas(50, 50);
assert_eq!(image.width(), 50);
assert_eq!(image.height(), 50);
}
#[test]
fn test_gen_canvas_2() {
let image = gen_canvas(0, 0);
assert_eq!(image.width(), 0);
assert_eq!(image.height(), 0);
}
... | random_line_split | |
main.rs | #[macro_use] extern crate log;
extern crate env_logger;
extern crate yak_client;
extern crate capnp;
extern crate log4rs;
extern crate rusqlite;
extern crate byteorder;
#[cfg(test)]
extern crate quickcheck;
#[cfg(test)]
extern crate rand;
use std::default::Default;
use std::net::{TcpListener, TcpStream};
use std::thre... | &ServerError::IoError(ref e) => e.fmt(f),
&ServerError::DownstreamError(ref e) => e.fmt(f),
&ServerError::StoreError(ref e) => write!(f, "{}", e),
}
}
}
impl Error for ServerError {
fn description(&self) -> &str {
match self {
&ServerError::CapnpError(ref e) => e.description(),
... | random_line_split | |
main.rs | #[macro_use] extern crate log;
extern crate env_logger;
extern crate yak_client;
extern crate capnp;
extern crate log4rs;
extern crate rusqlite;
extern crate byteorder;
#[cfg(test)]
extern crate quickcheck;
#[cfg(test)]
extern crate rand;
use std::default::Default;
use std::net::{TcpListener, TcpStream};
use std::thre... | (&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match self.protocol.try_lock() {
Ok(ref proto) => write!(fmt, "DownStream{{ protocol: {:?} }}", &**proto),
Err(_) => write!(fmt, "DownStream{{ protocol: <locked> }}"),
}
}
}
impl<S> Clone for DownStream<S> wher... | fmt | identifier_name |
main.rs | #[macro_use] extern crate log;
extern crate env_logger;
extern crate yak_client;
extern crate capnp;
extern crate log4rs;
extern crate rusqlite;
extern crate byteorder;
#[cfg(test)]
extern crate quickcheck;
#[cfg(test)]
extern crate rand;
use std::default::Default;
use std::net::{TcpListener, TcpStream};
use std::thre... |
fn write(&self, seq: SeqNo, space: &str, key: &[u8], val: &[u8]) -> Result<Response, ServerError> {
trace!("{}/{:?}: write:{:?} -> {:?}", self.id, space, key, val);
try_box!(self.store.write(space, key, val));
Ok(Response::Okay(seq))
}
fn subscribe(&mut self, seq: SeqNo, space: &str) -> Result<(), S... | {
let val = try_box!(self.store.read(space, key));
trace!("{}/{:?}: read:{:?}: -> {:?}", self.id, space, key, val);
let data = val.iter().map(|c| Datum { key: Vec::new(), content: c.clone() }).collect();
Ok(Response::OkayData(seq, data))
} | identifier_body |
lib.rs | #![crate_name = "r6"]
//! r6.rs is an attempt to implement R6RS Scheme in Rust language
#![feature(slice_patterns)]
#![feature(io)]
// This line should be at the top of the extern link list,
// because some weird compiler bug lets log imported from rustc, not crates.io log
#[macro_use] extern crate log;
#[macro_use]... | pub mod cast;
/// Macro implementations
pub mod syntax; | random_line_split | |
mod.rs | //! Types related to database connections
mod statement_cache;
mod transaction_manager;
use std::fmt::Debug;
use crate::backend::Backend;
use crate::deserialize::FromSqlRow;
use crate::expression::QueryMetadata;
use crate::query_builder::{AsQuery, QueryFragment, QueryId};
use crate::result::*;
#[doc(hidden)]
pub us... | /// assert_eq!(vec!["Sean", "Tess", "Ruby"], all_names);
///
/// Ok(())
/// });
///
/// // Even though we returned `Ok`, the transaction wasn't committed.
/// let all_names = users.select(name).load::<String>(&conn)?;
/// assert_eq!(vec!["Sean", "Tess"], all_names);
/// # ... | ///
/// let all_names = users.select(name).load::<String>(&conn)?; | random_line_split |
mod.rs | //! Types related to database connections
mod statement_cache;
mod transaction_manager;
use std::fmt::Debug;
use crate::backend::Backend;
use crate::deserialize::FromSqlRow;
use crate::expression::QueryMetadata;
use crate::query_builder::{AsQuery, QueryFragment, QueryId};
use crate::result::*;
#[doc(hidden)]
pub us... |
}
}
/// Creates a transaction that will never be committed. This is useful for
/// tests. Panics if called while inside of a transaction.
fn begin_test_transaction(&self) -> QueryResult<()>
where
Self: Sized,
{
let transaction_manager = self.transaction_manager();
... | {
transaction_manager.rollback_transaction(self)?;
Err(e)
} | conditional_block |
mod.rs | //! Types related to database connections
mod statement_cache;
mod transaction_manager;
use std::fmt::Debug;
use crate::backend::Backend;
use crate::deserialize::FromSqlRow;
use crate::expression::QueryMetadata;
use crate::query_builder::{AsQuery, QueryFragment, QueryId};
use crate::result::*;
#[doc(hidden)]
pub us... | (&self) -> &dyn std::any::Any {
self
}
}
impl<DB: Backend> dyn BoxableConnection<DB> {
/// Downcast the current connection to a specific connection
/// type.
///
/// This will return `None` if the underlying
/// connection does not match the corresponding
/// type, otherwise a refer... | as_any | identifier_name |
mod.rs | //! Types related to database connections
mod statement_cache;
mod transaction_manager;
use std::fmt::Debug;
use crate::backend::Backend;
use crate::deserialize::FromSqlRow;
use crate::expression::QueryMetadata;
use crate::query_builder::{AsQuery, QueryFragment, QueryId};
use crate::result::*;
#[doc(hidden)]
pub us... |
}
| {
self.as_any().is::<T>()
} | identifier_body |
json_body_parser.rs | use serialize::{Decodable, json};
use request::Request;
use typemap::Key;
use plugin::{Plugin, Pluggable};
use std::io;
use std::io::{Read, ErrorKind}; |
impl<'mw, 'conn, D> Plugin<Request<'mw, 'conn, D>> for JsonBodyParser {
type Error = io::Error;
fn eval(req: &mut Request<D>) -> Result<String, io::Error> {
let mut s = String::new();
try!(req.origin.read_to_string(&mut s));
Ok(s)
}
}
pub trait JsonBody {
fn json_as<T: Decodab... |
// Plugin boilerplate
struct JsonBodyParser;
impl Key for JsonBodyParser { type Value = String; } | random_line_split |
json_body_parser.rs | use serialize::{Decodable, json};
use request::Request;
use typemap::Key;
use plugin::{Plugin, Pluggable};
use std::io;
use std::io::{Read, ErrorKind};
// Plugin boilerplate
struct | ;
impl Key for JsonBodyParser { type Value = String; }
impl<'mw, 'conn, D> Plugin<Request<'mw, 'conn, D>> for JsonBodyParser {
type Error = io::Error;
fn eval(req: &mut Request<D>) -> Result<String, io::Error> {
let mut s = String::new();
try!(req.origin.read_to_string(&mut s));
Ok(s)
... | JsonBodyParser | identifier_name |
reporter.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::SourceLocation; | use msg::constellation_msg::PipelineId;
use script_traits::ConstellationControlMsg;
use servo_url::ServoUrl;
use std::sync::{Mutex, Arc};
use style::error_reporting::{ParseErrorReporter, ContextualParseError};
#[derive(HeapSizeOf, Clone)]
pub struct CSSErrorReporter {
pub pipelineid: PipelineId,
// Arc+Mutex c... | use ipc_channel::ipc::IpcSender;
use log; | random_line_split |
reporter.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::SourceLocation;
use ipc_channel::ipc::IpcSender;
use log;
use msg::constellation_msg::PipelineId;
u... |
//TODO: report a real filename
let _ = self.script_chan.lock().unwrap().send(
ConstellationControlMsg::ReportCSSError(self.pipelineid,
"".to_owned(),
location.line,
... | {
info!("Url:\t{}\n{}:{} {}",
url.as_str(),
location.line,
location.column,
error.to_string())
} | conditional_block |
reporter.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::SourceLocation;
use ipc_channel::ipc::IpcSender;
use log;
use msg::constellation_msg::PipelineId;
u... | (&self,
url: &ServoUrl,
location: SourceLocation,
error: ContextualParseError) {
if log_enabled!(log::LogLevel::Info) {
info!("Url:\t{}\n{}:{} {}",
url.as_str(),
location.line,
location.... | report_error | identifier_name |
mod.rs | //! Translators for various architectures to Falcon IL.
//!
//! Translators in Falcon do not lift individual instructions, but instead lift
//! basic blocks. This is both more performant than lifting individual
//! instructions, and allows Falcon to deal with weird cases such as the delay
//! slot in the MIPS architect... | control_flow_graph.set_entry(block_index)?;
control_flow_graph.set_exit(block_index)?;
translation_results.insert(
block_address,
BlockTranslationResult::new(
vec![(block_address, control_flow_graph)],
... | let mut control_flow_graph = ControlFlowGraph::new();
let block_index = control_flow_graph.new_block()?.index(); | random_line_split |
mod.rs | //! Translators for various architectures to Falcon IL.
//!
//! Translators in Falcon do not lift individual instructions, but instead lift
//! basic blocks. This is both more performant than lifting individual
//! instructions, and allows Falcon to deal with weird cases such as the delay
//! slot in the MIPS architect... | }
/// A generic translation trait, implemented by various architectures.
pub trait Translator {
/// Translates a basic block
fn translate_block(
&self,
bytes: &[u8],
address: u64,
options: &Options,
) -> Result<BlockTranslationResult>;
/// Translates a function
fn ... | {
let block_index = {
let block = control_flow_graph.new_block()?;
block.intrinsic(il::Intrinsic::new(
instruction.mnemonic.clone(),
format!("{} {}", instruction.mnemonic, instruction.op_str),
Vec::new(),
None,
None,
instructio... | identifier_body |
mod.rs | //! Translators for various architectures to Falcon IL.
//!
//! Translators in Falcon do not lift individual instructions, but instead lift
//! basic blocks. This is both more performant than lifting individual
//! instructions, and allows Falcon to deal with weird cases such as the delay
//! slot in the MIPS architect... | (
control_flow_graph: &mut il::ControlFlowGraph,
instruction: &capstone::Instr,
) -> Result<()> {
let block_index = {
let block = control_flow_graph.new_block()?;
block.intrinsic(il::Intrinsic::new(
instruction.mnemonic.clone(),
format!("{} {}", instruction.mnemonic,... | unhandled_intrinsic | identifier_name |
build.rs | extern crate gcc;
use std::path::PathBuf;
use std::env;
const LIB_NAME: &'static str = "libctxswtch.a";
fn main() {
let arch =
if cfg!(target_arch = "x86_64") {
"x86_64"
} else if cfg!(target_arch = "i686") {
"i686"
} else if cfg!(target_arch = "arm") {
... | else {
panic!("Unsupported architecture: {}", env::var("TARGET").unwrap());
};
let src_path = &["src", "asm", arch, "_context.S"].iter().collect::<PathBuf>();
gcc::compile_library(LIB_NAME, &[src_path.to_str().unwrap()]);
// seems like this line is no need actually
// println!("cargo:ru... | {
"mipsel"
} | conditional_block |
build.rs | extern crate gcc;
use std::path::PathBuf;
use std::env;
const LIB_NAME: &'static str = "libctxswtch.a";
fn | () {
let arch =
if cfg!(target_arch = "x86_64") {
"x86_64"
} else if cfg!(target_arch = "i686") {
"i686"
} else if cfg!(target_arch = "arm") {
"arm"
} else if cfg!(target_arch = "mips") {
"mips"
} else if cfg!(target_arch = "mip... | main | identifier_name |
build.rs | extern crate gcc;
use std::path::PathBuf;
use std::env;
const LIB_NAME: &'static str = "libctxswtch.a";
fn main() | }
| {
let arch =
if cfg!(target_arch = "x86_64") {
"x86_64"
} else if cfg!(target_arch = "i686") {
"i686"
} else if cfg!(target_arch = "arm") {
"arm"
} else if cfg!(target_arch = "mips") {
"mips"
} else if cfg!(target_arch = "mipsel... | identifier_body |
build.rs | extern crate gcc;
use std::path::PathBuf;
use std::env;
const LIB_NAME: &'static str = "libctxswtch.a"; | if cfg!(target_arch = "x86_64") {
"x86_64"
} else if cfg!(target_arch = "i686") {
"i686"
} else if cfg!(target_arch = "arm") {
"arm"
} else if cfg!(target_arch = "mips") {
"mips"
} else if cfg!(target_arch = "mipsel") {
... |
fn main() {
let arch = | random_line_split |
nbb.rs | //! A Non-blocking buffer implementation
use alloc::raw_vec::RawVec;
use core::ptr;
use interrupts::no_interrupts;
use super::stream::*;
/// A non-blocking circular buffer for use
/// by interrupt handlers
pub struct NonBlockingBuffer {
// A buffer
buffer: RawVec<char>,
// index of the front of the bu... | buffer: RawVec::with_capacity(cap),
front: 0,
size: 0,
}
}
}
impl InputStream for NonBlockingBuffer {
type Output = Option<char>;
/// Get the next character in the stream if there is one
fn get(&mut self) -> Option<char> {
no_interrupts(|| {
... | NonBlockingBuffer { | random_line_split |
nbb.rs | //! A Non-blocking buffer implementation
use alloc::raw_vec::RawVec;
use core::ptr;
use interrupts::no_interrupts;
use super::stream::*;
/// A non-blocking circular buffer for use
/// by interrupt handlers
pub struct NonBlockingBuffer {
// A buffer
buffer: RawVec<char>,
// index of the front of the bu... |
}
impl InputStream for NonBlockingBuffer {
type Output = Option<char>;
/// Get the next character in the stream if there is one
fn get(&mut self) -> Option<char> {
no_interrupts(|| {
if self.size > 0 {
let i = self.front;
self.front = (self.front + 1) %... | {
NonBlockingBuffer {
buffer: RawVec::with_capacity(cap),
front: 0,
size: 0,
}
} | identifier_body |
nbb.rs | //! A Non-blocking buffer implementation
use alloc::raw_vec::RawVec;
use core::ptr;
use interrupts::no_interrupts;
use super::stream::*;
/// A non-blocking circular buffer for use
/// by interrupt handlers
pub struct NonBlockingBuffer {
// A buffer
buffer: RawVec<char>,
// index of the front of the bu... | (&mut self, c: char) {
no_interrupts(|| {
if self.size < self.buffer.cap() {
let next = (self.front + self.size) % self.buffer.cap();
unsafe {
ptr::write(self.buffer.ptr().offset(next as isize), c);
}
self.size += 1;... | put | identifier_name |
nbb.rs | //! A Non-blocking buffer implementation
use alloc::raw_vec::RawVec;
use core::ptr;
use interrupts::no_interrupts;
use super::stream::*;
/// A non-blocking circular buffer for use
/// by interrupt handlers
pub struct NonBlockingBuffer {
// A buffer
buffer: RawVec<char>,
// index of the front of the bu... | else {
None
}
})
}
}
impl Iterator for NonBlockingBuffer {
type Item = char;
fn next(&mut self) -> Option<char> {
self.get()
}
}
impl OutputStream<char> for NonBlockingBuffer {
/// Put the given character at the end of the buffer.
///
/// If th... | {
let i = self.front;
self.front = (self.front + 1) % self.buffer.cap();
self.size -= 1;
unsafe { Some(ptr::read(self.buffer.ptr().offset(i as isize))) }
} | conditional_block |
sin.rs | //! Implements vertical (lane-wise) floating-point `sin`.
| #[inline]
pub fn sin(self) -> Self {
use crate::codegen::math::float::sin::Sin;
Sin::sin(self)
}
/// Sine of `self * PI`.
#[inline]
pub fn sin_pi(self) -> Self {
use crate::codegen::math::float::sin_... | macro_rules! impl_math_float_sin {
([$elem_ty:ident; $elem_count:expr]: $id:ident | $test_tt:tt) => {
impl $id {
/// Sine. | random_line_split |
macro_rules.rs | of `{}` is likely invalid in this context",
name);
parser.span_note(self.site_span, &msg[..]);
}
}
}
impl<'a> MacResult for ParserAnyMacro<'a> {
fn make_expr(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Expr>> {
let ret = self.... | Some(_) => {
cx.span_err(sp, "sequence repetition followed by another \
sequence repetition, which is not allowed"); | random_line_split | |
macro_rules.rs | let msg = format!("macro expansion ignores token `{}` and any \
following",
token_str);
let span = parser.span;
parser.span_err(span, &msg[..]);
let name = token::get_ident(self.macro_ident);
let msg ... |
// returns the last token that was checked, for TtSequence. this gets used later on.
fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
-> Option<(Span, Token)> where I: Iterator<Item=&'a TokenTree> {
use print::pprust::token_to_string;
let mut last = None;
// 2. For each token T in M... | {
// lhs is going to be like MatchedNonterminal(NtTT(TtDelimited(...))), where the entire lhs is
// those tts. Or, it can be a "bare sequence", not wrapped in parens.
match lhs {
&MatchedNonterminal(NtTT(ref inner)) => match &**inner {
&TtDelimited(_, ref tts) => {
check_... | identifier_body |
macro_rules.rs | let msg = format!("macro expansion ignores token `{}` and any \
following",
token_str);
let span = parser.span;
parser.span_err(span, &msg[..]);
let name = token::get_ident(self.macro_ident);
let msg ... | cx.span_err(sp, "sequence repetition followed by \
another sequence repetition, which is not allowed");
Eof
},
None => E... | {
// iii. Else, T is a complex NT.
match seq.separator {
// If T has the form $(...)U+ or $(...)U* for some token U,
// run the algorithm on the contents with F set to U. If it
// accepts, continue, else, reject.
... | conditional_block |
macro_rules.rs | let msg = format!("macro expansion ignores token `{}` and any \
following",
token_str);
let span = parser.span;
parser.span_err(span, &msg[..]);
let name = token::get_ident(self.macro_ident);
let msg ... | <'cx>(cx: &'cx ExtCtxt,
sp: Span,
name: ast::Ident,
imported_from: Option<ast::Ident>,
arg: &[ast::TokenTree],
lhses: &[Rc<NamedMatch>],
rhses: &[Rc<NamedMatch>])
... | generic_extension | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.