content
stringlengths
12
392k
id
int64
0
1.08k
pub fn read_file(file_name: &str) -> Result<Vec<u8>> { let mut file = File::open(file_name)?; let mut data: Vec<u8> = Vec::new(); file.read_to_end(&mut data)?; Ok(data) }
900
pub fn list_data(cache: &Cache, key: usize) { for reference in vec![1, 2, 3] { if /*let*/ Some(reference) = cache.data.get(key) { unimplemented!() } } }
901
fn lz_string_raw() { compression_tests( |s| lz_str::compress(s).into(), |s| lz_str::decompress(&s.0).map(ByteString::from), false, ); }
902
fn process_instructions(instructions: &Vec<Instruction>) -> (HashMap<&str, i32>, i32) { let mut registers: HashMap<&str, i32> = HashMap::new(); let mut max = 0; for instruction in instructions { let current = *registers.entry(&instruction.condition.register).or_insert(0); let condition_sat...
903
fn enums_are_preserved_when_generating_data_model_from_a_schema() { let ref_data_model = Datamodel { models: vec![], enums: vec![dml::Enum { name: "Enum".to_string(), database_name: None, documentation: None, commented_out: false, values: v...
904
fn de_timeline(raw: TimelineRaw, even: bool) -> game::Timeline { let mut res = game::Timeline::new( de_l(raw.index, even), raw.width, raw.height, raw.begins_at, raw.emerges_from.map(|x| de_l(x, even)), ); let index = de_l(raw.index, even); let begins_at = raw.beg...
905
pub fn projects_to_csv(projects:&[Project]) -> Result<String>{ let mut string = String::new(); let splitter = ";"; try!(writeln!(&mut string, "{}", [ "Rnum", "Bezeichnung", "Datum", "Rechnungsdatum", "Betreuer", "Verantwortlich", "Bezahlt am", "Betrag", "Canceled"].join(splitter))); for project in proje...
906
extern "C" fn gatt_svr_chr_access_heart_rate( _conn_handle: u16, _attr_handle: u16, ctxt: *mut ble_gatt_access_ctxt, _arg: *mut ::core::ffi::c_void, ) -> i32 { /* Sensor location, set to "Chest" */ const BODY_SENS_LOC: u8 = 0x01; let uuid: u16 = unsafe { ble_uuid_u16((*(*ctxt).__bindgen_ano...
907
fn primary_key_is_preserved_when_generating_data_model_from_a_schema() { let ref_data_model = Datamodel { models: vec![ // Model with auto-incrementing primary key Model { database_name: None, name: "Table1".to_string(), documentation: ...
908
pub fn default_panic_handler(info: &PanicInfo) -> ! { println!("[failed]\n"); println!("Error: {}\n", info); fail(); crate::halt(); }
909
fn main() { // creating instance of Food struct let pizza = Food{ restaurant : "Pizza Hut".to_string(), item : String::from("Chicken Fajita"), size : 9, price : 800, available : true }; // mutable struct let mut karahi = Food{ available : true, ...
910
pub fn parse_mapping(input: &str) -> IResult<&str, BTreeMap<String, BTreeMap<String, usize>>> { let mut mappings = BTreeMap::new(); for line in input.lines().map(str::trim) { if line.is_empty() { continue } let (input, (bag_name, list)) = parse_statement(line)?; if !...
911
pub fn compare_and_swap ( & self current : T new : T ) - > T { match self . compare_exchange ( current new ) { Ok ( v ) = > v Err ( v ) = > v } }
912
async fn process_command( ctx: Arc<Context>, command: InteractionCommand, cmd: InteractionCommandKind, ) -> Result<ProcessResult> { match cmd { InteractionCommandKind::Chat(cmd) => { match pre_process_command(&ctx, &command, cmd).await? { Some(result) => return Ok(res...
913
fn inc_3() { run_test(&Instruction { mnemonic: Mnemonic::INC, operand1: Some(Direct(EBX)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 67], OperandSize::Word) }
914
fn align_address(ptr: *const u8, align: usize) -> usize { let addr = ptr as usize; if addr % align != 0 { align - addr % align } else { 0 } }
915
pub fn assert_unary_arguments<D: Display>(name: D, actual: usize) -> Result<()> { if actual != 1 { return Err(ErrorCode::NumberArgumentsNotMatch(format!( "{} expect to have single arguments, but got {}", name, actual ))); } Ok(()) }
916
pub fn acrn_is_file(path: &str) -> bool { fs::metadata(path) .map(|metadata| metadata.is_file()) .unwrap_or(false) }
917
pub(crate) fn ident<'a, E>(i: &'a str) -> nom::IResult<&'a str, Ident, E> where E: ParseError<&'a str>, { let mut chars = i.chars(); if let Some(f) = chars.next() { if f.is_alphabetic() || f == '_' { let mut idx = 1; for c in chars { if !(c.is_alphanumeric() |...
918
fn env_var<K: AsRef<std::ffi::OsStr>>(key: K) -> String { env::var(&key).expect(&format!("Unable to find env var {:?}", key.as_ref())) }
919
fn test(){ }
920
pub fn write_map_len<W>(wr: &mut W, len: u32) -> Result<Marker, ValueWriteError> where W: Write { if len < 16 { let marker = Marker::FixMap(len as u8); try!(write_fixval(wr, marker)); Ok(marker) } else if len < 65536 { try!(write_marker(wr, Marker::Map16)); write_data...
921
async fn run_completions(shell: ShellCompletion) -> Result<()> { info!(version=%env!("CARGO_PKG_VERSION"), "constructing completions"); fn generate(generator: impl Generator) { let mut cmd = Args::command(); clap_complete::generate(generator, &mut cmd, "watchexec", &mut std::io::stdout()); } match shell { S...
922
fn draw_head<Message, B>( renderer: &mut Renderer<B>, head: &Element<'_, Message, Renderer<B>>, layout: Layout<'_>, cursor_position: Point, viewport: &Rectangle, style: &Style, ) -> (Primitive, mouse::Interaction) where B: Backend + backend::Text, { let mut head_children = layout.childre...
923
fn test_mismatched_types ( ) - > Result < ( ) > { fn is_invalid_column_type ( err : Error ) - > bool { matches ! ( err Error : : InvalidColumnType ( . . ) ) } let db = checked_memory_handle ( ) ? ; db . execute ( " INSERT INTO foo ( b t i f ) VALUES ( X ' 0102 ' ' text ' 1 1 . 5 ) " [ ] ) ? ; let mut stmt = db . prepar...
924
fn run_a_few_inputs() { let corpus = Path::new("fuzz").join("corpus").join("run_few"); let project = project("run_a_few_inputs") .with_fuzz() .fuzz_target( "run_few", r#" #![no_main] use libfuzzer_sys::fuzz_target; fuzz_ta...
925
fn build_unparsed(s: ~str) -> Result<IRCToken, ~str> { Ok(Unparsed(s)) }
926
fn KeyboardHandler(vector: u8){ let mut buffer = b"[INT: , ]".clone(); static mut keyboard_count: u8 = 0; buffer[5] = vector / 10 + '0' as u8; buffer[6] = vector % 10 + '0' as u8; unsafe { buffer[8] = keyboard_count + '0' as u8; keyboard_count = (keyboard_count + 1) % 10; } print_string(0, 0, &buffer); ...
927
fn up_to_release( repo: &Repository, reviewers: &Reviewers, mailmap: &Mailmap, to: &VersionTag, ) -> Result<AuthorMap, Box<dyn std::error::Error>> { let to_commit = repo.find_commit(to.commit).map_err(|e| { ErrorContext( format!( "find_commit: repo={}, commit={}",...
928
fn listing_a_single_migration_name_should_work(api: TestApi) { let dm = api.datamodel_with_provider( r#" model Cat { id Int @id name String } "#, ); let migrations_directory = api.create_migrations_directory(); api.create_migration("init", &dm, &migr...
929
pub fn test_mulw64() { let buffer = fs::read("tests/programs/mulw64").unwrap().into(); let result = run::<u64, SparseMemory<u64>>(&buffer, &vec!["mulw64".into()]); assert!(result.is_ok()); }
930
fn func_struct(data: Food){ println!("restaurant => {}", data.restaurant); println!("item => {}", data.item); println!("price => {}", data.price); }
931
fn adapters() { assert_done(|| list().map(|a| a + 1).collect(), Ok(vec![2, 3, 4])); assert_done(|| err_list().map_err(|a| a + 1).collect(), Err(4)); assert_done(|| list().fold(0, |a, b| finished::<i32, u32>(a + b)), Ok(6)); assert_done(|| err_list().fold(0, |a, b| finished::<i32, u32>(a + b)), Err(3)); ...
932
pub async fn client_async<'a, R, S>( request: R, stream: S, ) -> Result<(WebSocketStream<TokioAdapter<S>>, Response), Error> where R: IntoClientRequest + Unpin, S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin, { client_async_with_config(request, stream, None).await }
933
fn bindgen_test_layout_Bar() { const UNINIT: ::std::mem::MaybeUninit<Bar> = ::std::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<Bar>(), 48usize, concat!("Size of: ", stringify!(Bar)), ); assert_eq!( ::std::mem::align_of::<Ba...
934
pub fn get_remaining_timelimit(ctx: &PbsContext, job_id: &str) -> anyhow::Result<Duration> { let result = Command::new(&ctx.qstat_path) .args(&["-f", "-F", "json", job_id]) .output()?; if !result.status.success() { anyhow::bail!( "qstat command exited with {}: {}\n{}", ...
935
fn main() { let cli = CliArgs::from_args(); let args = Args::from(cli); actix::System::builder() .build() .block_on(async move { args.process().await }); }
936
pub fn causet_partitioner_context_free(context: Box<CausetPartitionerContext>) { //println!("causet_partitioner_context_free"); println!("causet_partitioner_context_free"); }
937
fn archive(version: &Version) -> String { format!("ruby-{}.zip", version) }
938
fn test_invalid_variable_2() { let parsed_data = parse(&"$invalid: false"); assert!(parsed_data .unwrap_err() .downcast_ref::<ParseError>() .is_some()); }
939
fn archive(version: &Version) -> String { format!("ruby-{}.tar.xz", version) }
940
fn main() { let mut prod_env = "".to_string(); let ws_server_thread = thread::Builder::new().name("ws_server".to_string()).spawn(move || { println!("Starting websocket server.."); listen("127.0.0.1:3012", |out| { Server { out: out } }).unwrap() }).unwrap(); thread::sleep(time::Duration::from_milli...
941
pub fn fetch_or ( & self val : bool ) - > bool { let a = unsafe { & * ( self . as_ptr ( ) as * const AtomicBool ) } ; a . fetch_or ( val Ordering : : AcqRel ) }
942
fn solve_1(input: &str) -> usize { let mut length = 0; let mut result = input.to_owned(); loop { result = reduce(&result); let reduced_length = result.len(); if reduced_length == length { break; } length = reduced_length; } length }
943
fn ownership_test() { let mut v = Vec::new(); for i in 101..106 { v.push(i.to_string()); } let fifth = v.pop().unwrap(); assert_eq!(fifth, "105"); let second = v.swap_remove(1); assert_eq!(second, "102"); let third = std::mem::replace(&mut v[2], "substitute".to_string()); ...
944
extern "C" fn telemetry_thread_fn() { let _ = MAIN_SENDER.send(GlobalEvent::Info); CHARLIE_LEDS.lock().unwrap().set_led(0, true); loop { CHARLIE_LEDS.lock().unwrap().next(); delay(Duration::from_ms(1)).unwrap(); } }
945
fn current_manifest_path() -> ManifestResult { let locate_result = Command::new("cargo").arg("locate-project").output(); let output = match locate_result { Ok(out) => out, Err(e) => { print!("Failure: {:?}", e); panic!("Cargo failure to target project via locate-project")...
946
pub extern "x86-interrupt" fn hdd1() { CommonInterruptHandler(46); }
947
fn binary_encoding_compatibility_tests_optional() { eprintln!("base64"); let base64_decompressed = "During tattooing, ink is injected into the skin, initiating an immune response, and cells called \"macrophages\" move into the area and \"eat up\" the ink. The macrophages carry some of the ink to the body\'s lym...
948
fn index(data: web::Json<PackageData>) -> String { let result = ethernet_header(&data.data[..]); let (rest, eth_header) = if result.is_ok() { let (r, eh) = result.unwrap(); (r, Some(eh)) } else { (&data.data[..], None) }; if eth_header.is_some() { let result = ipv4_he...
949
fn calculate_triangle_buffer_hash(triangles: &[TriangleDefinition]) -> u64 { let mut hasher = FxHasher::default(); triangles.hash(&mut hasher); hasher.finish() }
950
pub fn grammar() -> ParseContext<IRCToken> { let mut ctx = ParseContext::new(); /* message = [ ":" prefix SPACE ] command [ params ] crlf prefix = servername / ( nickname [ [ "!" user ] "@" host ] ) command = 1*letter / 3digit params = *14( SPACE middle ) [ SPACE ":" trailing ]...
951
fn state_to_buf(state: &Engine) -> Vec<u8> { serde_json::to_vec(state).unwrap() }
952
fn execute(cmd: String, args: Vec<String>) -> Result<ExitStatus, Error> { spawn(&cmd, &args, Stdio::inherit(), Stdio::inherit()) .map(|mut c| c.wait())? }
953
fn disable_metrics_tracing_integration() { std::env::set_var("DISABLE_INTERNAL_METRICS_TRACING_INTEGRATION", "true"); }
954
pub fn test_flat_crash_64() { let buffer = fs::read("tests/programs/flat_crash_64").unwrap().into(); let core_machine = DefaultCoreMachine::<u64, FlatMemory<u64>>::new(ISA_IMC, VERSION0, u64::max_value()); let mut machine = DefaultMachineBuilder::new(core_machine).build(); let result = machine.l...
955
fn perform_arithmetic( lhs: CoreAddr, rhs: CoreAddr, inputs: &OpInputs, ) -> Option<EmulatorResult<CoreAddr>> { // Performs an math modulo coresize, returning None only if division by zero match inputs.regs.current.instr.opcode { Opcode::Add => Some(offset(lhs, i64::from(rhs), inputs.core_si...
956
pub fn djn_op(inputs: OpInputs) -> EmulatorResult<()> { // DJN decrements the B-value and the B-target, then tests the B-value to // determine if it is zero. If the decremented B-value is not zero, the // sum of the program counter and the A-pointer is queued. Otherwise, the // next instruction is queu...
957
pub fn min_increment_for_unique(a: Vec<i32>) -> i32 { let mut A = a; A.sort_unstable(); let mut n = -1i32; let mut ans = 0i32; for &x in A.iter() { if n < x { n = x; } else { ans += n - x + 1; n += 1; } } ans }
958
fn no_item() { let dir = TestDir::new("sit", "no_item"); dir.cmd() .arg("init") .expect_success(); dir.cmd().args(&["reduce", "some-item"]).expect_failure(); }
959
fn test_deauthentication_packet() { // Receiver address: Siemens_41:bd:6e (00:01:e3:41:bd:6e) // Destination address: Siemens_41:bd:6e (00:01:e3:41:bd:6e) // Transmitter address: NokiaDan_3d:aa:57 (00:16:bc:3d:aa:57) // Source address: NokiaDan_3d:aa:57 (00:16:bc:3d:aa:57) // BSS Id: Siemens_41:bd:6e (00:01:e...
960
fn assert_memory_load_bytes_all<R: Rng>( rng: &mut R, max_memory: usize, buf_size: usize, addr: u64, ) { assert_memory_load_bytes( rng, &mut SparseMemory::<u64>::new_with_memory(max_memory), buf_size, addr, ); assert_memory_load_bytes( rng, &mu...
961
fn lz_string_uint8_array() { compression_tests( |s| { lz_str::compress_to_uint8_array(s) .into_iter() .map(u16::from) .collect::<Vec<u16>>() .into() }, |s| { lz_str::decompress_from_uint8_array( ...
962
const fn null_ble_gatt_svc_def() -> ble_gatt_svc_def { return ble_gatt_svc_def { type_: BLE_GATT_SVC_TYPE_END as u8, uuid: ptr::null(), includes: ptr::null_mut(), characteristics: ptr::null(), }; }
963
pub fn get_main_keyboard_shortcuts(config: &AxessConfiguration) -> Vec<KeyboardShortcut> { let mut s = vec![ KeyboardShortcut { key: KeyboardShortcutKey::Key(Keys::Enter), command_description: "Select the preset or scene".into(), command: ShortcutCommand::SelectPresetOrSc...
964
fn test_file() { use std::env; let mut dir = env::temp_dir(); dir.push("t_rex_test"); let basepath = format!("{}", &dir.display()); fs::remove_dir_all(&basepath); let cache = Filecache { basepath: basepath }; assert_eq!(cache.dir("tileset", 1, 2, 0), format!("{}/{}", cache.basepath, "tiles...
965
pub fn force_reset() -> Result<(), ()> { let mut configurator = Configurator::new(); configurator.force_reset(); Ok(()) }
966
async fn http_lookup(url: &Url) -> Result<Graph, Berr> { let resp = reqwest::get(url.as_str()).await?; if !resp.status().is_success() { return Err("unsucsessful GET".into()); } let content_type = resp .headers() .get(CONTENT_TYPE) .ok_or("no content-type header in respons...
967
fn main() { println!("Hello, Fizz Buzz!"); const NUMBER: i32 = 35; let fizz_buzz_result = fizz_buzz(NUMBER); println!("Fizz Buzz for number {} is: {:?}", NUMBER, fizz_buzz_result); }
968
pub extern "x86-interrupt" fn keyboard() { KeyboardHandler(33); }
969
unsafe fn atomic_store < T > ( dst : * mut T val : T ) { atomic ! { T a { a = & * ( dst as * const _ as * const _ ) ; a . store ( mem : : transmute_copy ( & val ) Ordering : : Release ) ; mem : : forget ( val ) ; } { let _guard = lock ( dst as usize ) . write ( ) ; ptr : : write ( dst val ) ; } } }
970
extern fn QScroller_scrollerPropertiesChanged_signal_connect_cb_box_0(rsfptr_raw:*mut Box<Fn(QScrollerProperties)>, arg0: *mut c_void) { println!("{}:{}", file!(), line!()); let rsfptr = unsafe{Box::from_raw(rsfptr_raw)}; let rsarg0 = QScrollerProperties::inheritFrom(arg0 as u64); // rsfptr(rsarg0); unsafe{(*...
971
pub fn acrn_remove_file(path: &str) -> Result<(), String> { fs::remove_file(path).map_err(|e| e.to_string()) }
972
fn item_named_user_query() { let dir = TestDir::new("sit", "named_user_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 i...
973
fn main() -> ! { let mut robot = init_peripherals( stm32f446::Peripherals::take().unwrap(), cortex_m::Peripherals::take().unwrap(), ); init_servo(&mut robot); let mut reader = TrameReader::new(); loop { let b = block!(robot.pc_rx.read()).unwrap(); reader.step(b); ...
974
const fn atomic_is_lock_free < T > ( ) - > bool { let is_lock_free = can_transmute : : < T AtomicUnit > ( ) | can_transmute : : < T atomic : : AtomicU8 > ( ) | can_transmute : : < T atomic : : AtomicU16 > ( ) | can_transmute : : < T atomic : : AtomicU32 > ( ) ; # [ cfg ( not ( crossbeam_no_atomic_64 ) ) ] let is_lock_f...
975
pub fn validate_file(args: &Vec<String>) -> Result<Box<&Path>, KataError> { if args.len() < 2 { Err(KataError::new("Not enough arguments! Missing filename.")) } else { let file_name = Path::new(&args[1]); if file_name.exists() { Ok(Box::new(file_name)) } else { ...
976
pub(crate) fn assignment_with_rescue_modifier(i: Input) -> NodeResult { map( tuple(( left_hand_side, no_lt, char('='), ws0, operator_expression, no_lt, tag("rescue"), ws0, operator_expression, ...
977
pub extern "x86-interrupt" fn serial_2() { CommonInterruptHandler(35); }
978
fn figure1b_pct_with_many_tasks() { // Spawn 18 busy threads, each taking 5 steps, plus 2 main threads with 10 steps, so k=110 // n=50, k=110, d=2, so probability of finding the bug in one iteration is at least 1/(20*110) // So probability of hitting the bug in 16_000 iterations = 1 - (1 - 1/2200)^16_000 > ...
979
pub fn init(title: &str) -> System { let title = match title.rfind('/') { Some(idx) => title.split_at(idx + 1).1, None => title, }; let events_loop = glutin::EventsLoop::new(); let builder = glutin::WindowBuilder::new() .with_title(title.to_owned()) .with_dimensions(gluti...
980
async fn init() -> Result<Args> { let mut log_on = false; #[cfg(feature = "dev-console")] match console_subscriber::try_init() { Ok(_) => { warn!("dev-console enabled"); log_on = true; } Err(e) => { eprintln!("Failed to initialise tokio console, falling back to normal logging\n{e}") } } if !log_...
981
pub fn write_value<W>(wr: &mut W, val: &Value) -> Result<(), Error> where W: Write { match val { &Value::Nil => try!(write_nil(wr)), &Value::Boolean(val) => try!(write_bool(wr, val)), // TODO: Replace with generic write_int(...). &Value::Integer(Integer::U64(val)) => { ...
982
fn main_loop(main_sender: MailSender<GlobalEvent>, main_receiver: MailReceiver<GlobalEvent>) -> ! { let state = GlobalState::new(); let mut store = Store::new( state, |state| { let mut charlie_leds = CHARLIE_LEDS.lock().unwrap(); charlie_leds.set_leds([ ...
983
pub fn do_souper_harvest(func: &ir::Function, out: &mut mpsc::Sender<String>) { let mut allocs = Allocs::default(); // Iterate over each instruction in each block and try and harvest a // left-hand side from its result. for block in func.layout.blocks() { let mut option_inst = func.layout.first...
984
pub fn challenge_5() { let input = "Burning 'em, if you ain't quick and nimble\nI go crazy when I hear a cymbal"; let out = crypto::xor_repeating(&input.as_bytes().to_vec(), &"ICE".as_bytes().to_vec()); let out_str = hex::encode(out); println!("{}", out_str); }
985
pub fn brackets_are_balanced(string: &str) -> bool { let mut brackets = vec![]; for char in string.chars() { match char { '(' => brackets.push(char), '[' => brackets.push(char), '{' => brackets.push(char), '}' => { if brackets.len() == 0 {...
986
fn app_installer_dir(settings: &Settings) -> crate::Result<PathBuf> { let arch = match settings.binary_arch() { "x86" => "x86", "x86_64" => "x64", target => { return Err(crate::Error::ArchError(format!( "Unsupported architecture: {}", target ))) } }; let package_base_n...
987
async fn server(url: &str) -> Result<!, String> { let server = TcpServer::bind(url).await.map_err(|e| e.to_string())?; let (op_reads, op_writes) = TcpServerOp::<RequestLatRepr>::new(server.clone()) // .debug("ingress") .morphism_closure(|item| item.flatten_keyed::<tag::VEC>()) .morphism...
988
pub fn collect_events(events_loop: &mut EventsLoop) -> Vec<Event> { let mut events = Vec::<Event>::new(); events_loop.poll_events(|event| events.push(event)); events }
989
pub async fn client_async_tls_with_config<R, S>( request: R, stream: S, config: Option<WebSocketConfig>, ) -> Result<(WebSocketStream<ClientStream<S>>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin, AutoStream<S>: Unpin, {...
990
pub fn test_memory_store_empty_bytes() { assert_memory_store_empty_bytes(&mut FlatMemory::<u64>::default()); assert_memory_store_empty_bytes(&mut SparseMemory::<u64>::default()); assert_memory_store_empty_bytes(&mut WXorXMemory::<FlatMemory<u64>>::default()); #[cfg(has_asm)] assert_memory_store_empt...
991
fn default_or(key: &str, default_value: f64, ctx: &mut Context) -> Decimal { let property = ctx.widget().clone_or_default(key); match Decimal::from_f64(property) { Some(val) => val, None => Decimal::from_f64(default_value).unwrap(), } }
992
fn a_table_should_read_0_for_any_key() { let mut table = HashMapOfTreeMap::new(); let mut vs = [Value::default(); 1]; table.read (0, &[0], &mut vs); match vs { [Value { v: 0, t: 0}] => (), _ => assert!(false) } }
993
fn list() -> Receiver<i32, u32> { let (tx, rx) = channel(); tx.send(Ok(1)) .and_then(|tx| tx.send(Ok(2))) .and_then(|tx| tx.send(Ok(3))) .forget(); return rx }
994
pub fn write_u64<W>(wr: &mut W, val: u64) -> Result<(), ValueWriteError> where W: Write { try!(write_marker(wr, Marker::U64)); write_data_u64(wr, val) }
995
pub extern fn pktproc_process(thread_id: u64, packets: *mut *mut libc::c_void, count: u32) { CONTEXT.with(|ref context| { if let Some(ref ctx) = *context.borrow() { assert_eq!(ctx.thread_id, thread_id); let pkts: &mut [&mut Packet] = unsafe { mem::transmute(slice::fro...
996
pub fn string_compose(parts: Node) -> Node { if is_collapse_string_parts(&parts) {} // TODO DUMMY if let Node::Str(string_value) = parts { return Node::Str(string_value); } if let Node::Nodes(str_nodes) = parts { if let Node::Str(str_value) = (*str_nodes.get(0).unwrap()).clone() { r...
997
fn main() { aoc_main(part1, part2); }
998
pub fn bubble_sort<T: PartialOrd + Debug>(v: &mut [T]) { for p in 0..v.len() { // println!("{:?}", v); let mut sorted = true; for i in 0..(v.len()-1) - p{ if v[i] > v[i+1] { v.swap(i, i+1); sorted = false; } } if sorted ...
999