content
stringlengths
12
392k
id
int64
0
1.08k
fn santa(instruction: &String) -> i32 { // if '(' up else if ')' down let mut floor: i32 = 0; for paren in instruction.chars() { println!("{}", paren); match paren { '(' => floor += 1, ')' => floor -= 1, _ => panic!(), } } floor }
500
pub unsafe extern "C" fn amcostestimate( _root: *mut pg_sys::PlannerInfo, path: *mut pg_sys::IndexPath, _loop_count: f64, index_startup_cost: *mut pg_sys::Cost, index_total_cost: *mut pg_sys::Cost, index_selectivity: *mut pg_sys::Selectivity, index_correlation: *mut f64, index_pages: *mu...
501
fn does_line_intersect(x0: i64, x1: i64, ox0: i64, ox1: i64) -> bool { (x0 <= ox0 && ox0 <= x1) || (x0 <= ox1 && ox1 <= x1) || (ox0 <= x0 && x0 <= ox1) || (ox0 <= x1 && x1 <= ox1) }
502
extern "C" fn debug_info_thread_fn() { loop { let debug_info = DEBUG_INFO_RECEIVER.recv(); if let Ok(debug_info) = debug_info { debug_info.print(); } } }
503
fn inc_5() { 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::Word) }
504
fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) { match msg { Msg::Clicked => { model.test = model.test+1; }, Msg::FetchData=> { orders .skip() .perform_cmd(fetch_data()); }, Msg::DataFetched(data) ...
505
fn assert_memory_store_empty_bytes<M: Memory>(memory: &mut M) { assert!(memory.store_byte(0, 0, 42).is_ok()); assert!(memory.store_bytes(0, &[]).is_ok()); }
506
pub fn challenge_2() { let input1 = hex::decode("1c0111001f010100061a024b53535009181c").unwrap(); let input2 = hex::decode("686974207468652062756c6c277320657965").unwrap(); let output = crypto::xor_repeating(&input1, &input2); println!("{}", hex::encode(output)); }
507
fn specific_url_encoded() { eprintln!("check that all chars are URL safe"); let mut test_string = String::new(); for _ in 0..1000 { write!(&mut test_string, "{} ", rand::thread_rng().gen::<f64>()) .expect("write rand float to string") } let compressed = lz_str::compress_to_encode...
508
fn test_line_intersections() { let p1 = Point::new(vec![1.0, 0.0]); let p2 = Point::new(vec![3.0, 2.0]); let p3 = Point::new(vec![2.0, 0.0]); let p3a = Point::new(vec![2.0, 3.0]); let p4 = Point::new(vec![2.0, 4.0]); let p5 = Point::new(vec![1.0, 1.0]); let p6 = Point::new(vec![2.5, 3.0]); ...
509
pub fn stdio() -> AsyncIO<impl AsyncRead, impl AsyncWrite> { let fin = tokio_file_unix::File::new_nb(tokio_file_unix::raw_stdin().unwrap()) .unwrap() .into_reader(&tokio::reactor::Handle::default()) .unwrap(); let fout = tokio::io::stdout(); AsyncIO { fin, fout } }
510
fn to_matrix(side: &str) -> Matrix<bool> { Matrix::square_from_vec( side.bytes() .filter(|b| *b != b'/') .map(|b| b == b'#') .collect()) }
511
fn print_fixed_acc(inss: &[Instruction], op: Operation, pc: usize) -> bool { let mut fixed_inss = inss.to_vec(); fixed_inss[pc].op = op; match Evaluator::new(&mut fixed_inss).eval_until_loop() { (final_pc, final_acc, _) if final_pc == fixed_inss.len() => { println!("{}", final_acc); ...
512
fn main() -> Result<()> { let inss = parse_instructions()?; for (pc, ins) in inss.iter().enumerate() { match ins.op { Operation::Nothing => { // Don't invert zero `nop`s as `jmp +0` results in a loop. if ins.arg != 0 && print_fixed_acc(&inss, Operation::Jump,...
513
fn exit_qemu(exit_code: u32) { use x86_64::instructions::port::Port; unsafe { let mut port = Port::new(0xf4); port.write(exit_code); } }
514
pub fn get( module: &Atom, index: &Index, old_unique: &OldUnique, unique: &Unique, arity: &Arity, ) -> Option<Code> { RW_LOCK_CODE_BY_ARITY_BY_UNIQUE_BY_OLD_UNIQUE_BY_INDEX_BY_MODULE .read() .get(module) .and_then(|code_by_arity_by_unique_by_old_unique_by_index| { ...
515
fn set_screen(n: u8, disp: &mut Screen) { let color_name = match n { 1 => { "red" }, 2 => { "yellow" } 3 => { "white" } 4 => { "aqua" } 5 => { "purple" } 6 => { ...
516
fn boot() { vector::trace::init(false, false, "warn", false); vector::metrics::init().expect("metrics initialization failed"); }
517
pub fn establish_connection() -> PooledConnection<ConnectionManager<PgConnection>> { pool().get().unwrap() }
518
fn collect_tokens(source: &Source, span: Span, report: &Report) -> Vec<NestedToken> { let mut iter = source.iter_from_span(span).unwrap(); let tokens = { let mut lexer = Lexer::new(&mut iter, report); let nest = Nest::new(&mut lexer); nest.collect::<Vec<_>>() }; assert!(!tokens.i...
519
pub fn set_panic_hook() { // When the `console_error_panic_hook` feature is enabled, we can call the // `set_panic_hook` function at least once during initialization, and then // we will get better error messages if our code ever panics. // // For more details see // https://github.com/rustwasm/...
520
fn part_1() { let re = Regex::new(r".*=(-?\d+)\.+(-?\d+).*=(-?\d+)\.+(-?\d+).*=(-?\d+)\.+(-?\d+)").unwrap(); let mut pts: HashSet<(i32, i32, i32)> = HashSet::new(); for l in include_str!("input.txt").split("\n") { let t: Vec<_> = re .captures(l) .unwrap() .iter()...
521
fn main() { let text = match read_input::read_text("input.txt") { Ok(t) => t, Err(e) => panic!("{:?}", e), }; let re = Regex::new(r"\s+").unwrap(); let mut nodes: HashMap<String, Node> = HashMap::new(); for line in text.lines() { if line.starts_with("/") { let ...
522
fn build_graph(choice: &str, pattern: &str) -> Option<Vec<Vec<MatchingStatus>>> { let mut scores = vec![]; let mut match_start_idx = 0; // to ensure that the pushed char are able to match the pattern let mut pat_prev_ch = '\0'; // initialize the match positions and inline scores for (pat_idx, pat_...
523
fn trait_test() { { use std::io::Write; fn say_hello(out: &mut Write) -> std::io::Result<()> { out.write_all(b"hello world\n")?; out.flush() } // use std::fs::File; // let mut local_file = File::create("hello.txt"); // say_hello(&mut local_f...
524
async fn main() -> Result<!, String> { // Begin by parsing the arguments. We are either a server or a client, and // we need an address and potentially a sleep duration. let args: Vec<_> = env::args().collect(); match &*args { [_, mode, url] if mode == "server" => server(url).await?...
525
fn fizz_buzz(number: i32) -> Vec<String> { //NOTE: we start at 1 to avoid handling another case with 0 let numbers = 1..=number; numbers .map(|n| match n { n if (n % 3 == 0 && n % 5 == 0) => String::from("FizzBuzz"), n if n % 3 == 0 => String::from("Fizz"), n if n % 5 == 0 => String::from("...
526
fn calc_chunk_size<E>(mem: u64, core_count: usize) -> usize where E: Engine, { let aff_size = std::mem::size_of::<E::G1Affine>() + std::mem::size_of::<E::G2Affine>(); let exp_size = exp_size::<E>(); let proj_size = std::mem::size_of::<E::G1>() + std::mem::size_of::<E::G2>(); ((((mem as f64) * (1f64 ...
527
fn is_not_skipped(rule: &Option<SerdeValue>) -> bool { rule.as_ref().map(|value| !value.skip).unwrap_or(true) }
528
pub fn fuzzy_indices(choice: &str, pattern: &str) -> Option<(i64, Vec<usize>)> { if pattern.is_empty() { return Some((0, Vec::new())); } let mut picked = vec![]; let scores = build_graph(choice, pattern)?; let last_row = &scores[scores.len() - 1]; let (mut next_col, &MatchingStatus { f...
529
fn main() { std::panic::set_hook(Box::new(console_error_panic_hook::hook)); console_log::init_with_level(log::Level::Warn).expect("could not initialize logger"); let fighter_bytes = include_bytes!("subaction_data.bin"); let subaction = bincode::deserialize(fighter_bytes).unwrap(); wasm_bindgen_futu...
530
fn kxord_1() { run_test(&Instruction { mnemonic: Mnemonic::KXORD, operand1: Some(Direct(K5)), operand2: Some(Direct(K4)), operand3: Some(Direct(K5)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 225, 221, 71, 237], OperandSize::Dword) }
531
pub extern "x86-interrupt" fn coprocessor() { CommonInterruptHandler(45); }
532
fn view(model: &Model) -> impl View<Msg> { // let scatter_plot = model.plot_state.view().map_message(|orig_msg|{ // Msg::PlotMsg(orig_msg) // }); div![ class!["w-screen", "flex", "flex-col"], // root container div![class!["flex", "w-full"], // header container ...
533
fn string_test() { // literal let speech = "\"Ouch!\" said the well.\n"; println!("{}", speech); println!( "In the room the women come and go, Singing of Mount Abora" ); println!( "It was a bright, cold day in Aplil, and \ there were four of us \ more o...
534
fn modules_file(repo: &Repository, at: &Commit) -> Result<String, Box<dyn std::error::Error>> { if let Some(modules) = at.tree()?.get_name(".gitmodules") { Ok(String::from_utf8( modules.to_object(&repo)?.peel_to_blob()?.content().into(), )?) } else { return Ok(String::new());...
535
pub fn run(config: Config) -> Result<(), Box<dyn Error>> { let file_content = read_to_string(config.file_path)?; let search_result = search(&config.target, &file_content); for line in search_result { println!("{}", line); } Ok(()) }
536
fn next(args: Args) -> Result<Value, Value> { let o = args.this(); if o.type_of() != ValueType::Object { return Err(Value::new_error(args.agent(), "invalid receiver")); } let a = o.get_slot("iterated object"); if a == Value::Null { return Value::new_iter_result(args.agent(), Value::N...
537
pub extern "x86-interrupt" fn page_fault() { CommonExceptionHandler(14); }
538
fn run_one_input() { let corpus = Path::new("fuzz").join("corpus").join("run_one"); let project = project("run_one_input") .with_fuzz() .fuzz_target( "run_one", r#" #![no_main] use libfuzzer_sys::fuzz_target; fuzz_target!(...
539
fn set_privilege(handle: HANDLE, name: &str) -> Result<(), std::io::Error> { let mut luid: LUID = LUID { LowPart: 0, HighPart: 0, }; let name: U16CString = name.try_into().unwrap(); let r = unsafe {LookupPrivilegeValueW(std::ptr::null(),name.as_ptr(), &mut luid )}; if r == 0 { ...
540
pub fn register() { device_manager::register_driver(&s_pci_legacy_driver); device_manager::register_driver(&s_pci_native_driver); }
541
fn test_with_error() { let parsed_data = parse(&"test: $false_var"); assert!(parsed_data .unwrap_err() .downcast_ref::<VariableNotDefinedError>() .is_some()); }
542
fn parse_args() -> Args { let env_args = env::args(); if env_args.len() < 2 { println!("{}", USAGE); std::process::exit(1) } let mut args = Args { port_number: 0, group: Group::Singleton, num_worker_threads: 0, upstream: None, downstream: None, ...
543
pub fn challenge_13() { println!("TODO"); }
544
pub fn retype_task(source: CAddr, target: CAddr) { system_call(SystemCall::RetypeTask { request: (source, target), }); }
545
const fn null_ble_gatt_chr_def() -> ble_gatt_chr_def { return ble_gatt_chr_def { uuid: ptr::null(), access_cb: None, arg: (ptr::null_mut()), descriptors: (ptr::null_mut()), flags: 0, min_key_size: 0, val_handle: (ptr::null_mut()), }; }
546
fn build_one() { let project = project("build_one").with_fuzz().build(); // Create some targets. project .cargo_fuzz() .arg("add") .arg("build_one_a") .assert() .success(); project .cargo_fuzz() .arg("add") .arg("build_one_b") .ass...
547
fn main() { let argv = os::args(); let size = from_str::<uint>(argv[1]).unwrap(); // println!("{}",size); let align = from_str::<uint>(argv[2]).unwrap(); // println!("{}", align); let aligned = align_to(size,align); println!("{} by {} = {}", size, align, aligned); // print_uint(*argv[1]); }
548
fn run() -> Result<(), Box<dyn std::error::Error>> { let by_version = generate_thanks()?; let mut all_time = by_version.values().next().unwrap().clone(); for map in by_version.values().skip(1) { all_time.extend(map.clone()); } site::render(by_version, all_time)?; Ok(()) }
549
fn run_with_coverage() { let target = "with_coverage"; let project = project("run_with_coverage") .with_fuzz() .fuzz_target( target, r#" #![no_main] use libfuzzer_sys::fuzz_target; fuzz_target!(|data: &[u8]| { ...
550
fn update_repo(url: &str) -> Result<PathBuf, Box<dyn std::error::Error>> { let mut slug = url; let prefix = "https://github.com/"; if slug.starts_with(prefix) { slug = &slug[prefix.len()..]; } let prefix = "git://github.com/"; if slug.starts_with(prefix) { slug = &slug[prefix.len...
551
fn fetch_data() -> impl Future<Item = Msg, Error = Msg> { let url = "http://192.168.15.22:8000/shower_data"; Request::new(url).fetch_json(Msg::DataFetched) }
552
fn run_with_different_fuzz_dir() { let (fuzz_dir, mut project_builder) = project_with_fuzz_dir( "project_likes_to_move_it", Some("dir_likes_to_move_it_move_it"), ); let project = project_builder .with_fuzz() .fuzz_target( "you_like_to_move_it", r#" ...
553
fn test_value ( ) - > Result < ( ) > { let db = checked_memory_handle ( ) ? ; db . execute ( " INSERT INTO foo ( i ) VALUES ( ? 1 ) " [ Value : : Integer ( 10 ) ] ) ? ; assert_eq ! ( 10i64 db . one_column : : < i64 > ( " SELECT i FROM foo " ) ? ) ; Ok ( ( ) ) }
554
pub fn jmz_op(inputs: OpInputs) -> EmulatorResult<()> { // JMZ tests the B-value to determine if it is zero. If the B-value is // zero, the sum of the program counter and the A-pointer is queued. // Otherwise, the next instruction is queued (PC + 1). JMZ.I functions // as JMZ.F would, i.e. it jumps if...
555
fn project_with_fuzz_dir( project_name: &str, fuzz_dir_opt: Option<&str>, ) -> (String, ProjectBuilder) { let fuzz_dir = fuzz_dir_opt.unwrap_or("custom_dir"); let next_root = next_root(); let fuzz_dir_pb = next_root.join(fuzz_dir); let fuzz_dir_sting = fuzz_dir_pb.display().to_string(); let ...
556
fn CommonInterruptHandler(vector: u8){ let mut buffer = b"[INT: , ]".clone(); static mut common_count: u8 = 0; buffer[5] = vector / 10 + '0' as u8; buffer[6] = vector % 10 + '0' as u8; unsafe { buffer[8] = common_count + '0' as u8; common_count = (common_count + 1) % 10; } print_string(70, 0, &buffer); S...
557
fn main() { println!("Welcome to my credit card verifier. Please input number to check."); let mut card_number = String::new(); io::stdin() .read_line(&mut card_number) .expect("Failed to read the input"); if card_number.ends_with('\n') { card_number.pop(); if card...
558
fn get_command(stream: &mut TcpStream, buf: &mut[u8]) -> Result<Task, Error> { let buf_sz = stream.read(buf).expect("failed to read from stream"); let buf_usize = buf_sz as usize; let v = match serde_json::from_slice::<Task>(&buf[..buf_usize]){ Ok(v) => v, Err(e) => return Err(e) }; ...
559
fn buffered() { let (tx, rx) = channel::<_, u32>(); let (a, b) = promise::<u32>(); let (c, d) = promise::<u32>(); tx.send(Ok(b.map_err(|_| 2).boxed())) .and_then(|tx| tx.send(Ok(d.map_err(|_| 4).boxed()))) .forget(); let mut rx = rx.buffered(2); sassert_empty(&mut rx); c.comple...
560
pub fn nop_op(inputs: OpInputs) -> EmulatorResult<()> { // Increments and queues the PC but otherwise has no effect past operand // evaluation inputs.pq.push_back( offset(inputs.regs.current.idx, 1, inputs.core_size)?, inputs.warrior_id, )?; Ok(()) }
561
fn main() {}
562
fn figure1b(num_threads: usize) { assert!(num_threads >= 2); let x1 = Arc::new(Mutex::new(Some(1))); let x2 = Arc::clone(&x1); // Optionally, spawn a bunch of threads that add scheduling choice points, each taking 5 steps for _ in 0..num_threads - 2 { thread::spawn(|| { for _ i...
563
fn main() { let instruction: Vec<String> = std::env::args().collect(); let instruction: &String = &instruction[1]; println!("{}", santa(instruction)); }
564
fn find_realpath(cmd_name: &str) -> String { match env::var_os("PATH") { Some(paths) => { for path in env::split_paths(&paths) { let cmd_path = Path::new(&path).join(cmd_name); if cmd_path.exists() { return cmd_path.to_str().unwrap().to_string(...
565
pub fn channel_take_raw(target: CAddr) -> u64 { let result = channel_take_nonpayload(target); match result { ChannelMessage::Raw(v) => return v, _ => panic!(), }; }
566
fn main() { let decimal = 65.4321_f32; // エラー! 暗黙的な型変換はできない。 let integer: u8 = decimal; // 明示的な型変換 let integer = decimal as u8; let character = integer as char; println!("Casting: {} -> {} -> {}", decimal, integer, character); // 何らかの値を符号なしの型(仮にTとする)へキャスティングすると // 値がTに収まるまで、std::...
567
async fn link_to_quic(mut link: LinkSender, quic: Arc<AsyncConnection>) -> Result<(), Error> { while let Some(mut p) = link.next_send().await { p.drop_inner_locks(); quic.dgram_send(p.bytes_mut()).await?; } Ok(()) }
568
pub fn sum_even_after_queries(mut a: Vec<i32>, queries: Vec<Vec<i32>>) -> Vec<i32> { let mut ret: Vec<i32> = Vec::with_capacity(queries.len()); for query in queries.into_iter() { a[query[1] as usize] += query[0]; ret.push(a.iter().filter(|&&n| n % 2 == 0).sum::<i32>()); } ret }
569
fn db_scheme_type_mapper(scheme: &str) -> SchemeType { match scheme { "postgres" => SchemeType::Relative(5432), "mysql" => SchemeType::Relative(3306), _ => SchemeType::NonRelative, } }
570
pub fn sobel(frame : ImageBuffer<Luma<u8>, Vec<u8>>) -> ImageBuffer<Luma<u8>, Vec<u8>> { let mut result = ImageBuffer::new(640, 480); for i in 1..638 { for j in 1..478 { let north_west = frame[(i-1, j-1)].channels()[0] as i32; let north = frame[(i, j-1)].channels()[0] as i3...
571
pub fn fetch_nand ( & self val : bool ) - > bool { let a = unsafe { & * ( self . as_ptr ( ) as * const AtomicBool ) } ; a . fetch_nand ( val Ordering : : AcqRel ) }
572
fn test_let_cons() { let module = make_module( indoc! {r#" tail x = let (x :: xs) = x in xs t = tail [1, 2, 3] "#}, default_sym_table(), ); assert!(module.is_ok()); let module = module.unwrap(); let decls = module.get_decls(); assert_eq!(decls[...
573
pub fn write_array_len<W>(wr: &mut W, len: u32) -> Result<Marker, ValueWriteError> where W: Write { if len < 16 { let marker = Marker::FixArray(len as u8); try!(write_fixval(wr, marker)); Ok(marker) } else if len < 65536 { try!(write_marker(wr, Marker::Array16)); writ...
574
pub fn median_filter_hist(frame : ImageBuffer<Luma<u8>, Vec<u8>>, kernel_size : usize) -> ImageBuffer<Luma<u8>, Vec<u8>> { //assert!(kernel_size % 2 == 1, "Kernel size must be odd."); let mut result = ImageBuffer::new(640, 480); let kernel_offset = ((kernel_size - 1) / 2) as i32; for i in 0..640 { ...
575
pub async fn connect_async_with_tls_connector<R>( request: R, connector: Option<Connector>, ) -> Result<(WebSocketStream<ConnectStream>, Response), Error> where R: IntoClientRequest + Unpin, { connect_async_with_tls_connector_and_config(request, connector, None).await }
576
async fn get_config(db: &FdbTransactional) -> Result<Config, dyn Error> { let config_file = db.get_config_file().await?; let config_file_content = db.get_config_file_content().await?; let config = Config::new(config_file, config_file_content); Ok(config) }
577
fn get_disjoint<T>(ts: &mut [T], a: usize, b: usize) -> (&mut T, &mut T) { assert!(a != b, "a ({}) and b ({}) must be disjoint", a, b); assert!(a < ts.len(), "a ({}) is out of bounds", a); assert!(b < ts.len(), "b ({}) is out of bounds", b); if a < b { let (al, bl) = ts.split_at_mut(b); ...
578
fn decode_ppm_image(cursor: &mut Cursor<Vec<u8>>) -> Result<Image, Box<std::error::Error>> { let mut image = Image { width : 0, height: 0, pixels: vec![] }; // read header let mut c: [u8; 2] = [0; 2]; cursor.read(&mut c)?; match &c { b"P6" => { }, _ ...
579
pub fn debug_cpool_list() { system_call(SystemCall::DebugCPoolList); }
580
fn part1(rules: &Vec<PasswordRule>) -> usize { rules .iter() .filter(|rule| (rule.min..=rule.max).contains(&rule.password.matches(rule.letter).count())) .count() }
581
fn assert_memory_load_bytes<R: Rng, M: Memory>( rng: &mut R, memory: &mut M, buffer_size: usize, addr: u64, ) { let mut buffer_store = Vec::<u8>::new(); buffer_store.resize(buffer_size, 0); rng.fill(buffer_store.as_mut_slice()); memory .store_bytes(addr, &buffer_store.as_slice()...
582
extern "C" fn gatt_svr_chr_access_device_info( _conn_handle: u16, _attr_handle: u16, ctxt: *mut ble_gatt_access_ctxt, _arg: *mut ::core::ffi::c_void, ) -> i32 { let uuid: u16 = unsafe { ble_uuid_u16((*(*ctxt).__bindgen_anon_1.chr).uuid) }; if uuid == GATT_MODEL_NUMBER_UUID { let rc: i32...
583
fn system_call_put_payload<T: Any>(message: SystemCall, payload: T) -> SystemCall { use core::mem::{size_of}; let addr = task_buffer_addr(); unsafe { let buffer = &mut *(addr as *mut TaskBuffer); buffer.call = Some(message); buffer.payload_length = size_of::<T>(); let paylo...
584
pub(crate) fn assignment_expression(i: Input) -> NodeResult { alt(( single::single_assignment_expression, abbreviated::abbreviated_assignment_expression, assignment_with_rescue_modifier, ))(i) }
585
pub fn smart_to_words_vec() -> Vec<Words> { let mut words_vec: Vec<Words> = Vec::new(); for i in 1..22 { let words = smart_to_words(i); words_vec.push(words); } words_vec }
586
pub fn test_invalid_file_offset64() { let buffer = fs::read("tests/programs/invalid_file_offset64") .unwrap() .into(); let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["invalid_file_offset64".into()]); assert_eq!(result.err(), Some(Error::ElfSegmentAddrOrSizeError)); }
587
fn uniqueness_is_preserved_when_generating_data_model_from_a_schema() { let ref_data_model = Datamodel { models: vec![Model { database_name: None, name: "Table1".to_string(), documentation: None, is_embedded: false, is_commented_out: false, ...
588
fn souper_type_of(dfg: &ir::DataFlowGraph, val: ir::Value) -> Option<ast::Type> { let ty = dfg.value_type(val); assert!(ty.is_int()); assert_eq!(ty.lane_count(), 1); let width = match dfg.value_def(val).inst() { Some(inst) if dfg.insts[inst].opcode() == ir::Opcode::IcmpImm ...
589
pub fn get_settings() -> HashMap<String, String>{ let mut settings = Config::default(); settings .merge(glob("config/*") .unwrap() .map(|path| File::from(path.unwrap())) .collect::<Vec<_>>()) .unwrap(); // Print out our settings (as a HashMap) setting...
590
pub fn borrow_expr<'a>( expr: &'a Expr<'a>, var_id: &mut u64, ast: &'a Ast<'a>, borrowstate: &mut State<(Vec<&'a str>, u64)>, ) -> Result<(Vec<&'a str>, u64), BorrowError<'a>> { match &expr.value { Value::Literal(Literal::Ref(_)) => panic!(), Value::UnOp(UnOp::Ref(_), arg) => { ...
591
fn test_solve_1() { assert_eq!(solve_1("dabAcCaCBAcCcaDA"), 10); }
592
pub fn causet_partitioner_scan_column_as_string( context: Box<CausetPartitionerContext>, column_name: &[u8], column_value: &[u8], ) -> Box<CausetPartitionerContext> { context }
593
fn build_author_map_( repo: &Repository, reviewers: &Reviewers, mailmap: &Mailmap, from: &str, to: &str, ) -> Result<AuthorMap, Box<dyn std::error::Error>> { let mut walker = repo.revwalk()?; if repo.revparse_single(to).is_err() { // If a commit is not found, try fetching it. ...
594
fn load ( & self _order : Ordering ) { }
595
fn zig_zag(root: Option<Rc<RefCell<TreeNode>>>, left: bool) -> (i32, i32) { if root.is_none() { return (0, 1) } let mut root = root.unwrap(); let mut rt = root.borrow_mut(); let (lr, lmax) = zig_zag(rt.left.take(), true); let (rl, rmax) = zig_zag(rt.right.take(), false); let (l, r) =...
596
fn get_line_intersection(p0: i64, p1: i64, op0: i64, op1: i64) -> (i64, i64) { let r0 = if op0 < p0 { p0 } else { op0 }; let r1 = if op1 < p1 { op1 } else { p1 }; (r0, r1) }
597
fn main() { println!( "Part 1 Result - {}", solve_1(include_str!("../data/input.txt")) ); println!( "Part 2 Result - {}", solve_2(include_str!("../data/input.txt")) ); }
598
pub fn validate_line_type(data: &str) -> DataType { let line_tokens: Vec<&str> = data.split(" ").collect(); if line_tokens.len() == 2 && line_tokens[0] == "Driver" { DataType::Driver(line_tokens[1].to_string()) } else if line_tokens.len() == 5 && line_tokens[0] == "Trip" { DataType::Trip(li...
599