text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> fn convert_scancode( &self, scancode_option: Option<sdl2::keyboard::Scancode>, shift: bool, ) -> Option<(char, u8)> { if let Some(scancode) = scancode_option { match scancode { sdl2::keyboard::Scancode::A => Some((if shift { 'A' } else { ...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/orbclient", "path": "/src/sys/sdl2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redox-os/orbclient path: /src/sys/sdl2.rs tr::null_mut(); /// Video Context static mut VIDEO_CTX: *mut sdl2::VideoSubsystem = ptr::null_mut(); /// Event Pump static mut EVENT_PUMP: *mut sdl2::EventPump = ptr::null_mut(); //Call this when the CTX needs to be used is created #[inline] unsafe fn i...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/orbclient", "path": "/src/sys/sdl2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redox-os/orbclient path: /src/sys/sdl2.rs DL_USAGES: AtomicUsize = AtomicUsize::new(0); /// SDL2 Context static mut SDL_CTX: *mut sdl2::Sdl = ptr::null_mut(); /// Video Context static mut VIDEO_CTX: *mut sdl2::VideoSubsystem = ptr::null_mut(); /// Event Pump static mut EVENT_PUMP: *mut sdl2::Eve...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/orbclient", "path": "/src/sys/sdl2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(FromStr)] #[adhoc(regex = r"^#(?P<id>\d+) @ (?P<rect>.+)$")] struct OuterRectangle { id: usize, rect: InnerRectangle, } let rect: OuterRectangle = "#123 @ 3,2: 5x4".parse().unwrap(); assert_eq!(123, rect.id); assert_eq!(3, rect.rect.x); assert_eq!(...
code_fim
hard
{ "lang": "rust", "repo": "df5602/adhoc_derive", "path": "/tests/structs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: df5602/adhoc_derive path: /tests/structs.rs extern crate adhoc_derive; use adhoc_derive::FromStr; #[test] fn derive_standard_struct() { #[derive(FromStr)] #[adhoc(regex = r"^#(?P<id>\d+) @ (?P<x>\d+),(?P<y>\d+): (?P<width>\d+)x(?P<height>\d+)$")] struct Rectangle { id: usiz...
code_fim
medium
{ "lang": "rust", "repo": "df5602/adhoc_derive", "path": "/tests/structs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: patrickbiel01/libra path: /ol/zero_knowledge/rust-ethereum-abi-0.1.0/src/lib.rs //! Ethereum Smart Contracts ABI (abstract binary interface) utility library. <|fim_suffix|>pub use abi::*; pub use params::*; pub use types::*; pub use values::*;<|fim_middle|>mod abi; mod params; mod types; mod va...
code_fim
easy
{ "lang": "rust", "repo": "patrickbiel01/libra", "path": "/ol/zero_knowledge/rust-ethereum-abi-0.1.0/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use abi::*; pub use params::*; pub use types::*; pub use values::*;<|fim_prefix|>// repo: patrickbiel01/libra path: /ol/zero_knowledge/rust-ethereum-abi-0.1.0/src/lib.rs //! Ethereum Smart Contracts ABI (abstract binary interface) utility library. <|fim_middle|>mod abi; mod params; mod types; mod va...
code_fim
easy
{ "lang": "rust", "repo": "patrickbiel01/libra", "path": "/ol/zero_knowledge/rust-ethereum-abi-0.1.0/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(test)] mod tests { use super::*; #[test] fn test_sorted_squares() { let tests = vec![ (vec![-4, -1, 0, 3, 10], vec![0, 1, 9, 16, 100]), (vec![-7, -3, 2, 3, 11], vec![4, 9, 9, 49, 121]), ]; for (input, expected) in tests { assert_eq!(expected, sorted_squares_nai...
code_fim
hard
{ "lang": "rust", "repo": "PoorlyDefinedBehaviour/data-structures-and-algorithms", "path": "/rust/algorithms/others/squares_of_a_sorted_array/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tests = vec![ (vec![-4, -1, 0, 3, 10], vec![0, 1, 9, 16, 100]), (vec![-7, -3, 2, 3, 11], vec![4, 9, 9, 49, 121]), ]; for (input, expected) in tests { assert_eq!(expected, sorted_squares_naive(input.clone())); assert_eq!(expected, sorted_squares(input)); } } }...
code_fim
hard
{ "lang": "rust", "repo": "PoorlyDefinedBehaviour/data-structures-and-algorithms", "path": "/rust/algorithms/others/squares_of_a_sorted_array/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PoorlyDefinedBehaviour/data-structures-and-algorithms path: /rust/algorithms/others/squares_of_a_sorted_array/main.rs // 977. Squares of a Sorted Array // // Given an integer array nums sorted in non-decreasing order, // return an array of the squares of each number sorted in non-decreasing orde...
code_fim
hard
{ "lang": "rust", "repo": "PoorlyDefinedBehaviour/data-structures-and-algorithms", "path": "/rust/algorithms/others/squares_of_a_sorted_array/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jcaromiq/codewars-katas-rust path: /src/mexican_wave.rs // https://www.codewars.com/kata/58f5c63f1e26ecda7e000029/train/rust fn wave(s: &str) -> Vec<String> { let mut result = vec![]; for n in 1..s.len() { let r = s.chars() .map(|(i, c)| { if i == n {...
code_fim
hard
{ "lang": "rust", "repo": "jcaromiq/codewars-katas-rust", "path": "/src/mexican_wave.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let expect = ["Codewars", "cOdewars", "coDewars", "codEwars", "codeWars", "codewArs", "codewaRs", "codewarS"]; assert_eq!(wave("codewars"), expect); let expect: [&str; 0] = []; assert_eq!(wave(""), expect); let expect = ["Two words", "tWo words", "twO words", "two...
code_fim
medium
{ "lang": "rust", "repo": "jcaromiq/codewars-katas-rust", "path": "/src/mexican_wave.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: smokku/emerald path: /src/rendering/texture.rs use crate::rendering::font::*; use crate::rendering::shaders::*; use crate::*; use glam::Vec2; use miniquad::{Bindings, Buffer, BufferType, Context, FilterMode}; use std::sync::Arc; pub const EMERALD_DEFAULT_TEXTURE_NAME: &str = "emerald_default_te...
code_fim
hard
{ "lang": "rust", "repo": "smokku/emerald", "path": "/src/rendering/texture.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let width = img.width() as u16; let height = img.height() as u16; let bytes = img.into_raw(); Self::from_rgba8(ctx, key, width, height, &bytes) } pub(crate) fn from_rgba8( mut ctx: &mut Context, key: TextureKey, width: u16, height: ...
code_fim
hard
{ "lang": "rust", "repo": "smokku/emerald", "path": "/src/rendering/texture.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Devolutions/sarpine-rs path: /sarpine/src/messages/srp_initiate.rs use std::io::{Read, Write, Error}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use super::*; pub struct SrpInitiate { pub prime_size: u16, pub hash_type: u16, pub reserved: u32, pub username: (u1...
code_fim
medium
{ "lang": "rust", "repo": "Devolutions/sarpine-rs", "path": "/sarpine/src/messages/srp_initiate.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(SrpInitiate { prime_size, hash_type, reserved, username: (username_len, username_buf), a_pub: (a_pub_size, a_pub_buf) }) } fn write_to<W: Write>(&self, writer: &mut W) -> Result<(), SrpErr> { writer.write_u16::...
code_fim
hard
{ "lang": "rust", "repo": "Devolutions/sarpine-rs", "path": "/sarpine/src/messages/srp_initiate.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> f }) } assert_eq!(mylambda_tt!(y, y * 2)(8), 16); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/macros/macro-2.rs // run-pass pub fn main() { <|fim_middle|> macro_rules! mylambda_tt { ($x:ident, $body:expr) => ({ fn f($x: i...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/macros/macro-2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/macros/macro-2.rs // run-pass pub fn main() { <|fim_suffix|> f }) } assert_eq!(mylambda_tt!(y, y * 2)(8), 16); }<|fim_middle|> macro_rules! mylambda_tt { ($x:ident, $body:expr) => ({ fn f($x: i...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/macros/macro-2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timoschuetz/cloud-connector-prometheus path: /src/checks/availability.rs use std::sync::mpsc; use std::net::Ipv4Addr; use std::time::Duration; use log::{info,warn,debug,error}; use crate::models; use models::global::Instance; use models::availability::{Status, URLAvailability}; <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "timoschuetz/cloud-connector-prometheus", "path": "/src/checks/availability.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut result = URLAvailability { instance, status: Status::Offline, }; // Initialize blocking client let client = reqwest::blocking::Client::builder().timeout(Duration::from_millis(500)).danger_accept_invalid_certs(true); match client.bui...
code_fim
hard
{ "lang": "rust", "repo": "timoschuetz/cloud-connector-prometheus", "path": "/src/checks/availability.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, v...
code_fim
hard
{ "lang": "rust", "repo": "9ary/rp2040-pac", "path": "/src/usbctrl_regs/sie_status.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>er_curr(&self) -> VBUS_OVER_CURR_R { VBUS_OVER_CURR_R::new(((self.bits >> 10) & 0x01) != 0) } #[doc = "Bits 8:9 - Host: device speed. Disconnected = 00, LS = 01, FS = 10"] #[inline(always)] pub fn speed(&self) -> SPEED_R { SPEED_R::new(((self.bits >> 8) & 0x03) as u8) }...
code_fim
hard
{ "lang": "rust", "repo": "9ary/rp2040-pac", "path": "/src/usbctrl_regs/sie_status.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 9ary/rp2040-pac path: /src/usbctrl_regs/sie_status.rs ; #[doc = "Register SIE_STATUS `reset()`'s with value 0"] impl crate::ResetValue for super::SIE_STATUS { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Reader of field `DATA_SEQ_ERRO...
code_fim
hard
{ "lang": "rust", "repo": "9ary/rp2040-pac", "path": "/src/usbctrl_regs/sie_status.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: morr0ne/neo-mime path: /src/range.rs use std::fmt; use std::str::FromStr; use neo_mime_parse::{Mime, Parse}; use crate::{InvalidMime, MediaType, Value}; /// A parsed media range used to match media types. /// /// Commonly found in the HTTP `Accept` header, these are used for agents /// to ind...
code_fim
hard
{ "lang": "rust", "repo": "morr0ne/neo-mime", "path": "/src/range.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> MediaRange::parse(s) } } impl AsRef<str> for MediaRange { fn as_ref(&self) -> &str { self.mime.as_ref() } } impl fmt::Debug for MediaRange { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&self.mime, f) } } impl fmt::Disp...
code_fim
hard
{ "lang": "rust", "repo": "morr0ne/neo-mime", "path": "/src/range.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kamiyaa/JaneStreet-rs path: /src/main.rs use std::io::{BufRead, Write}; use std::net::TcpStream; use std::collections::HashMap; use serde_json::json; use serde_derive::{Serialize, Deserialize}; // for telling the server your input is complete const EOF: &[u8; 1] = &['\n' as u8]; const TEAM_NA...
code_fim
hard
{ "lang": "rust", "repo": "kamiyaa/JaneStreet-rs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn connect() -> std::io::Result<TcpStream> { let mut exchange = TcpStream::connect(CURRENT_HOSTNAME)?; Ok(exchange) } fn say_hello(exchange: &mut TcpStream) -> std::io::Result<PortFolio> { let json_1 = json!({ "type": "hello", "team": TEAM_NAME, }); exchange.write_all(...
code_fim
hard
{ "lang": "rust", "repo": "kamiyaa/JaneStreet-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn say_hello(exchange: &mut TcpStream) -> std::io::Result<PortFolio> { let json_1 = json!({ "type": "hello", "team": TEAM_NAME, }); exchange.write_all(json_1.to_string().as_bytes())?; exchange.write(EOF)?; let mut reader = std::io::BufReader::new(exchange); let mut...
code_fim
hard
{ "lang": "rust", "repo": "kamiyaa/JaneStreet-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mayamaclean/rocket_diesel path: /src/models.rs #![allow(proc_macro_derive_resolution_fallback)] use super::*; use super::schema::*; <|fim_suffix|>#[derive(Insertable)] #[table_name="entries"] pub struct NewEntry<'a> { pub opt: &'a str, pub num: std::time::SystemTime, pub hash: &'a ...
code_fim
medium
{ "lang": "rust", "repo": "mayamaclean/rocket_diesel", "path": "/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Queryable)] #[derive(Serialize)] pub struct Entry { pub id: i32, pub opt: Option<String>, pub num: std::time::SystemTime, pub hash: String, } #[derive(Insertable)] #[table_name="entries"] pub struct NewEntry<'a> { pub opt: &'a str, pub num: std::time::SystemTime, pub ...
code_fim
easy
{ "lang": "rust", "repo": "mayamaclean/rocket_diesel", "path": "/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let resp = client .get(&uri) .basic_auth( state.active_cluster().username(), Some(state.active_cluster().password()), ) .send() .await .unwrap() .json::<Vec<BucketInfo>>() .await .unwrap(); let buckets...
code_fim
hard
{ "lang": "rust", "repo": "griels/couchbase-shell-1", "path": "/src/cli/buckets.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: griels/couchbase-shell-1 path: /src/cli/buckets.rs use crate::state::State; use futures::executor::block_on; use nu_cli::{CommandArgs, CommandRegistry, OutputStream}; use nu_errors::ShellError; use nu_protocol::{Signature, TaggedDictBuilder}; use nu_source::Tag; use serde::Deserialize; use std::...
code_fim
medium
{ "lang": "rust", "repo": "griels/couchbase-shell-1", "path": "/src/cli/buckets.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, _args: CommandArgs, _registry: &CommandRegistry, ) -> Result<OutputStream, ShellError> { block_on(buckets(self.state.clone())) } } async fn buckets(state: Arc<State>) -> Result<OutputStream, ShellError> { let client = reqwest::Client::new(); // todo...
code_fim
medium
{ "lang": "rust", "repo": "griels/couchbase-shell-1", "path": "/src/cli/buckets.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Murzaza/note-app-rs path: /src/data.rs pub mod models; pub mod schema; use dotenv::dotenv; use std::env; use diesel::prelude::*; <|fim_suffix|>pub fn establish_connection() -> SqliteConnection { if cfg!(test) { let conn = SqliteConnection::establish(":memory:").unwrap_or_else(|_| p...
code_fim
medium
{ "lang": "rust", "repo": "Murzaza/note-app-rs", "path": "/src/data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> SqliteConnection::establish(&database_url).unwrap_or_else(|_| panic!("Error creating db: {}!", database_url)) } }<|fim_prefix|>// repo: Murzaza/note-app-rs path: /src/data.rs pub mod models; pub mod schema; use dotenv::dotenv; use std::env; use diesel::prelude::*; embed_migrations!(); pub ...
code_fim
medium
{ "lang": "rust", "repo": "Murzaza/note-app-rs", "path": "/src/data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 95th/torrent-rs path: /dht/tests/test_dht_storage.rs use dht::settings::DhtSettings; <|fim_suffix|> let mut settings = DhtSettings::default(); settings.max_torrents = 2; settings.max_dht_items = 2; settings.item_lifetime = 120 * 60; settings }<|fim_middle|>fn test_settings() ...
code_fim
easy
{ "lang": "rust", "repo": "95th/torrent-rs", "path": "/dht/tests/test_dht_storage.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut settings = DhtSettings::default(); settings.max_torrents = 2; settings.max_dht_items = 2; settings.item_lifetime = 120 * 60; settings }<|fim_prefix|>// repo: 95th/torrent-rs path: /dht/tests/test_dht_storage.rs use dht::settings::DhtSettings; <|fim_middle|>fn test_settings() ...
code_fim
easy
{ "lang": "rust", "repo": "95th/torrent-rs", "path": "/dht/tests/test_dht_storage.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boneyard93501/rust-peer path: /particle-behaviour/src/behaviour.rs /* * Copyright 2020 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * ...
code_fim
hard
{ "lang": "rust", "repo": "boneyard93501/rust-peer", "path": "/particle-behaviour/src/behaviour.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl ParticleBehaviour { pub fn new( config: ParticleConfig, trust_graph: TrustGraph, registry: Option<&Registry>, ) -> anyhow::Result<Self> { let services = ParticleAppServices::new(config.services_config()?); let mailbox = Mailbox::new(); let provi...
code_fim
hard
{ "lang": "rust", "repo": "boneyard93501/rust-peer", "path": "/particle-behaviour/src/behaviour.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut syst = cp.SYST; syst.disable_counter(); syst.set_reload(0); syst.disable_interrupt(); } } fn rcc_deinit(rcc: RCC){ let mut timeout: u8 = 0; /* Set HSION bit, HSITRIM[4:0] bits to the reset value*/ rcc.cr.modify(|_, w| w.hsion().on().hsitrim().bits...
code_fim
hard
{ "lang": "rust", "repo": "vhrdtech/vhrd-bootloader", "path": "/src/peripherals/stm32f0xx/stm32f0_peripherals.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vhrdtech/vhrd-bootloader path: /src/peripherals/stm32f0xx/stm32f0_peripherals.rs use cfg_if::cfg_if; use stm32f0xx_hal as hal; use hal::{ stm32, delay::Delay, pac, }; use cortex_m::interrupt::{CriticalSection}; use stm32f0xx_hal::stm32::RCC; use stm32f0xx_hal::{ gpio::gpioa::{PA...
code_fim
hard
{ "lang": "rust", "repo": "vhrdtech/vhrd-bootloader", "path": "/src/peripherals/stm32f0xx/stm32f0_peripherals.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> rcc.apb1enr.modify(|_, w| w.canen().enabled()); // can time enb rcc.apb2enr.modify(|_, w| w.syscfgen().enabled()); let mut clock = rcc .configure() .sysclk(8.mhz()) .freeze(&mut dp.FLASH); let gpioa = dp.GPIOA.split(&mut clock); let gpiob = dp.GPIOB.split(&mut...
code_fim
hard
{ "lang": "rust", "repo": "vhrdtech/vhrd-bootloader", "path": "/src/peripherals/stm32f0xx/stm32f0_peripherals.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tomgrean/stardict path: /src/dictionary.rs extern crate regex; use std::cmp::Ordering; use std::{borrow::Cow, fs, path, str}; use self::regex::bytes::Regex; use self::regex::Error; use super::dict::Dict; use super::idx::Idx; use super::ifo::Ifo; use super::result::DictError; use super::syn::Sy...
code_fim
hard
{ "lang": "rust", "repo": "tomgrean/stardict", "path": "/src/dictionary.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// search Idx by regular expression pub fn search(&self, expr: &[u8]) -> Result<IdxIter, Error> { match str::from_utf8(expr) { Ok(e) => { let reg = Regex::new(e)?; Ok(IdxIter { cur: 0, idx: IdxRef::Ref(&se...
code_fim
hard
{ "lang": "rust", "repo": "tomgrean/stardict", "path": "/src/dictionary.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GeneFerneau/mpecdsa path: /src/state_machine/sign.rs re)?; next_state = round .proceed(msgs, &mut self.msgs_queue) .map(OfflineR::R4) .map_err(Error::ProceedRound)?; true } s @ Off...
code_fim
hard
{ "lang": "rust", "repo": "GeneFerneau/mpecdsa", "path": "/src/state_machine/sign.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.party_i } fn parties(&self) -> u16 { self.party_n } } impl super::traits::RoundBlame for OfflineStage { /// RoundBlame returns number of unwilling parties and a vector of their party indexes. fn round_blame(&self) -> (u16, Vec<u16>) { let store1_blame = s...
code_fim
hard
{ "lang": "rust", "repo": "GeneFerneau/mpecdsa", "path": "/src/state_machine/sign.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GeneFerneau/mpecdsa path: /src/state_machine/sign.rs xt_state: OfflineR; let try_again: bool = match replace(&mut self.round, OfflineR::Gone) { OfflineR::R0(round) if !round.is_expensive() || may_block => { next_state = round .proceed(&mut ...
code_fim
hard
{ "lang": "rust", "repo": "GeneFerneau/mpecdsa", "path": "/src/state_machine/sign.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: poljar/weechat-matrix-rs path: /src/commands/mod.rs use clap::{App, ArgMatches}; use weechat::{ hooks::{Command, CommandRun}, Args, Weechat, }; use crate::{config::ConfigHandle, Servers}; mod buffer_clear; mod devices; mod keys; mod matrix; mod page_up; use buffer_clear::BufferClearCo...
code_fim
medium
{ "lang": "rust", "repo": "poljar/weechat-matrix-rs", "path": "/src/commands/mod.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> parser: App, arguments: Args, command: impl FnOnce(&ArgMatches), ) { match parser.get_matches_from_safe(arguments) { Ok(m) => command(&m), Err(e) => { let error = Weechat::execute_modifier( "color_decode_ansi", "1", ...
code_fim
hard
{ "lang": "rust", "repo": "poljar/weechat-matrix-rs", "path": "/src/commands/mod.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: antimonyproject/antimony-core path: /src/core/stream_manager/mod.rs use utils::storage::Storage; use std::net::ToSocketAddrs; use futures::{Future, future, Stream, self}; use tokio_uds::{UnixListener, UnixStream}; use tokio_core::net::{TcpListener, TcpStream}; use tokio_io::AsyncRead; use tokio_...
code_fim
hard
{ "lang": "rust", "repo": "antimonyproject/antimony-core", "path": "/src/core/stream_manager/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> h.spawn(uds); }, futures::stream::MergedItem::Both(_, _) => {} }; Ok(()) }); self.storage.register_sm(tcp_addr, self.physical_plan.self_id); let pool = CpuPool::new_num_cpus(); let storage = self.s...
code_fim
hard
{ "lang": "rust", "repo": "antimonyproject/antimony-core", "path": "/src/core/stream_manager/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn start() { let mut router = Router::new(); router.get("/hello", routes::say_hello, "hello"); let mut mount = Mount::new(); mount.mount("/", Static::new(Path::new("public"))); mount.mount("/api/", router); let server = Iron::new(mount).http("localhost:3000").unwrap(); }<|fim_p...
code_fim
medium
{ "lang": "rust", "repo": "anon4284/portfolio", "path": "/src/server/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn start() { let mut router = Router::new(); router.get("/hello", routes::say_hello, "hello"); let mut mount = Mount::new(); mount.mount("/", Static::new(Path::new("public"))); mount.mount("/api/", router); let server = Iron::new(mount).http("localhost:3000").unwrap(); }<|fim_...
code_fim
medium
{ "lang": "rust", "repo": "anon4284/portfolio", "path": "/src/server/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anon4284/portfolio path: /src/server/mod.rs extern crate iron; extern crate router; extern crate staticfile; extern crate mount; <|fim_suffix|>mod routes; pub fn start() { let mut router = Router::new(); router.get("/hello", routes::say_hello, "hello"); let mut mount = Mount::new(...
code_fim
medium
{ "lang": "rust", "repo": "anon4284/portfolio", "path": "/src/server/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let current_state = self.is_active(); self.set_is_concealing(!current_state); self.button.on_click(clicked_on); } fn get_cursor_on_hover(&self, pos: Vector) -> quicksilver::CursorIcon { self.button.get_cursor_on_hover(pos) } } impl Concealer { fn is_active(...
code_fim
hard
{ "lang": "rust", "repo": "lenscas/mergui", "path": "/src/widgets/concealer.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> self.button.contains(point) } fn is_focusable(&self, _: Vector) -> bool { false } fn set_hover(&mut self, location: Vector, hover: bool) { self.button.set_hover(location, hover); } fn render(&mut self, gfx: &mut Graphics, w: &Window) -> Result<()> { ...
code_fim
hard
{ "lang": "rust", "repo": "lenscas/mergui", "path": "/src/widgets/concealer.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lenscas/mergui path: /src/widgets/concealer.rs use super::{button::Button, ButtonConfig, Widget, WidgetConfig}; use crate::{channels::concealer::ConcealerReturn, SingularLayerId}; use quicksilver::graphics::Graphics; use quicksilver::{geom::Vector, Result, Window}; //use quicksilver::prelude::{...
code_fim
hard
{ "lang": "rust", "repo": "lenscas/mergui", "path": "/src/widgets/concealer.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/tokio/src/runtime/tests/loom_local.rs use crate::runtime::tests::loom_oneshot as oneshot; use crate::runtime::Builder; use crate::task::LocalSet; use std::task::Poll; #[test] fn wake_during_shutdown() { <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/tokio/src/runtime/tests/loom_local.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> loom::model(|| { let rt = Builder::new_current_thread().build().unwrap(); let ls = LocalSet::new(); let (send, recv) = oneshot::channel(); ls.spawn_local(async move { let mut send = Some(send); let () = futures::future::poll_fn(|cx| { ...
code_fim
medium
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/tokio/src/runtime/tests/loom_local.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarberd/formally-cool path: /classy/src/classy.rs Some(rhs_id) => { if self .id_to_dfa .conta...
code_fim
hard
{ "lang": "rust", "repo": "tarberd/formally-cool", "path": "/classy/src/classy.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if tokens.len() != 0 { match tokens[0] { "help" => Classy::help(), "exit" => std::process::exit(0), "let" => { self.parse_expression(&tokens[1..tokens.len()]); } "write" => match tokens....
code_fim
hard
{ "lang": "rust", "repo": "tarberd/formally-cool", "path": "/classy/src/classy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarberd/formally-cool path: /classy/src/classy.rs &rhs_id.to_string()) { Some(rg) => { let nfa = NondeterministicFiniteAutomata::from(rg); println!("{}", nf...
code_fim
hard
{ "lang": "rust", "repo": "tarberd/formally-cool", "path": "/classy/src/classy.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: afaber999/dicom-pipe path: /dcmpipe_dict/src/dict/tags.rs ident: "SpatialFrequencyResponseRows", tag: 0x0016_000A, implicit_vr: Some(&vr::IS), vm: &VM::Distinct(1), desc: "Spatial Frequency Response Rows", }; /// Spatial Frequency Response Columns /// /// - **Tag:** (0016,000B)...
code_fim
hard
{ "lang": "rust", "repo": "afaber999/dicom-pipe", "path": "/dcmpipe_dict/src/dict/tags.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: afaber999/dicom-pipe path: /dcmpipe_dict/src/dict/tags.rs CS), vm: &VM::Distinct(1), desc: "Source Applicator Type", }; /// Source Applicator Name /// /// - **Tag:** (300A,0294) /// - **VR:** LO /// - **VM:** 1 pub static SourceApplicatorName: Tag = Tag { ident: "SourceApplicatorNam...
code_fim
hard
{ "lang": "rust", "repo": "afaber999/dicom-pipe", "path": "/dcmpipe_dict/src/dict/tags.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Component 1 Referenced Mating Feature ID /// /// - **Tag:** (0076,0090) /// - **VR:** US /// - **VM:** 1 pub static Component1ReferencedMatingFeatureID: Tag = Tag { ident: "Component1ReferencedMatingFeatureID", tag: 0x0076_0090, implicit_vr: Some(&vr::US), vm: &VM::Distinct(1), des...
code_fim
hard
{ "lang": "rust", "repo": "afaber999/dicom-pipe", "path": "/dcmpipe_dict/src/dict/tags.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>dlers: LogHandler = Box::new(ParallelHandlers::new(Vec::from([file_handler, console_handler]))); return Box::new(StringLogger::new(parallel_handlers)); } }<|fim_prefix|>// repo: gprearo/plumbing-rs path: /examples/logger/logger/logger_factory_1.rs use super::{Logger, FileLogger, ConsoleLogger...
code_fim
hard
{ "lang": "rust", "repo": "gprearo/plumbing-rs", "path": "/examples/logger/logger/logger_factory_1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gprearo/plumbing-rs path: /examples/logger/logger/logger_factory_1.rs use super::{Logger, FileLogger, ConsoleLogger, LogData, StringLogger}; use plumbing::action::handler::{ParallelHandlers, Handler}; pub struct App1LoggerFactory {} impl App1LoggerFactory { pub fn get_logger() -> Box<dyn Lo...
code_fim
medium
{ "lang": "rust", "repo": "gprearo/plumbing-rs", "path": "/examples/logger/logger/logger_factory_1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (mut server, mut event_loop) = server(&args); let actions = server.consensus.init(); server.execute_actions(&mut event_loop, actions); server.set_pub(tx_pub); let eventloop_notifix = event_loop.channel(); thread_handler(rx, eventloop_notifix); event_loop.run(&mut server); }...
code_fim
hard
{ "lang": "rust", "repo": "gokzrlp/Sushumna", "path": "/consensus/raft/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gokzrlp/Sushumna path: /consensus/raft/main.rs // sushumna // Copyright 2016-2017 Cryptape Technologies LLC. // This program is free software: you can redistribute it // and/or modify it under the terms of the GNU General Public // License as published by the Free Software Foundation, // either...
code_fim
hard
{ "lang": "rust", "repo": "gokzrlp/Sushumna", "path": "/consensus/raft/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Each register server holds a replica of the map, and coordinates with its peers to update the maps values according to client commands. The register is available for reading and writing only if a majority of register servers are available. Commands: server Starts a key server. Servers must be provid...
code_fim
hard
{ "lang": "rust", "repo": "gokzrlp/Sushumna", "path": "/consensus/raft/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PatatasDelPapa/axum_playground path: /src/types/handler_types.rs use serde::{Deserialize, Serialize}; use uuid::Uuid; #[derive(Debug, Serialize, Clone)] pub struct Todo { pub id: Uuid, pub title: String, pub text: String, pub completed: bool, } <|fim_suffix|>// The query parame...
code_fim
hard
{ "lang": "rust", "repo": "PatatasDelPapa/axum_playground", "path": "/src/types/handler_types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// The query parameters for todo index #[derive(Debug, Deserialize, Default)] pub struct Pagination { pub offset: Option<usize>, pub limit: Option<usize>, }<|fim_prefix|>// repo: PatatasDelPapa/axum_playground path: /src/types/handler_types.rs use serde::{Deserialize, Serialize}; use uuid::Uuid; ...
code_fim
hard
{ "lang": "rust", "repo": "PatatasDelPapa/axum_playground", "path": "/src/types/handler_types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anasahmed700/Rust-examples path: /ch04.3_slice_type/src/main.rs fn main() { let name = String::from("Anas Ahmed"); let fname = &name[0..4]; // [start..end] range syntax let lname = &name[5..]; println!("{} {}", fname, lname); <|fim_suffix|>} fn first_word(s: &str) -> &str{ ...
code_fim
hard
{ "lang": "rust", "repo": "anasahmed700/Rust-examples", "path": "/ch04.3_slice_type/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} fn first_word(s: &str) -> &str{ let bytes = s.as_bytes(); for (i, &item) in bytes.iter().enumerate() { if item == b' ' { return &s[0..i]; } } &s[..] }<|fim_prefix|>// repo: anasahmed700/Rust-examples path: /ch04.3_slice_type/src/main.rs fn main() { let ...
code_fim
hard
{ "lang": "rust", "repo": "anasahmed700/Rust-examples", "path": "/ch04.3_slice_type/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, ( player, read_shapes, mut write_maybe_selected, mut write_draw_line_collection, ): Self::SystemData, ) { if let Some(MaybeSelected(Some(selected))) = write_maybe_selected.get_mut(player.0) { self.0....
code_fim
hard
{ "lang": "rust", "repo": "akuczala/4d-game", "path": "/src/input/systems.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akuczala/4d-game path: /src/input/systems.rs use glium::backend::glutin::headless; use specs::prelude::*; use std::marker::PhantomData; use crate::cleanup::DeletedEntities; use crate::config::Config; use crate::ecs_utils::ModSystem; use crate::{components::*, config}; use crate::{ecs_utils::Com...
code_fim
hard
{ "lang": "rust", "repo": "akuczala/4d-game", "path": "/src/input/systems.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quasor/makepad path: /makepad/hub/src/hubserver.rs ientType{ Unknown, Workspace(String), Clone(String), UI } pub struct HubServerConnection { peer_addr: HubAddr, tx_write: mpsc::Sender<HubToClientMsg>, tcp_stream: TcpStream, client_type: HubClientType } pub stru...
code_fim
hard
{ "lang": "rust", "repo": "quasor/makepad", "path": "/makepad/hub/src/hubserver.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quasor/makepad path: /makepad/hub/src/hubserver.rs &key, SocketAddr::from(([0, 0, 0, 0], 0)), hub_log ) } pub fn start_hub_server(key: &[u8], listen_address: SocketAddr, hub_log:HubLog) -> HubServer { let listener = TcpLi...
code_fim
hard
{ "lang": "rust", "repo": "quasor/makepad", "path": "/makepad/hub/src/hubserver.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match to { HubMsgTo::All => { // send it to all for connection in connections.iter() { if connection.client_type != HubClientType::Unknown { conne...
code_fim
hard
{ "lang": "rust", "repo": "quasor/makepad", "path": "/makepad/hub/src/hubserver.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> GetModuleHandleA, }, }, ); }<|fim_prefix|>// repo: OnePercent418/windows-samples-rs path: /create_window/bindings/build.rs fn main() { windows::build!( Windows::Win32::{ Foundation::*, Graphics::Gdi::ValidateRect, <|fim_...
code_fim
hard
{ "lang": "rust", "repo": "OnePercent418/windows-samples-rs", "path": "/create_window/bindings/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> UI::WindowsAndMessaging::*, System::LibraryLoader::{ GetModuleHandleA, }, }, ); }<|fim_prefix|>// repo: OnePercent418/windows-samples-rs path: /create_window/bindings/build.rs fn main() { windows::build!( Windows::Win32::{ <|fim_...
code_fim
hard
{ "lang": "rust", "repo": "OnePercent418/windows-samples-rs", "path": "/create_window/bindings/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OnePercent418/windows-samples-rs path: /create_window/bindings/build.rs fn main() { windows::build!( Windows::Win32::{ <|fim_suffix|> UI::WindowsAndMessaging::*, System::LibraryLoader::{ GetModuleHandleA, }, }, ); }<|fim_...
code_fim
hard
{ "lang": "rust", "repo": "OnePercent418/windows-samples-rs", "path": "/create_window/bindings/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Serializes this proof into a vector of bytes. pub fn to_bytes(&self) -> Vec<u8> { let mut result = Vec::new(); self.context.write_into(&mut result); self.commitments.write_into(&mut result); self.trace_queries.write_into(&mut result); self.constraint_que...
code_fim
hard
{ "lang": "rust", "repo": "GuildOfWeavers/winterfell", "path": "/air/src/proof/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns trace info for the computation described by this proof. pub fn get_trace_info(&self) -> TraceInfo { self.context.get_trace_info() } /// Returns the size of the LDE domain for the computation described by this proof. pub fn lde_domain_size(&self) -> usize { ...
code_fim
hard
{ "lang": "rust", "repo": "GuildOfWeavers/winterfell", "path": "/air/src/proof/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GuildOfWeavers/winterfell path: /air/src/proof/mod.rs // Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. //! Contains STARK proof struct and associated components. ...
code_fim
hard
{ "lang": "rust", "repo": "GuildOfWeavers/winterfell", "path": "/air/src/proof/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> iup::open().unwrap(); let mut dialog = iup::dialog(iup::label("Hello, world!")); iup::show(&mut dialog).unwrap(); iup::main_loop(); iup::close(); }<|fim_prefix|>// repo: frewsxcv/iup-rust path: /examples/hello0.rs //! Example based on hello0 from http://wiki.call-cc.org/iup-tutor <|f...
code_fim
easy
{ "lang": "rust", "repo": "frewsxcv/iup-rust", "path": "/examples/hello0.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frewsxcv/iup-rust path: /examples/hello0.rs //! Example based on hello0 from http://wiki.call-cc.org/iup-tutor extern crate iup; <|fim_suffix|> iup::open().unwrap(); let mut dialog = iup::dialog(iup::label("Hello, world!")); iup::show(&mut dialog).unwrap(); iup::main_loop(); ...
code_fim
easy
{ "lang": "rust", "repo": "frewsxcv/iup-rust", "path": "/examples/hello0.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betrusted-io/xous-core path: /services/shellchat/src/cmds/sha.rs use crate::{ShellCmdApi, CommonEnv}; use xous_ipc::String; use sha2::*; use digest::Digest; use num_traits::*; use core::sync::atomic::{AtomicU32, Ordering}; static CB_ID: AtomicU32 = AtomicU32::new(0); #[derive(num_derive::Fro...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/shellchat/src/cmds/sha.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> { use core::fmt::Write; let mut ret = String::<1024>::new(); let helpstring = "sha [check] [check256] [hwbench] [swbench] [susres]"; let mut tokens = args.as...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/shellchat/src/cmds/sha.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("cargo:rerun-if-changed=build.rs"); }<|fim_prefix|>// repo: sccommunity/crates-sgx path: /crates/log/build.rs //! This build script detects target platforms that lack proper support for //! atomics and sets `cfg` flags accordingly. use std::env; <|fim_middle|>fn main() { let target = e...
code_fim
medium
{ "lang": "rust", "repo": "sccommunity/crates-sgx", "path": "/crates/log/build.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sccommunity/crates-sgx path: /crates/log/build.rs //! This build script detects target platforms that lack proper support for //! atomics and sets `cfg` flags accordingly. use std::env; fn main() { <|fim_suffix|> if !target.starts_with("thumbv6") { println!("cargo:rustc-cfg=atomic_c...
code_fim
easy
{ "lang": "rust", "repo": "sccommunity/crates-sgx", "path": "/crates/log/build.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bryanburgers/advent-of-code-2020 path: /day-02/src/main.rs use std::io::BufRead; fn main() { let stdin = std::io::stdin(); let lines = stdin.lock().lines(); let entries: Vec<_> = lines .map(|line| line.unwrap().parse::<PasswordEntry>().unwrap()) .collect(); let...
code_fim
hard
{ "lang": "rust", "repo": "bryanburgers/advent-of-code-2020", "path": "/day-02/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn is_valid_2(&self) -> bool { let chars: Vec<char> = self.password.chars().collect(); let c1 = chars.get(self.min - 1); let c2 = chars.get(self.max - 1); (c1 == Some(&self.ch)) ^ (c2 == Some(&self.ch)) } } #[derive(Debug, thiserror::Error, Clone, Copy)] enum Passw...
code_fim
hard
{ "lang": "rust", "repo": "bryanburgers/advent-of-code-2020", "path": "/day-02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut parts = s.splitn(3, ' '); let range = parts.next().ok_or(PasswordEntryParseError::MissingRange)?; let ch = parts .next() .ok_or(PasswordEntryParseError::MissingCharacter)?; let password = parts .next() .ok_or(PasswordE...
code_fim
hard
{ "lang": "rust", "repo": "bryanburgers/advent-of-code-2020", "path": "/day-02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::graph::Graph; pub enum TopologyMessage { Init(Init), AnnouncementNode(AnnouncementNode), AnnouncementChannel(AnnouncementChannel), UpdateChannel(UpdateChannel), } impl MessageFiltered for TopologyMessage { fn filter(v: Message) -> Result<Self, Message> { match v...
code_fim
hard
{ "lang": "rust", "repo": "evgeniy-scherbina/lpd", "path": "/routing/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evgeniy-scherbina/lpd path: /routing/src/lib.rs #![forbid(unsafe_code)] #![allow(non_shorthand_field_patterns)] // The crate is bunch of public modules and tests module. // Its structure will change. extern crate secp256k1; extern crate chrono; #[macro_use] extern crate wire; extern crate bron...
code_fim
hard
{ "lang": "rust", "repo": "evgeniy-scherbina/lpd", "path": "/routing/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> rocket::ignite().mount( "/consumos", routes![get_consumos, get_consumo, create_consumo, delete_consumo], ) }<|fim_prefix|>// repo: neviim/apiagua path: /src/bin.rs #![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; use rocket_contrib::json::Json; use r...
code_fim
hard
{ "lang": "rust", "repo": "neviim/apiagua", "path": "/src/bin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: neviim/apiagua path: /src/bin.rs #![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; use rocket_contrib::json::Json; use rocket::http::RawStr; use lib::db; use lib::model::Consumo; fn main() { <|fim_suffix|> rocket::ignite().mount( "/consumos", rou...
code_fim
hard
{ "lang": "rust", "repo": "neviim/apiagua", "path": "/src/bin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ruchnar/rusthammer path: /src/units/tests.rs macro_rules! simple_unit { () => ( super::Unit { name: String::from("Simple"), save: 6, size: 1, wounds: 4, bravery: 6, movement: 4, weapons: vec![ ...
code_fim
hard
{ "lang": "rust", "repo": "ruchnar/rusthammer", "path": "/src/units/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_unsaved() { assert_approx_eq!( simple_unit!().unsaved(&complex_unit!()), 4.0 * (4.0/6.0) * (4.0/6.0) * (0.5 - (1.0/6.0 * 0.5))); assert_approx_eq!( complex_unit!().unsaved(&simple_unit!()), 9.0 * ( 3.0 * (4.0/6.0) * (4.0/6.0) * (5.0/6.0)...
code_fim
hard
{ "lang": "rust", "repo": "ruchnar/rusthammer", "path": "/src/units/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }