content stringlengths 12 392k | id int64 0 1.08k |
|---|---|
fn main() -> Result<()> {
let args = Args::parse();
let Args {
aspect_ratio,
image_width,
image_height,
samples_per_pixel,
outfile,
max_depth,
} = args;
let (stats_tx, stats_rx) = unbounded();
let (render_tx, render_rx) = bounded(1024);
let look_... | 600 |
fn test_where() {
let module = make_module(
indoc! {r#"
-- taken from http://learnyouahaskell.com/syntax-in-functions#pattern-matching
str_imc w h =
if bmi <= 18.5 then "You're underweight, you emo, you!"
elif bmi <= 25.0 then "You're supposedly normal... | 601 |
fn parse_file(file_name: &str) -> Vec<Instruction> {
let f = File::open(file_name).expect("Could not open the specified file.");
let reader = BufReader::new(f);
reader
.lines()
.map(|lr| lr.expect("Could not read a line."))
.map(|l| parse_instruction(&l))
.collect()
} | 602 |
fn number_vectorizer(card_digits: &String) {
let mut card_number: [u32; 16] = [0; 16];
let mut index = 0;
for digit in card_digits.chars() {
card_number[index] = digit.to_digit(10).expect("Non number on credit card");
index += 1;
}
credit_checksum(&mut card_number);
} | 603 |
fn main() {
let input = "49276d206b696c6c696e6720796f757220627261696e20\
6c696b65206120706f69736f6e6f7573206d757368726f6f6d";
println!("{}", encoding::hexstr_to_base64str(input));
} | 604 |
pub extern "x86-interrupt" fn not_use_0() { CommonInterruptHandler(42); } | 605 |
fn part_2() {
let re = Regex::new(r".*=(-?\d+)\.+(-?\d+).*=(-?\d+)\.+(-?\d+).*=(-?\d+)\.+(-?\d+)").unwrap();
let mut cubiods: Vec<Cuboid> = Vec::new();
for l in include_str!("input.txt").split("\n") {
let t: Vec<_> = re
.captures(l)
.unwrap()
.iter()
... | 606 |
pub fn test_op_rvc_slli_crash_32() {
let buffer = fs::read("tests/programs/op_rvc_slli_crash_32")
.unwrap()
.into();
let result = run::<u32, SparseMemory<u32>>(&buffer, &vec!["op_rvc_slli_crash_32".into()]);
assert!(result.is_ok());
} | 607 |
fn make_field(doc: &Option<String>, ident: &syn::Ident, ty: syn::Type) -> syn::Field {
let mut attrs = Vec::new();
if let Some(doc) = doc {
let doc = syn::LitStr::new(&markdown::sanitize(&doc), Span::call_site());
use syn::parse::Parser;
attrs = syn::Attribute::parse_outer
.p... | 608 |
fn main() {
println!("Common letters in the box ids: {}",
match find_common_id() {
Some(s) => s,
None => "NA".to_string()
});
} | 609 |
pub
fn
fetch_update
<
F
>
(
&
self
mut
f
:
F
)
-
>
Result
<
T
T
>
where
F
:
FnMut
(
T
)
-
>
Option
<
T
>
{
let
mut
prev
=
self
.
load
(
)
;
while
let
Some
(
next
)
=
f
(
prev
)
{
match
self
.
compare_exchange
(
prev
next
)
{
x
Ok
(
_
)
=
>
return
x
Err
(
next_prev
)
=
>
prev
=
next_prev
}
}
Err
(
prev
)
} | 610 |
fn item_query() {
let dir = TestDir::new("sit", "query");
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(... | 611 |
pub fn task_set_instruction_pointer(target: CAddr, ptr: u64) {
system_call(SystemCall::TaskSetInstructionPointer {
request: (target, ptr),
});
} | 612 |
pub unsafe fn mmap_trimmed_anonymous(size: usize) -> io::Result<Ptr> {
let aligned_size = alignment_size(size);
let desired = size;
let ptr = mmap_without_fd(size)?;
let addr = ptr as usize;
let padding_start= addr + (BLOCK_SIZE - PAGE_SIZE);
let aligned_addr = padding_start & BLOCK_MASK;
le... | 613 |
pub fn causet_partitioner_result_free(result: Box<CausetPartitionerResult>) {
} | 614 |
pub
const
fn
new
(
val
:
T
)
-
>
AtomicCell
<
T
>
{
AtomicCell
{
value
:
UnsafeCell
:
:
new
(
MaybeUninit
:
:
new
(
val
)
)
}
}
pub
fn
into_inner
(
self
)
-
>
T
{
let
this
=
ManuallyDrop
:
:
new
(
self
)
;
unsafe
{
this
.
as_ptr
(
)
.
read
(
)
}
}
pub
const
fn
is_lock_free
(
)
-
>
bool
{
atomic_is_lock_free
:
:
<
T
>
(... | 615 |
async fn retrieve_pairs() {
let exchange = init().await;
let pairs = exchange.refresh_market_info().await.unwrap();
println!("{:?}", pairs);
} | 616 |
fn main() {
// ใใฟใผใณ
// ใใฟใผใณใซใฏไธใค่ฝใจใ็ฉดใใใใพใใ
// ๆฐใใๆ็ธใๅฐๅ
ฅใใไปใฎๆงๆใจๅๆงใใใฟใผใณใฏใทใฃใใผใคใณใฐใใใพใใไพใใฐ๏ผ
let x = 'x';
let c = 'c';
match c {
x => println!("x: {} c: {}", x, c), // ๅ
ใฎxใใทใฃใใผใคใณใฐใใใฆใๅฅใฎxใจใใฆๅไฝใใฆใใใ
}
println!("x: {}", x);
// x => ใฏๅคใใใฟใผใณใซใใใใใใใใใใฎ่
ๅ
ใงๆๅนใช x ใจใใๅๅใฎๆ็ธใๅฐๅ
ฅใใพใใ
// ๆขใซ x ใจใใๆ็ธใๅญๅจใใฆใใใฎใงใๆฐ... | 617 |
pub extern "x86-interrupt" fn FPU_error() { CommonExceptionHandler(16); } | 618 |
pub fn data_type<'a>() -> Parser<'a, char, DataType> {
ident().convert(|v| DataType::match_data_type(&v))
} | 619 |
fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lines: bool) -> Vec<Vec<String>> {
let mut res = Vec::new();
let prefix = "// ";
let lines = text.lines().map(str::trim_start);
let mut block = vec![];
for line in lines {
if line == "//" && allow_blocks_with_empty_lines {
... | 620 |
fn inc_9() {
run_test(&Instruction { mnemonic: Mnemonic::INC, operand1: Some(Direct(CL)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[254, 193], OperandSize::Qword)
} | 621 |
fn main() -> ! {
let (mut leds, rcc, tim6) = aux9_tasks::init();
// Power on the TIM6 timer
rcc.apb1enr.modify(|_, w| w.tim6en().set_bit());
// SR, the status register.
// EGR, the event generation register.
// CNT, the counter register.
// PSC, the prescaler register.
// ARR, the auto... | 622 |
pub fn read_lines(filename: Box<&Path>) -> io::Result<io::Lines<io::BufReader<File>>> {
let file = File::open(*filename)?;
Ok(io::BufReader::new(file).lines())
} | 623 |
pub fn assign(lhs_node: Node, token: Token, rhs_node: Node) -> Node {
match lhs_node {
Node::LVasgn(var_str, mut nodes) => {
nodes.push(rhs_node);
return Node::LVasgn(var_str, nodes);
},
_ => { panic!("node::assign UNIMPL"); }
}
} | 624 |
async fn order_book() {
let exchange = init().await;
let req = OrderBookRequest {
market_pair: "eth_btc".to_string(),
};
let resp = exchange.order_book(&req).await.unwrap();
println!("{:?}", resp);
} | 625 |
fn loadResFromMesh(model: &mut Model, meshFilePath: &str) {} | 626 |
fn a_table_should_reject_a_stale_write() {
let mut table = HashMapOfTreeMap::new();
table.write(0, &[Row { k: 0, v: 1 }]);
assert_eq!(table.write(0, &[Row { k: 0, v: 2 }]), WriteResult::Stale { cond: 0, max: 1 });
let mut vs = [Value::default(); 1];
table.read (1, &[0], &mut vs);
assert_eq!(vs, [Value { v: ... | 627 |
async fn run_manpage(_args: Args) -> Result<()> {
info!(version=%env!("CARGO_PKG_VERSION"), "constructing manpage");
let man = Man::new(Args::command().long_version(None));
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer).into_diagnostic()?;
if std::io::stdout().is_terminal() && which::which... | 628 |
pub fn get_home() -> Result<String, ()> {
match dirs::home_dir() {
None => Ok(String::new()),
Some(path) => Ok(path.to_str().unwrap().to_string()),
}
} | 629 |
pub fn exe_phdrs() -> (*const c_void, usize) {
imp::process::exe_phdrs()
} | 630 |
pub fn format_pbs_duration(duration: &Duration) -> String {
format_duration(duration)
} | 631 |
fn create_tap() -> AppResult<TapInfo> {
// create tap
inner_create_tap("tap0")
} | 632 |
fn parse_bag_name(input: &str) -> IResult<&str, &str> {
let input = skip_whitespace(input);
let (input, name) = recognize(tuple((alpha1, space1, alpha1)))(input)?;
let input = skip_whitespace(input);
let (input, _) = tag("bag")(input)?;
let (input, _) = opt(char('s'))(input)?;
let input = skip_w... | 633 |
fn run_with_crash() {
let project = project("run_with_crash")
.with_fuzz()
.fuzz_target(
"yes_crash",
r#"
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
run_with_crash::fail_fuzzing... | 634 |
pub fn reply(message: &str) -> &str {
match message.trim() {
x if x.is_empty() => "Fine. Be that way!",
x if x.ends_with("?") => match x {
x if is_uppercase(x) => "Calm down, I know what I'm doing!",
_ => "Sure.",
},
x if is_uppercase(x) => "Whoa, chill out!",... | 635 |
pub fn causet_partitioner_scan_column_as_float(
context: Box<CausetPartitionerContext>,
column_name: &[u8],
column_value: &[u8],
) -> Box<CausetPartitionerContext> {
context
} | 636 |
pub fn causet_partitioner_scan_column(
context: Box<CausetPartitionerContext>,
column_name: &[u8],
column_value: &[u8],
) -> Box<CausetPartitionerContext> {
context
} | 637 |
fn add(value: i32) -> i32 {
value + 1
} | 638 |
async fn main() -> std::io::Result<()> {
// ----------------------------------------------------------------------------- tracing & logging
// configure tracing subscriber
configure_tracing();
// log http events from actix
LogTracer::init().expect("failed to enable http request logging");
// -... | 639 |
async fn run_watchexec(args: Args) -> Result<()> {
info!(version=%env!("CARGO_PKG_VERSION"), "constructing Watchexec from CLI");
let init = config::init(&args);
let state = state::State::new()?;
let mut runtime = config::runtime(&args, &state)?;
runtime.filterer(filterer::globset(&args).await?);
info!("initial... | 640 |
fn inc_6() {
run_test(&Instruction { mnemonic: Mnemonic::INC, operand1: Some(IndirectDisplaced(BX, 5189, Some(OperandSize::Byte), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[254, 135, 69, 20], OperandSize::W... | 641 |
fn get_build_type() -> String {
match env::var("PROFILE").unwrap().as_str() {
"release" => String::from("Release"),
_ => String::from("Debug"),
}
} | 642 |
pub fn fuzzy_match(choice: &str, pattern: &str) -> Option<i64> {
if pattern.is_empty() {
return Some(0);
}
let scores = build_graph(choice, pattern)?;
let last_row = &scores[scores.len() - 1];
let (_, &MatchingStatus { final_score, .. }) = last_row
.iter()
.enumerate()
... | 643 |
fn abstract_node(alpha: &RcNode, t: &RcTerm, subst: Subst) {
let bindings = subst
.iter()
.map(|(n, t)| (n.clone(), Rc::clone(t)))
.collect();
let let_term = Term::mk_let(Rc::clone(t), bindings);
replace_subtree(alpha, &let_term);
} | 644 |
fn load_data() -> Vec<Vec<u8>> {
let f = File::open(DATA_PATH).unwrap();
let f = BufReader::new(f);
let l: Vec<String> = f.lines().collect::<Result<Vec<_>, _>>().unwrap();
let l: Vec<Vec<u8>> = l.into_iter().map(|x| x.from_base64().unwrap()).collect();
l
} | 645 |
pub fn with_projects<F>(dir:StorageDir, search_terms:&[&str], f:F) -> Result<()>
where F:Fn(&Project)->Result<()>
{
trace!("with_projects({:?})", search_terms);
let luigi = try!(setup_luigi());
let projects = try!(luigi.search_projects_any(dir, search_terms));
if projects.is_empty() {
return... | 646 |
fn run_predicate_script(
header: fuzzers::HeaderC,
) -> Result<Output, Box<dyn Error>> {
let dir = Builder::new().prefix("bindgen_prop").tempdir()?;
let header_path = dir.path().join("prop_test.h");
let mut header_file = File::create(&header_path)?;
header_file.write_all(header.to_string().as_bytes... | 647 |
fn test_let_2() {
let module = make_module(
indoc! {r#"
a = let a = 10 in let a = a * 1.0 in let a = a // 2 in a
b = let a = 10 in let a = a * 1.0 in let a = a / 2 in a
"#},
default_sym_table(),
);
assert!(module.is_ok());
let module = module.unwrap();... | 648 |
pub fn init(
title: &str,
set_min_window_size: bool,
) -> Result<(EventsLoop, GlWindow, Rc<gl::Gl>), Error> {
let events_loop = EventsLoop::new();
let window = WindowBuilder::new().with_title(title);
// 3.3 just because that's what <https://learnopengl.com> uses
let context = ContextBuilder::new()
.with... | 649 |
fn is_rollup_commit(commit: &Commit) -> bool {
let summary = commit.summary().unwrap_or("");
summary.starts_with("Rollup merge of #")
} | 650 |
pub fn channel_take<T: Any + Clone>(target: CAddr) -> T {
let (result, payload) = system_call_take_payload(SystemCall::ChannelTake {
request: target,
response: None
});
match result {
SystemCall::ChannelTake {
request: _,
response: Some(ChannelMessage::Payload... | 651 |
fn count(nums: &[i64], from: usize, memo: &mut HashMap<usize, i64>) -> i64 {
if let Some(n) = memo.get(&from) {
return *n;
} else if from >= nums.len() {
return 0;
}
let cur = nums[from];
let (a, b, c) = (from + 1, from + 2, from + 3);
let mut sum = count(nums, a, memo); // 1 X ... | 652 |
fn move_node_data_to_coords(nodes: &HashMap<String, Node>, node: &Node, target: &String, used_list_data: Vec<String>) -> (usize, String, HashMap<String, Node>) {
let mut scan_list: Vec<(String, HashMap<String, Node>)> = vec![(node.coords.clone(), nodes.clone())];
let mut used_list: HashSet<String> = HashSet::ne... | 653 |
pub fn flip_ref_opt_to_opt_ref<T> (r: Ref<Option<T>>) -> Option<Ref<T>> {
match r.deref() {
Some(_) => Some(Ref::map(r, |o| o.as_ref().unwrap())),
None => None
}
} | 654 |
fn bindgen_prop(header: fuzzers::HeaderC) -> TestResult {
match run_predicate_script(header) {
Ok(o) => TestResult::from_bool(o.status.success()),
Err(e) => {
println!("{:?}", e);
TestResult::from_bool(false)
}
}
} | 655 |
pub fn fixed_vector(receiver: Receiver<u128>) -> Result<()> {
// This is used to store all numbers that haven't been solved yet.
// -> For instance, if the task for 10 completes, but 7, 8 and 9 haven't yet, these will be
// added to the backlog.
// In theory, there should never be more than `threa... | 656 |
pub fn nth(n: u32) -> u32 {
let mut primes: Vec<u32> = vec![2, 3, 5];
let i = n as usize;
let mut nn = 5;
while i + 1 >= primes.len() {
nn += 2;
if !primes.iter().any(|x| nn % x == 0) {
primes.push(nn);
}
}
primes[i]
} | 657 |
pub fn list_dir() {
if let Ok(entries) = fs::read_dir(".") {
for entry in entries {
println!("entry:{:?}", entry);
if let Ok(entry) = entry {
println!("path:{:?}", entry.path());
println!("file_name:{:?}", entry.file_name());
println!("... | 658 |
fn die(err: impl Error) -> ! {
println!("{}", err);
std::process::exit(1);
} | 659 |
pub unsafe fn set_thread_area(u_info: &mut UserDesc) -> io::Result<()> {
imp::syscalls::tls::set_thread_area(u_info)
} | 660 |
pub fn ref_and_then_mut<'r, T, U: 'static, F: FnOnce (&mut T) -> Option<&mut U>> (mut r: RefMut<'r, T>, f: F) -> Option<RefMut<'r, U>> {
match f(r.deref_mut()) {
Some(u) => {
// SAFETY: we're discarding the compile-time managed borrow in the reference,
// in favor of the runtime-managed borrow in the Ref
le... | 661 |
fn main() {
let mut args = env::args();
if args.len() >= 2 {
args.next();
let path = args.next().unwrap();
let mut debug_mode = false;
if let Some(s) = args.next() {
debug_mode = s == "-d";
if s == "-a" {
assemble(path).unwrap();
... | 662 |
pub fn test_trace() {
let buffer = fs::read("tests/programs/trace64").unwrap().into();
let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["trace64".into()]);
assert!(result.is_err());
assert_eq!(result.err(), Some(Error::MemWriteOnExecutablePage));
} | 663 |
fn fist_2() {
run_test(&Instruction { mnemonic: Mnemonic::FIST, operand1: Some(Indirect(EAX, Some(OperandSize::Dword), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[219, 16], OperandSize::Dword)
} | 664 |
pub fn mean(set: &[f32]) -> f32 {
set.iter().sum::<f32>() / (set.len() as f32)
} | 665 |
fn save_history(cmd: String) {
let timestamp = chrono::Local::now().format("%s").to_string();
match cmd.as_str() {
"" => (),
_ => {
let mut file = OpenOptions::new()
.create(true).append(true)
.open(get_histfile_path()).unwrap();
file.write((timestamp + ";" + cmd.as_str() + "\n"... | 666 |
fn parseModelInfo(reader: &mut BufReader<&File>, buf: &mut String, models: &mut Vec<Model>, basePath: &str) -> Model {
//Firstly, read the meshId and materialId;
reader.read_line(buf);
let mut split_info = buf.split(" ");
if len(split_info) != 2 {}
let meshId: i32 = split_info.next().unwrap().p... | 667 |
pub async fn new_quic_link(
sender: LinkSender,
receiver: LinkReceiver,
endpoint: Endpoint,
) -> Result<(QuicSender, QuicReceiver, ConnectionId), Error> {
let scid = ConnectionId::new();
let mut config = sender.router().new_quiche_config().await?;
config.set_application_protos(b"\x10overnet.link... | 668 |
pub fn acrn_read_dir(path: &str, recursive: bool) -> Result<Vec<DirEntry>, String> {
read_dir(path, recursive).map_err(|e| e.to_string())
} | 669 |
pub fn check_hex_range(addr: u16) -> bool {
return if addr < 0x0000 || addr > 0xFFFF {
false
} else {
true
};
} | 670 |
pub fn var(v: Var) -> Value {
Rc::new(RefCell::new(V {
val: Value_::Var(v),
computed: false,
}))
} | 671 |
pub fn unarchive_projects(year:i32, search_terms:&[&str]) -> Result<Vec<PathBuf>> {
let luigi = try!(setup_luigi_with_git());
Ok(try!( luigi.unarchive_projects(year, search_terms) ))
} | 672 |
pub fn calculate() {
println!("calculate grade");
} | 673 |
pub fn test_memory_load_bytes() {
let mut rng = thread_rng();
assert_memory_load_bytes_all(&mut rng, RISCV_MAX_MEMORY, 1024 * 5, 0);
assert_memory_load_bytes_all(&mut rng, RISCV_MAX_MEMORY, 1024 * 5, 2);
assert_memory_load_bytes_all(&mut rng, RISCV_MAX_MEMORY, 1024 * 5, 1024 * 6);
assert_memory_loa... | 674 |
fn array_test() {
let lazy_caterer: [u32; 6] = [1, 2, 4, 7, 11, 16];
let taxonomy = ["Animalia", "arthropoda", "Insecta"];
assert_eq!(lazy_caterer[3], 7);
assert_eq!(taxonomy.len(), 3);
let mut sieve = [true; 10000];
for i in 2..100 {
if sieve[i] {
let mut j = i * i;
... | 675 |
pub extern "x86-interrupt" fn mouse() { CommonInterruptHandler(44); } | 676 |
fn build_package(
current_dir: &Path,
installed_dir: &Path,
configure_opts: &[String],
) -> Result<(), FrumError> {
debug!("./configure {}", configure_opts.join(" "));
let mut command = Command::new("sh");
command
.arg("configure")
.arg(format!("--prefix={}", installed_dir.to_str... | 677 |
fn test_region_area() {
let ll = (0.0, 0.0).into_pt();
let ur = (2.0, 2.0).into_pt();
let r = Region::from_points(&ll, &ur);
assert_eq!(r.get_area(), 4.0);
} | 678 |
fn get_largest_register_value(registers: &HashMap<&str, i32>) -> i32 {
*registers
.iter()
.map(|(_, v)| v)
.max()
.unwrap_or(&0)
} | 679 |
pub
fn
fetch_and
(
&
self
val
:
bool
)
-
>
bool
{
let
a
=
unsafe
{
&
*
(
self
.
as_ptr
(
)
as
*
const
AtomicBool
)
}
;
a
.
fetch_and
(
val
Ordering
:
:
AcqRel
)
} | 680 |
fn desearlizer_task(req: &mut reqwest::Response) -> Result<Task, Error> {
let mut buffer = String::new();
match req.read_to_string(&mut buffer) {
Ok(_) => (),
Err(e) => println!("error : {}", e.to_string())
};
println!("buffer before serializaztion: {}", buffer);
let v = match serde... | 681 |
pub fn causet_partitioner_context_new() -> Box<CausetPartitionerContext> {
Box::new(CausetPartitionerContext {
prev_user_soliton_id: Vec::new(),
current_user_soliton_id: Vec::new(),
current_output_file_size: 0,
})
} | 682 |
pub fn solve2(input: &str) -> Option<Box<usize>> {
let sum_of_counts = input
.trim_end()
.split("\n\n")
.map(|group| {
let answers_per_person = group
.split_ascii_whitespace()
.map(|person| person.chars().collect::<HashSet<_>>())
.collect::<Vec<_>>();
answers_per_perso... | 683 |
pub fn challenge_8() {
let mut file = File::open("data/8.txt").unwrap();
let mut all_file = String::new();
file.read_to_string(&mut all_file).unwrap();
let mut best_guess = ("", 0);
for line in all_file.lines() {
let data = hex::decode(line).unwrap();
let nb_rep = crypto::number_rep... | 684 |
pub fn setup_luigi() -> Result<Storage<Project>> {
trace!("setup_luigi()");
let working = try!(::CONFIG.get_str("dirs/working").ok_or("Faulty config: dirs/working does not contain a value"));
let archive = try!(::CONFIG.get_str("dirs/archive").ok_or("Faulty config: dirs/archive does not contain a value"... | 685 |
pub fn test_jump0() {
let buffer = fs::read("tests/programs/jump0_64").unwrap().into();
let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["jump0_64".into()]);
assert!(result.is_err());
assert_eq!(result.err(), Some(Error::MemWriteOnExecutablePage));
} | 686 |
fn test_env_var() {
// Sets a new environment variable to check the correct value retrieval from Gura
let env_var_name = "env_var_value";
let env_value = "using_env_var";
env::set_var(env_var_name, env_value);
let parsed_data = parse(&format!("test: ${}", env_var_name)).unwrap();
assert_eq!(pars... | 687 |
pub fn startup_tls_info() -> StartupTlsInfo {
imp::thread::tls::startup_tls_info()
} | 688 |
pub fn star1(lines: &Vec<String>) -> String {
let days = initialize(lines);
let mut guard_map = HashMap::new();
for day in days {
guard_map.entry(day.guard_id)
.or_insert(vec![])
.push(day);
}
let (&sleepiest_guard_id, sleepiest_guard_days) = guard_map.iter()
... | 689 |
pub fn sne_op(inputs: OpInputs) -> EmulatorResult<()> {
// SNE compares the A-value to the B-value. If the result of the
// comparison is not equal, the instruction after the next instruction
// (PC + 2) is queued (skipping the next instruction). Otherwise, the
// next instruction is queued (PC + 1).
... | 690 |
pub fn hex_to_uint256(hex: &str) -> Option<Uint256> {
if hex.len() != 64 { return None; }
let mut out = [0u64; 4];
let mut b: u64 = 0;
for (idx, c) in hex.as_bytes().iter().enumerate() {
b <<= 4;
match *c {
b'A'..=b'F' => b |= (c - b'A' + 10) as u64,
b'a'..=b'f' => b |= (c - b'a' + 10) as u64,
b'0'..=... | 691 |
pub extern "x86-interrupt" fn machine_check() { CommonExceptionHandler(18); } | 692 |
pub fn ldp_op(inputs: OpInputs) -> EmulatorResult<()> {
// Reads a value from the PSPACE, writing it into core memory
//
// LDP and STP are not defined in any ICWS standard. This implementation
// is based on pMARS's behavior.
//
// The source index uses one of the fields from the A instruction... | 693 |
fn map_params(tok: IRCToken) -> Result<IRCToken, ~str> {
// Sequence(~[Sequence(~[Sequence(~[Ignored, Unparsed(~"##codelab")])]), Sequence(~[Sequence(~[Ignored, Unparsed(~":"), Unparsed(~"hi")])])])
match tok {
Sequence(args) => Ok(Params(args.map(|arg| {
match arg.clone() {
... | 694 |
pub fn write_uint8(buf: &mut Vec<u8>, u: u8) -> usize {
buf.push(u);
1
} | 695 |
pub fn main() {
Opt::from_args();
let options = SkimOptionsBuilder::default()
.multi(true)
.bind(vec!["ctrl-k:kill-line"])
.build()
.unwrap();
let re = Regex::new(URL_REGEX).unwrap();
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer).unwrap();
... | 696 |
fn err_list() -> Receiver<i32, u32> {
let (tx, rx) = channel();
tx.send(Ok(1))
.and_then(|tx| tx.send(Ok(2)))
.and_then(|tx| tx.send(Err(3)))
.forget();
return rx
} | 697 |
pub fn task_set_active(target: CAddr) {
system_call(SystemCall::TaskSetActive {
request: target
});
} | 698 |
fn parse_statement(input: &str) -> IResult<&str, (&str, Vec<(usize, &str)>)> {
let (input, bag_name) = parse_bag_name(input)?;
let input = skip_whitespace(input);
let (input, _) = tag("contain")(input)?;
let input = skip_whitespace(input);
let (input, list) = alt((parse_bag_list, map(tag("no other b... | 699 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.