text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: dennisss/dacha path: /pkg/macros/src/args.rs use std::collections::HashMap; use proc_macro::TokenStream; use proc_macro2::TokenTree; use quote::{quote, quote_spanned}; use syn::spanned::Spanned; use syn::{ parse_macro_input, parse_quote, AttributeArgs, Data, DeriveInput, Fields, GenericPara...
code_fim
hard
{ "lang": "rust", "repo": "dennisss/dacha", "path": "/pkg/macros/src/args.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fabianschuiki/llhd path: /src/pass/dce.rs // Copyright (c) 2017-2021 Fabian Schuiki //! Dead Code Elimination use crate::{ir::prelude::*, opt::prelude::*}; use std::collections::{HashMap, HashSet}; /// Dead Code Elimination /// /// This pass implements dead code elimination. It removes instru...
code_fim
hard
{ "lang": "rust", "repo": "fabianschuiki/llhd", "path": "/src/pass/dce.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Check if a block can be trivially addressed from a different block, and if /// so, return a potential immediate forward through the block if trivial. fn check_block_retargetable( unit: &UnitBuilder, block: Block, triv_bb: &mut HashMap<Block, Option<Block>>, triv_br: &mut HashMap<Inst, ...
code_fim
hard
{ "lang": "rust", "repo": "fabianschuiki/llhd", "path": "/src/pass/dce.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oleganza/libmerlin path: /src/lib.rs //! A Rust testing harness for the C implementation. // This entire crate is only for tests, so it's all unused without cfg(test) #![allow(dead_code)] #[cfg(test)] extern crate keccak; #[cfg(test)] extern crate merlin; #[cfg(test)] extern crate rand; // sho...
code_fim
hard
{ "lang": "rust", "repo": "oleganza/libmerlin", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rs_transcript = merlin::Transcript::new(b"ConformanceTest"); let mut c_transcript = Transcript::new(b"ConformanceTest"); let max_test_data_size = 64 * 1024; let mut message_data = vec![0u8; max_test_data_size]; let mut rs_chal_buf = vec![0u8; max_test_data_...
code_fim
hard
{ "lang": "rust", "repo": "oleganza/libmerlin", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jnqnfe/pulse-binding-rust path: /pulse-binding-simple/src/lib.rs // Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language binding. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute th...
code_fim
hard
{ "lang": "rust", "repo": "jnqnfe/pulse-binding-rust", "path": "/pulse-binding-simple/src/lib.rs", "mode": "psm", "license": "LGPL-2.1-or-later", "source": "the-stack-v2" }
<|fim_suffix|>impl Simple { /// Creates a new connection to the server. /// /// # Params /// /// * `server`: Server name, or `None` for default. /// * `name`: A descriptive name for this client (application name, ...). /// * `dir`: Open this stream for recording or playback? /// * `dev`:...
code_fim
hard
{ "lang": "rust", "repo": "jnqnfe/pulse-binding-rust", "path": "/pulse-binding-simple/src/lib.rs", "mode": "spm", "license": "LGPL-2.1-or-later", "source": "the-stack-v2" }
<|fim_suffix|> let p_map = map.map_or(null::<pcapi::pa_channel_map>(), |m| m.as_ref()); let p_attr = attr.map_or(null::<pcapi::pa_buffer_attr>(), |a| a.as_ref()); let p_server = server.map_or(null::<c_char>(), |_| c_server.as_ptr() as *const c_char); let p_dev = dev.map_or(null::<c_char>(...
code_fim
hard
{ "lang": "rust", "repo": "jnqnfe/pulse-binding-rust", "path": "/pulse-binding-simple/src/lib.rs", "mode": "spm", "license": "LGPL-2.1-or-later", "source": "the-stack-v2" }
<|fim_suffix|> } } } } println!("Answer1: {}", min*argmin); let mut us = Vec::new(); let mut ms = Vec::new(); for (i,id) in ids.iter().enumerate() { match id.parse::<u64>() { Err(_) => continue, Ok(n) => { us.push(BigInt::from(-(i...
code_fim
hard
{ "lang": "rust", "repo": "krtab/aoc2020", "path": "/day13/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krtab/aoc2020 path: /day13/src/main.rs use num_bigint::BigInt; fn main() -> anyhow::Result<()> { let buf = String::from_utf8(std::fs::read("input.txt")?)?; let mut lines = buf.lines(); let earliest : u64 = lines.next().unwrap().parse()?; let ids : Vec<_> = lines.next().unwrap()....
code_fim
hard
{ "lang": "rust", "repo": "krtab/aoc2020", "path": "/day13/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> buffer.copy_from_slice(&mut to_write); } fn write_to_file(data: Vec<u8>, file: File, width: u32, height: u32) { let mut encoder = png::Encoder::new(BufWriter::new(file), width, height); encoder.set_color(png::ColorType::RGB); encoder.set_depth(png::BitDepth::Sixteen); let mut writer ...
code_fim
hard
{ "lang": "rust", "repo": "ashpil/based", "path": "/xenon/src/write.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ashpil/based path: /xenon/src/write.rs use std::io::BufWriter; use std::fs::File; use crate::color::Color; #[cfg(feature = "rayon")] use rayon::prelude::*; pub fn fn_to_png(width: u32, height: u32, file: File, func: impl Fn(u32, u32) -> Color + Sync + Send) { let mut data = vec![0; (width ...
code_fim
hard
{ "lang": "rust", "repo": "ashpil/based", "path": "/xenon/src/write.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zyla/talent-plan path: /courses/dss/raft/src/kvraft/server.rs use std::sync::Arc; use futures::StreamExt; use futures::channel::mpsc::unbounded; use futures::channel::mpsc::UnboundedReceiver; use futures::channel::oneshot; use futures::lock::Mutex; use std::collections::HashMap; use crate::prot...
code_fim
hard
{ "lang": "rust", "repo": "zyla/talent-plan", "path": "/courses/dss/raft/src/kvraft/server.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|>ion).finish(); let client = Client::builder().connector(connector).finish(); client }<|fim_prefix|>// repo: yat-labs/partner_auth_service path: /src/server/client.rs use actix_web::client::{Client, Connector}; use std::time::Duration; pub fn client_with_conn<|fim_middle|>ector_timeout(connector_...
code_fim
medium
{ "lang": "rust", "repo": "yat-labs/partner_auth_service", "path": "/src/server/client.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yat-labs/partner_auth_service path: /src/server/client.rs use actix_web::client::{Client, Connector}; use std::time::Duration; pub fn client_with_conn<|fim_suffix|>ion).finish(); let client = Client::builder().connector(connector).finish(); client }<|fim_middle|>ector_timeout(connector_...
code_fim
medium
{ "lang": "rust", "repo": "yat-labs/partner_auth_service", "path": "/src/server/client.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: graydon/nperf path: /src/arch/mod.rs use std::fmt; use gimli; use dwarf_regs::DwarfRegs; use address_space::MemoryReader; use unwind_context::UnwindFrame; use archive::{Endianness, Bitness}; pub mod amd64; pub mod mips64; pub mod arm; pub mod native { #[cfg(target_arch = "x86_64")] pub...
code_fim
hard
{ "lang": "rust", "repo": "graydon/nperf", "path": "/src/arch/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Architecture: Sized { const NAME: &'static str; const ENDIANNESS: Endianness; const BITNESS: Bitness; type Endianity: Endianity + 'static; type State; fn register_name( register: u16 ) -> RegName { if let Some( name ) = Self::register_name_str( register ) { ...
code_fim
hard
{ "lang": "rust", "repo": "graydon/nperf", "path": "/src/arch/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>//============================================================================== // Public Functions //============================================================================== pub fn init() { button::init(); led::init(); } //========================================================================...
code_fim
medium
{ "lang": "rust", "repo": "tayspen72/cc2640_dev", "path": "/src/drivers/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tayspen72/cc2640_dev path: /src/drivers/mod.rs //============================================================================== // Notes //============================================================================== // drivers::mod.rs <|fim_suffix|>//==========================================...
code_fim
hard
{ "lang": "rust", "repo": "tayspen72/cc2640_dev", "path": "/src/drivers/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //============================================================================== // Task Handler //============================================================================== pub fn task_handler() { button::task_handler(); led::task_handler(); }<|fim_prefix|>// repo: tayspen72/cc2640_dev path: /src...
code_fim
hard
{ "lang": "rust", "repo": "tayspen72/cc2640_dev", "path": "/src/drivers/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YoonSung/Rust-PriorityQueue path: /tests/lib.rs extern crate rust_datastructure; use rust_datastructure::binary_min_heap; <|fim_suffix|> let mut unordered_array = [9,8,7,6,5,4,3,2,1,0]; binary_min_heap::test(); }<|fim_middle|>#[test] fn binary_min_heap() {
code_fim
easy
{ "lang": "rust", "repo": "YoonSung/Rust-PriorityQueue", "path": "/tests/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> binary_min_heap::test(); }<|fim_prefix|>// repo: YoonSung/Rust-PriorityQueue path: /tests/lib.rs extern crate rust_datastructure; use rust_datastructure::binary_min_heap; <|fim_middle|>#[test] fn binary_min_heap() { let mut unordered_array = [9,8,7,6,5,4,3,2,1,0];
code_fim
medium
{ "lang": "rust", "repo": "YoonSung/Rust-PriorityQueue", "path": "/tests/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut unordered_array = [9,8,7,6,5,4,3,2,1,0]; binary_min_heap::test(); }<|fim_prefix|>// repo: YoonSung/Rust-PriorityQueue path: /tests/lib.rs extern crate rust_datastructure; use rust_datastructure::binary_min_heap; <|fim_middle|>#[test] fn binary_min_heap() {
code_fim
easy
{ "lang": "rust", "repo": "YoonSung/Rust-PriorityQueue", "path": "/tests/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coolo/spider path: /spider_rust/src/deck.rs } if n_suits == 2 { nsuit = suit % 2; } let c = Card::known(nsuit, rank); cards.push(Card::new(c.value())); cards.push(c); }...
code_fim
hard
{ "lang": "rust", "repo": "coolo/spider", "path": "/spider_rust/src/deck.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coolo/spider path: /spider_rust/src/deck.rs ; } Some(pile) => { let parsed = Pile::parse(pile); match parsed { None => panic!("Failed to parse {}", pile), Some(pile) => match i...
code_fim
hard
{ "lang": "rust", "repo": "coolo/spider", "path": "/spider_rust/src/deck.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn shortest_path2() { // win in 28 moves // 7->0 8->7 8->3 1->3 8->3 9->3 9->8 9->4 // 0->9 9->6 6->off 3->4 8->3 6->5 6->4 9->6 7->6 9->3 // 6->7 7->6 6->3 3->5 5->6 6->off 6->2 4->2 6->2 2->off let text = "Play0: TH 9H 8H 7H 6H 5H 4H 3H Pla...
code_fim
hard
{ "lang": "rust", "repo": "coolo/spider", "path": "/spider_rust/src/deck.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let balances = view!(pool.get_deposits(to_va(root.account_id.clone()))) .unwrap_json::<HashMap<AccountId, U128>>(); assert_eq!( balances.get(&eth()).unwrap(), &U128(to_yocto("100") + 1662497915624478906119726) ); assert_eq!(balances.get(&dai()).unwrap(), &U128(to_yo...
code_fim
hard
{ "lang": "rust", "repo": "kcole16/ref-contracts", "path": "/ref-exchange/tests/test_swap.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kcole16/ref-contracts path: /ref-exchange/tests/test_swap.rs use std::convert::TryFrom; use near_sdk::json_types::{ValidAccountId, U128}; use near_sdk::AccountId; use near_sdk_sim::{call, deploy, init_simulator, to_yocto, view, ContractAccount, UserAccount}; use ref_exchange::{ContractContract...
code_fim
hard
{ "lang": "rust", "repo": "kcole16/ref-contracts", "path": "/ref-exchange/tests/test_swap.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl NodeIDResponse { pub fn from_response(response: proto::Response) -> Result<NodeID> { Ok(match response { proto::Response::OnlyID { id } => id, got => Err(ErrorKind::InvalidResponseType { expected: "NodeIDResponse", got, }...
code_fim
easy
{ "lang": "rust", "repo": "0xcaff/dht-crawler", "path": "/packages/tokio_krpc/src/responses/node_id_response.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xcaff/dht-crawler path: /packages/tokio_krpc/src/responses/node_id_response.rs use crate::send_errors::{ ErrorKind, Result, }; use krpc_encoding::{ self as proto, NodeID, }; <|fim_suffix|>impl NodeIDResponse { pub fn from_response(response: proto::Response) -> Result<NodeI...
code_fim
easy
{ "lang": "rust", "repo": "0xcaff/dht-crawler", "path": "/packages/tokio_krpc/src/responses/node_id_response.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/Devices/Gpio/mod.rs #![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "Devices_Gpio_Provider")] pub mod Provider; #[link(name = "windows")] extern "syst...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/crates/deps/sys/src/Windows/Devices/Gpio/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *self } } pub type GpioChangeReader = *mut ::core::ffi::c_void; #[repr(C)] #[cfg(feature = "Foundation")] pub struct GpioChangeRecord { pub RelativeTime: super::super::Foundation::TimeSpan, pub Edge: GpioPinEdge, } #[cfg(feature = "Foundation")] impl ::core::marker::Copy for GpioChange...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/crates/deps/sys/src/Windows/Devices/Gpio/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *self } } #[repr(transparent)] pub struct GpioPinValue(pub i32); impl GpioPinValue { pub const Low: Self = Self(0i32); pub const High: Self = Self(1i32); } impl ::core::marker::Copy for GpioPinValue {} impl ::core::clone::Clone for GpioPinValue { fn clone(&self) -> Self { *...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/crates/deps/sys/src/Windows/Devices/Gpio/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`eth_dmaa4rx_acr::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."] pub struct ETH_DMAA4RX_ACR_SPEC; impl crate::RegisterSpec for ETH_DM...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/eth_dma/eth_dmaa4rx_acr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp153/eth_dma/eth_dmaa4rx_acr.rs #[doc = "Register `ETH_DMAA4RxACR` reader"] pub type R = crate::R<ETH_DMAA4RX_ACR_SPEC>; #[doc = "Register `ETH_DMAA4RxACR` writer"] pub type W = crate::W<ETH_DMAA4RX_ACR_SPEC>; #[doc = "Field `RDWC` reader - R...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/eth_dma/eth_dmaa4rx_acr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mowind/juice-sdk-rs path: /src/lib.rs #[macro_use] extern crate futures; use jsonrpc_core as rpc; // it needs to be before other modules // otherwise the macro for tests is not available. #[macro_use] pub mod helpers; pub mod client; pub mod error; pub mod transports; pub mod types; pub use e...
code_fim
hard
{ "lang": "rust", "repo": "mowind/juice-sdk-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Execute remote method with given parameters. fn execute(&self, method: &str, params: Vec<rpc::Value>) -> Self::Out { let (id, request) = self.prepare(method, params); self.send(id, request) } } impl<X, T> Transport for X where T: Transport + ?Sized, X: std::ops::De...
code_fim
hard
{ "lang": "rust", "repo": "mowind/juice-sdk-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn send(&self, id: RequestId, request: rpc::Call) -> Self::Out { (**self).send(id, request) } } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }<|fim_prefix|>// repo: mowind/juice-sdk-rs path: /src/lib.rs #[macro_use] extern crate futures; us...
code_fim
hard
{ "lang": "rust", "repo": "mowind/juice-sdk-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonlamb-gh/openscad-models-rust path: /sandbox/house/src/posts.rs /// Posts (Hashira) use dimdraw::{ObjectAssembler, ObjectDescriptor}; use parts::common_functions::*; use parts::Board; use scad::*; use config::*; qstruct!(Posts(color: Option<&'static str>) { l12: Board = Board::new( ...
code_fim
hard
{ "lang": "rust", "repo": "jonlamb-gh/openscad-models-rust", "path": "/sandbox/house/src/posts.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // col 2 let x_offset = ft_to_cm(8.0); for row in 0..5 { if row == 0 || row == 3 || row == 4 { let y_offset = row as f32 * ft_to_cm(8.0); parent.add_child(scad!(Translate(vec3(x_offset, y_offset, 0.0));{ self.assemble_...
code_fim
hard
{ "lang": "rust", "repo": "jonlamb-gh/openscad-models-rust", "path": "/sandbox/house/src/posts.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if( args.len() != 2) { eprintln!("Usage: {} <path to file>", args[0]); process::exit(1); } let filename = &args[1]; println!("Will parse {}", filename); let config = Config::new(filename); let nodes = run(config); println!("{}", nodes) }<|fim_prefix|>// repo: KartikAiyer/media_atoms...
code_fim
medium
{ "lang": "rust", "repo": "KartikAiyer/media_atoms", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KartikAiyer/media_atoms path: /src/main.rs // Kartik Aiyer use std::env; use std::process; use media_atoms::*; <|fim_suffix|> let config = Config::new(filename); let nodes = run(config); println!("{}", nodes) }<|fim_middle|>fn main() { let args: Vec<String> = env::args().collect(); if...
code_fim
hard
{ "lang": "rust", "repo": "KartikAiyer/media_atoms", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: upsuper-forks/sightglass path: /crates/recorder/src/benchmark.rs use crate::measure::{Measure, MeasureType, Measurement}; use anyhow::Result; use libloading as lib; use log::info; use serde::{Deserialize, Serialize}; use std::ffi::{c_void, OsStr}; /// Measure various phases of a Wasm module's l...
code_fim
hard
{ "lang": "rust", "repo": "upsuper-forks/sightglass", "path": "/crates/recorder/src/benchmark.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Measure the module compilation. measure.start(); let result = engine_compile_module(engine); let compilation = measure.end(); assert_eq!( result, 0, "`engine_compile_module` did not return a success exit code" ); info!("Com...
code_fim
hard
{ "lang": "rust", "repo": "upsuper-forks/sightglass", "path": "/crates/recorder/src/benchmark.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut s = String::from("hello"); { //closure let add5 = |x:i32| { s.push_str("world"); //possible because of FnMut println!("{}", s); x + 5 }; //println!("{}",s); //error. immutable borrow let t = apply(add5); p...
code_fim
easy
{ "lang": "rust", "repo": "anwarmamat/cmsc330", "path": "/rust/fnmut.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anwarmamat/cmsc330 path: /rust/fnmut.rs fn apply<F>(mut f:F)->i32 where F:FnMut(i32)->i32 { f(10) } <|fim_suffix|> let mut s = String::from("hello"); { //closure let add5 = |x:i32| { s.push_str("world"); //possible because of FnMut println!(...
code_fim
easy
{ "lang": "rust", "repo": "anwarmamat/cmsc330", "path": "/rust/fnmut.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type TypeId = String; #[derive(PartialEq, Clone, Debug)] pub enum Type { Id(TypeId), Field(Vec<TypeField>), Array(String), } #[derive(PartialEq, Clone, Debug)] pub enum TypedExpr { Num(i64), Str(String), Var(String, Type), OpNode(Op, Type, Box<TypedExpr>, Box<TypedExpr>), ...
code_fim
hard
{ "lang": "rust", "repo": "koba-e964/rust-tigress", "path": "/src/ast.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koba-e964/rust-tigress path: /src/ast.rs use std::fmt; // Expr #[derive(PartialEq, Clone, Debug)] pub enum Expr { Num(i64), Str(String), LVal(LValue), Neg(Box<Expr>), OpNode(Op, Box<Expr>, Box<Expr>), IfNode(Box<Expr>, Box<Expr>, Box<Expr>), // If the first evaluates to ...
code_fim
hard
{ "lang": "rust", "repo": "koba-e964/rust-tigress", "path": "/src/ast.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(2 + 2, 4); } }<|fim_prefix|>// repo: kazhida/sabyc path: /src/lib.rs //! Saby/c - Virtual Machine for mruby byte-code. //! //! Copyright (C) 2021 ABplus Inc. kazhida //! //! This file is distributed under BSD 3-Clause License. //! mod config; mod vm; mod builtin; mod op_code; <|...
code_fim
easy
{ "lang": "rust", "repo": "kazhida/sabyc", "path": "/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kazhida/sabyc path: /src/lib.rs //! Saby/c - Virtual Machine for mruby byte-code. //! //! Copyright (C) 2021 ABplus Inc. kazhida //! //! This file is distributed under BSD 3-Clause License. //! mod config; mod vm; mod builtin; mod op_code; <|fim_suffix|> assert_eq!(2 + 2, 4); } }<|...
code_fim
easy
{ "lang": "rust", "repo": "kazhida/sabyc", "path": "/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> match write_object_file(assm_data, out_file.as_ref()) { Err(err) => panic!("{:?}",err), Ok(()) => () } }<|fim_prefix|>// repo: jmpspace/lc4 path: /src/bin/lc4-assembler.rs #![feature(box_syntax, core)] extern crate core; extern crate lc4; use std::convert::AsRef; use std::env::args; use st...
code_fim
hard
{ "lang": "rust", "repo": "jmpspace/lc4", "path": "/src/bin/lc4-assembler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jmpspace/lc4 path: /src/bin/lc4-assembler.rs #![feature(box_syntax, core)] extern crate core; extern crate lc4; use std::convert::AsRef; use std::env::args; use std::vec::Vec; <|fim_suffix|> println!(""); for addr in 0..assm_data.heap { println!("{:?} {:?}", addr, assm_data.memory[add...
code_fim
hard
{ "lang": "rust", "repo": "jmpspace/lc4", "path": "/src/bin/lc4-assembler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut out_file = source_file.clone(); out_file.push_str("obj"); match write_object_file(assm_data, out_file.as_ref()) { Err(err) => panic!("{:?}",err), Ok(()) => () } }<|fim_prefix|>// repo: jmpspace/lc4 path: /src/bin/lc4-assembler.rs #![feature(box_syntax, core)] extern crate core; e...
code_fim
hard
{ "lang": "rust", "repo": "jmpspace/lc4", "path": "/src/bin/lc4-assembler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hirevo/alexandrie path: /crates/alexandrie-index/src/index/mod.rs /// Index management through `git` shell command invocations. pub mod cli; /// Index management usin<|fim_suffix|>/libgit2.org #[cfg(feature = "git2")] pub mod git2;<|fim_middle|>g [**`libgit2`**][libgit2]. /// [libgit2]: https:/
code_fim
easy
{ "lang": "rust", "repo": "Hirevo/alexandrie", "path": "/crates/alexandrie-index/src/index/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/libgit2.org #[cfg(feature = "git2")] pub mod git2;<|fim_prefix|>// repo: Hirevo/alexandrie path: /crates/alexandrie-index/src/index/mod.rs /// Index management through `git` shell command i<|fim_middle|>nvocations. pub mod cli; /// Index management using [**`libgit2`**][libgit2]. /// [libgit2]: https:/
code_fim
medium
{ "lang": "rust", "repo": "Hirevo/alexandrie", "path": "/crates/alexandrie-index/src/index/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn transposed(self) -> Self { Point::new(self.y, self.x) } }<|fim_prefix|>// repo: noemk2/battleship-salvo path: /server/src/model/point.rs use serde::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; use core::fmt; #[derive(Serialize, Deserialize, Debug, PartialOr...
code_fim
medium
{ "lang": "rust", "repo": "noemk2/battleship-salvo", "path": "/server/src/model/point.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noemk2/battleship-salvo path: /server/src/model/point.rs use serde::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; use core::fmt; <|fim_suffix|> write!(f, "[{}; {}]", self.x, self.y) } } impl Point { pub fn new(x: u8, y: u8) -> Self { Point { x...
code_fim
hard
{ "lang": "rust", "repo": "noemk2/battleship-salvo", "path": "/server/src/model/point.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>rintln!("cargo:rustc-link-lib=static=ogc"); println!("cargo:rustc-link-search={}/libogc/lib/wii", devkitpro); }<|fim_prefix|>// repo: EduRenesto/rust-wii path: /libogc-sys/build.rs use std::env; pub fn main() { let devkitpro = env::v<|fim_middle|>ar("DEVKITPRO").expect("is DEVKITPRO installed?")...
code_fim
easy
{ "lang": "rust", "repo": "EduRenesto/rust-wii", "path": "/libogc-sys/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>"cargo:rustc-link-search={}/libogc/lib/wii", devkitpro); }<|fim_prefix|>// repo: EduRenesto/rust-wii path: /libogc-sys/build.rs use std::env; pub fn main() { let devkitpro = env::v<|fim_middle|>ar("DEVKITPRO").expect("is DEVKITPRO installed?"); println!("cargo:rustc-link-lib=static=ogc"); p...
code_fim
medium
{ "lang": "rust", "repo": "EduRenesto/rust-wii", "path": "/libogc-sys/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EduRenesto/rust-wii path: /libogc-sys/build.rs use std::env; pub fn main() { let devkitpro = env::v<|fim_suffix|>"cargo:rustc-link-search={}/libogc/lib/wii", devkitpro); }<|fim_middle|>ar("DEVKITPRO").expect("is DEVKITPRO installed?"); println!("cargo:rustc-link-lib=static=ogc"); p...
code_fim
medium
{ "lang": "rust", "repo": "EduRenesto/rust-wii", "path": "/libogc-sys/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let pos = Scene::load_vec3f(e.get("pos").expect("Camera view position must be set")) .expect("Invalid camera position"); let target = Scene::load_vec3f(e.get("target").expect("Camera view target must be set")) .expect("Invalid camera target"); let up = Scene...
code_fim
hard
{ "lang": "rust", "repo": "Twinklebear/ispc-rs", "path": "/examples/ddvol/src/scene.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Twinklebear/ispc-rs path: /examples/ddvol/src/scene.rs //! Provides the scene struct containing information needed to render a //! volume from some camera position. Scenes are stored in JSON format, for example: //! //! ```json //! { //! "volume": { //! "file": "csafe-heptane-302-...
code_fim
hard
{ "lang": "rust", "repo": "Twinklebear/ispc-rs", "path": "/examples/ddvol/src/scene.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OneFourth/advent2019 path: /day08/src/main.rs use std::ops; #[derive(Debug, Clone)] struct Layer { pixels: Vec<u32>, } impl ops::Add<Layer> for Layer { type Output = Layer; fn add(self, _rhs: Layer) -> Layer { Layer { pixels: self .pixels ...
code_fim
hard
{ "lang": "rust", "repo": "OneFourth/advent2019", "path": "/day08/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { let part2 = layers; let mut layer = part2.first().unwrap().clone(); for item in part2.iter().skip(1) { layer = layer + item.clone(); } println!("Part 2:"); for c in layer.pixels.chunks(25) { for p in c { if *p ...
code_fim
hard
{ "lang": "rust", "repo": "OneFourth/advent2019", "path": "/day08/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> part1.sort_by(|a, b| { a.pixels .iter() .filter(|&&p| p == 0) .count() .partial_cmp(&b.pixels.iter().filter(|&&p| p == 0).count()) .unwrap() }); println!( "Part 1: {:?}", ...
code_fim
hard
{ "lang": "rust", "repo": "OneFourth/advent2019", "path": "/day08/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vtree-rs/vtree path: /vtree_macros/src/generator/groups.rs quote!{ Text(::std::borrow::Cow<'static, str>), } } } }); quote!{ #[derive(Debug, Clone)] pub enum #group { #(#vars)* Widg...
code_fim
hard
{ "lang": "rust", "repo": "vtree-rs/vtree", "path": "/vtree_macros/src/generator/groups.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let node_name = &node.name; let maybe_params_cmp = node.params_ty.as_ref().map(|_| quote!{ if curr_node.params != last_node.params { differ.diff_params_changed(ctx, curr, last); } }); quote!{ // equal types (...
code_fim
hard
{ "lang": "rust", "repo": "vtree-rs/vtree", "path": "/vtree_macros/src/generator/groups.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vtree-rs/vtree path: /vtree_macros/src/generator/groups.rs .add_empty(), ); } } ChildType::Optional => { quote!{ if let Some(children) = curr_node.children { AllNodes::expand_w...
code_fim
hard
{ "lang": "rust", "repo": "vtree-rs/vtree", "path": "/vtree_macros/src/generator/groups.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if(result.is_ok()) { println!("ok"); } match result { Ok(_) => println!("{:?}", s), Err(e) => {}, } }<|fim_prefix|>// repo: hitoyozake/Rust_study path: /webrequest/src/main.rs extern crate reqwest; use std::io::Read; fn main() { <|fim_midd...
code_fim
medium
{ "lang": "rust", "repo": "hitoyozake/Rust_study", "path": "/webrequest/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hitoyozake/Rust_study path: /webrequest/src/main.rs extern crate reqwest; use std::io::Read; fn main() { println!("Hello, world!"); let mut resp = reqwest::get("https://www.rust-lang.org").unwrap(); let mut s = String::new(); let result = resp.read_to_string(&mut s); <|fim_...
code_fim
medium
{ "lang": "rust", "repo": "hitoyozake/Rust_study", "path": "/webrequest/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut resp = reqwest::get("https://www.rust-lang.org").unwrap(); let mut s = String::new(); let result = resp.read_to_string(&mut s); if(result.is_ok()) { println!("ok"); } match result { Ok(_) => println!("{:?}", s), Err(e) => {}, ...
code_fim
easy
{ "lang": "rust", "repo": "hitoyozake/Rust_study", "path": "/webrequest/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tooooooooomy/rust-learning-projects path: /generics/src/main.rs use std::fmt::Display; fn main() { let number_list = vec![10, 20, 30, 1000, 40]; let result = largest(&number_list); println!("The largest number: {}", result); let char_list = vec!['y', 'm', 'k', 'a']; let re...
code_fim
hard
{ "lang": "rust", "repo": "tooooooooomy/rust-learning-projects", "path": "/generics/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { x, y } } } impl <T: Display + PartialOrd> Pair<T> { fn cmp_display(&self) { if self.x >= self.y { println!("The largest number is x = {}", self.x); } else { println!("The largest number is y = {}", self.y); } } } fn longer<'a>(x:...
code_fim
hard
{ "lang": "rust", "repo": "tooooooooomy/rust-learning-projects", "path": "/generics/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aloucks/vki path: /src/imp/fence.rs use crate::imp::serial::Serial; use crate::imp::{DeviceInner, FenceInner}; use crate::{Error, Fence, FenceError}; use parking_lot::Mutex; use std::sync::Arc; use std::time::{Duration, Instant}; // TODO: The GPUWeb definition of a Fence seems to be more akin ...
code_fim
hard
{ "lang": "rust", "repo": "aloucks/vki", "path": "/src/imp/fence.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn get_last_completed_serial(device: &DeviceInner) -> Serial { let state = device.state.lock(); state.get_last_completed_serial() } impl Into<Fence> for FenceInner { fn into(self) -> Fence { Fence { inner: self } } }<|fim_prefix|>// repo: aloucks/vki path: /src/imp/fence.rs use c...
code_fim
hard
{ "lang": "rust", "repo": "aloucks/vki", "path": "/src/imp/fence.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sizes = &[80, 30, 60, 50, 70, 20, 40]; let objects = &[32, 64, 48, 16]; let mut heap = Heap::new(sizes); for object in objects { heap.first_fit(*object); } println!("{:?}", heap); let mut heap = Heap::new(sizes); for object in objects { heap.best_fit(*...
code_fim
easy
{ "lang": "rust", "repo": "ivfranco/notes", "path": "/Dragon_Book/chapter_7/free_space/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> let mut heap = Heap::new(sizes); for object in objects { heap.best_fit(*object); } println!("{:?}", heap); }<|fim_prefix|>// repo: ivfranco/notes path: /Dragon_Book/chapter_7/free_space/src/main.rs use free_space::Heap; fn main() { exercise_7_4_1(); } <|fim_middle|>fn exerci...
code_fim
hard
{ "lang": "rust", "repo": "ivfranco/notes", "path": "/Dragon_Book/chapter_7/free_space/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivfranco/notes path: /Dragon_Book/chapter_7/free_space/src/main.rs use free_space::Heap; fn main() { exercise_7_4_1(); } <|fim_suffix|> let sizes = &[80, 30, 60, 50, 70, 20, 40]; let objects = &[32, 64, 48, 16]; let mut heap = Heap::new(sizes); for object in objects { ...
code_fim
easy
{ "lang": "rust", "repo": "ivfranco/notes", "path": "/Dragon_Book/chapter_7/free_space/src/main.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> /* [deprecated] void loadUrl (in nsIURI aURL); */ Method { name: "loadUrl", abi: "C", params: &[Param { name: "aURL", ty: "*const nsIURI" }], ret: "nsresult", ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/bt/nsIExternalProtocolService.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /bt/nsIExternalProtocolService.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIExternalProtocolService.idl // {static D: &'static [Interface] = &[ Interface { name: "nsIExternalProtocolService", base: Some(...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/bt/nsIExternalProtocolService.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* void loadURI (in nsIURI aURI, [optional] in nsIInterfaceRequestor aWindowContext); */ Method { name: "loadURI", abi: "C", params: &[Param { name: "aURI", ty: "*const nsIURI" }, Param { name: ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/bt/nsIExternalProtocolService.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jiayuliu27/rust path: /helloworld.rs fn main() { /// I'm part of documentation but will be ignored by the compiler ////! ``` ////! me too ////! mee too ////! meee too ////! ``` <|fim_suffix|> // As can named arguments. println!("{subject} {verb} {object}", object="t...
code_fim
medium
{ "lang": "rust", "repo": "jiayuliu27/rust", "path": "/helloworld.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // It will even check to make sure the correct number of arguments are // used. println!("My name is {0}, {1} {0}", "Bond", "James"); // FIXME ^ Add the missing argument: "James" // Create a structure which contains an `i32`. Name it `Structure`. #[allow(dead_code)] struct Str...
code_fim
hard
{ "lang": "rust", "repo": "jiayuliu27/rust", "path": "/helloworld.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<VM: VMBinding> Deref for GenCopyNurseryProcessEdges<VM> { type Target = ProcessEdgesBase<Self>; fn deref(&self) -> &Self::Target { &self.base } } impl<VM: VMBinding> DerefMut for GenCopyNurseryProcessEdges<VM> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self...
code_fim
hard
{ "lang": "rust", "repo": "PDFxy/mmtk-core", "path": "/src/plan/gencopy/gc_work.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PDFxy/mmtk-core path: /src/plan/gencopy/gc_work.rs use super::global::GenCopy; use crate::plan::PlanConstraints; use crate::plan::{barriers::BarrierSelector, CopyContext}; use crate::policy::space::Space; use crate::scheduler::gc_work::*; use crate::scheduler::WorkerLocal; use crate::util::alloc...
code_fim
hard
{ "lang": "rust", "repo": "PDFxy/mmtk-core", "path": "/src/plan/gencopy/gc_work.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.plan } } impl<VM: VMBinding> ProcessEdgesWork for GenCopyMatureProcessEdges<VM> { type VM = VM; fn new(edges: Vec<Address>, _roots: bool, mmtk: &'static MMTK<VM>) -> Self { let base = ProcessEdgesBase::new(edges, mmtk); let plan = base.plan().downcast_ref::<GenCop...
code_fim
hard
{ "lang": "rust", "repo": "PDFxy/mmtk-core", "path": "/src/plan/gencopy/gc_work.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Dereference the pointer to get the pointer to the data // // ```c // data_ptr:*const T: = *data_ptr_ptr; // ``` builder .build_load(self.0, &format!("{}->data", &value_name)) .into_pointer_value() } /// Returns the type of...
code_fim
hard
{ "lang": "rust", "repo": "mun-lang/mun", "path": "/crates/mun_codegen/src/ir/reference.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mun-lang/mun path: /crates/mun_codegen/src/ir/reference.rs use inkwell::builder::Builder; use inkwell::types::{BasicType, BasicTypeEnum}; use inkwell::values::{BasicValueEnum, PointerValue}; use inkwell::AddressSpace; use std::ffi::CStr; /// A helper struct that wraps an object on the heap. ///...
code_fim
hard
{ "lang": "rust", "repo": "mun-lang/mun", "path": "/crates/mun_codegen/src/ir/reference.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<MSG> Special for Element<MSG> { fn get_value<'a>(&'a self, att_name: &'static str) -> Option<&'a Value> { self.get_attribute_value(&att_name) .map(|att_values| { att_values.first().map(|v| v.get_simple()).flatten() }) .flatten() } } ...
code_fim
hard
{ "lang": "rust", "repo": "ChMarP/sauron", "path": "/crates/sauron-core/src/html/attributes/special.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// key attributes is used to match /// old element and new element when diffing pub fn key<V, MSG>(v: V) -> Attribute<MSG> where V: Into<Value>, { attr("key", v) } /// if the value is true, then the diffing of this element /// and its descendants are skip entirely pub fn skip<MSG>(v: bool) -> At...
code_fim
hard
{ "lang": "rust", "repo": "ChMarP/sauron", "path": "/crates/sauron-core/src/html/attributes/special.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChMarP/sauron path: /crates/sauron-core/src/html/attributes/special.rs //! special attributes which is treated differently //! //! use super::{attr, Attribute, Value}; use crate::{Element, Node}; /// Special Node attributes that are treated differently /// such as key and skip which both greatl...
code_fim
hard
{ "lang": "rust", "repo": "ChMarP/sauron", "path": "/crates/sauron-core/src/html/attributes/special.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: infoverload/prisma-engine path: /libs/datamodel/src/dml/validator/directive/mod.rs use crate::ast; use crate::common; use crate::common::argument::Arguments; use crate::dml; use crate::errors::{ErrorCollection, ValidationError}; // BTreeMap has a strictly defined order. // That's important sinc...
code_fim
hard
{ "lang": "rust", "repo": "infoverload/prisma-engine", "path": "/libs/datamodel/src/dml/validator/directive/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// For each directive in the given object, picks the correct /// directive definition and uses it to validate and apply the directive. pub fn validate_and_apply(&self, ast: &dyn ast::WithDirectives, t: &mut T) -> Result<(), ErrorCollection> { let mut errors = ErrorCollection::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "infoverload/prisma-engine", "path": "/libs/datamodel/src/dml/validator/directive/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> while pos < length { if filtered[pos] == 0x7A { // z special case result.push(0x0); result.push(0x0); result.push(0x0); result.push(0x0); pos += 1; continue; } let bytes_left = if (length - pos...
code_fim
hard
{ "lang": "rust", "repo": "nigelkerr/parsepdf", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nigelkerr/parsepdf path: /src/parser.rs ) => { Ok((rest, stream_bytes.to_vec())) } Err(err) => Err(err), } } pub fn recognize_pdf_stream(i: &[u8]) -> IResult<&[u8], PdfObject> { match recognize_pdf_dictionary(i) { Ok((rest, PdfObject::Dictionary(dicti...
code_fim
hard
{ "lang": "rust", "repo": "nigelkerr/parsepdf", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( Err(nom::Err::Error(( b"0000000001 00002 n \n0000000099 00006 n \n0000000999 00008 n \n".as_bytes(), nom::error::ErrorKind::ManyMN ))), recognize_pdf_cross_reference_subsection( b"5 4\n0000000001 00002 ...
code_fim
hard
{ "lang": "rust", "repo": "nigelkerr/parsepdf", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PSeitz/nushell path: /src/commands/histogram.rs use crate::commands::evaluate_by::evaluate; use crate::commands::group_by::group; use crate::commands::map_max_by::map_max; use crate::commands::reduce_by::reduce; use crate::commands::t_sort_by::columns_sorted; use crate::commands::t_sort_by::t_so...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/nushell", "path": "/src/commands/histogram.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut fact = TaggedDictBuilder::new(&name); let value: Tagged<String> = group_labels.get(idx).unwrap().clone(); fact.insert_tagged(&column, Value::string(value.item).tagged(value.tag)); if let Tagged { item:...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/nushell", "path": "/src/commands/histogram.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let n = { n.to_i32().unwrap() * 100 / max }; Value::number(n).tagged(&tag) } _ => Value::number(0).tagged(&tag), }) ...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/nushell", "path": "/src/commands/histogram.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/mio-0.7.11/src/net/tcp/mod.rs mod listener; pub use self::listener::TcpListener; <|fim_suffix|>mod stream; pub use self::stream::TcpStream;<|fim_middle|>mod socket; pub use self::socket::{TcpSocket, TcpKeepalive};
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/mio-0.7.11/src/net/tcp/mod.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }