text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: PinkDiamond1/thor-1 path: /thunder/src/db.rs use crate::{channel, ChannelId}; use anyhow::{anyhow, Context, Result}; use serde::{Deserialize, Serialize}; use std::path::Path; use thor::Channel; // TODO: Use it #[allow(dead_code)] struct Database { db: sled::Db, } // TODO: Use it #[allow(de...
code_fim
hard
{ "lang": "rust", "repo": "PinkDiamond1/thor-1", "path": "/thunder/src/db.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match (channel_id, channel) { (Ok(_channel_id), Ok(channel)) => Some(Ok(channel)), (Ok(_), Err(err)) => Some(Err(err)), // If the channel id deserialize, // then it should be a channel (..) ...
code_fim
hard
{ "lang": "rust", "repo": "PinkDiamond1/thor-1", "path": "/thunder/src/db.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uesugi6111/wd122-db path: /src/config.rs use once_cell::sync::Lazy; pub static ENV_CONFIG: Lazy<Config> = Lazy::new<|fim_suffix|>env::var("PAGE_SIZE").unwrap().parse().unwrap(); Config { page_size } }<|fim_middle|>(load_config); pub const PAGE_SIZE: u64 = 4096; pub struct Config { pub ...
code_fim
medium
{ "lang": "rust", "repo": "uesugi6111/wd122-db", "path": "/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>page_size: u64, } pub fn load_config() -> Config { let page_size = dotenv::var("PAGE_SIZE").unwrap().parse().unwrap(); Config { page_size } }<|fim_prefix|>// repo: uesugi6111/wd122-db path: /src/config.rs use once_cell::sync::Lazy; pub static ENV_CONFIG: Lazy<Config> = Lazy::new<|fim_middle|>(...
code_fim
medium
{ "lang": "rust", "repo": "uesugi6111/wd122-db", "path": "/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryanhofer/adventofcode2018 path: /src/bin/day8/main.rs const INPUT: &'static str = include_str!("input.txt"); fn main() { println!("Part One: {}", part_one()); println!("Part Two: {}", part_two()); } fn part_one() -> u32 { let root = parse_tree(INPUT); root.recursive_metadata_s...
code_fim
hard
{ "lang": "rust", "repo": "ryanhofer/adventofcode2018", "path": "/src/bin/day8/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>where I: Iterator<Item = u8>, { let num_children = input.next().unwrap(); let num_metadata = input.next().unwrap(); let mut children = vec![]; let mut metadata = vec![]; for _ in 0..num_children { children.push(parse_node(input)); } for _ in 0..num_metadata { ...
code_fim
hard
{ "lang": "rust", "repo": "ryanhofer/adventofcode2018", "path": "/src/bin/day8/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn hash<H: Hash>(value: H) -> u64 { let mut hasher = HashHasher::default(); value.hash(&mut hasher); hasher.finish() } #[test] // This checks for regressions to https://github.com/Fraser999/Hash-Hasher/issues/1 fn avoid_tending_towards_max_value() { let...
code_fim
hard
{ "lang": "rust", "repo": "Fraser999/Hash-Hasher", "path": "/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let mut hasher = HashHasher::default(); value.hash(&mut hasher); hasher.finish() } #[test] // This checks for regressions to https://github.com/Fraser999/Hash-Hasher/issues/1 fn avoid_tending_towards_max_value() { let h1 = hash(&[u64::max_value()]); ...
code_fim
hard
{ "lang": "rust", "repo": "Fraser999/Hash-Hasher", "path": "/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Fraser999/Hash-Hasher path: /src/lib.rs //! A [`std::hash::Hasher`](https://doc.rust-lang.org/std/hash/trait.Hasher.html) which is designed //! to work with already-hashed or hash-like data. //! //! The provided hasher does minimal work under the assumption that the input data is already //! sui...
code_fim
hard
{ "lang": "rust", "repo": "Fraser999/Hash-Hasher", "path": "/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let pos: Position = "A1".into(); assert_eq!(pos.x(), 1); assert_eq!(pos.y(), 1); let pos: Position = "t19".into(); assert_eq!(pos.x(), 19); assert_eq!(pos.y(), 19); let pos: Position = "J12".into(); assert_eq!(pos.x(), 9); assert_eq...
code_fim
medium
{ "lang": "rust", "repo": "mipli/baduk-rs", "path": "/tests/position.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let pos: Position = "J12".into(); assert_eq!(pos.x(), 9); assert_eq!(pos.y(), 12); } }<|fim_prefix|>// repo: mipli/baduk-rs path: /tests/position.rs #[cfg(test)] mod tests { use baduk_rs::Position; #[test] fn it_can_convert_from_usize_tuple() { let pos: Po...
code_fim
hard
{ "lang": "rust", "repo": "mipli/baduk-rs", "path": "/tests/position.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mipli/baduk-rs path: /tests/position.rs #[cfg(test)] mod tests { use baduk_rs::Position; #[test] fn it_can_convert_from_usize_tuple() { let pos: Position = (2, 3).into(); assert_eq!(pos.x(), 2); assert_eq!(pos.y(), 3); } #[test] fn it_can_convert...
code_fim
medium
{ "lang": "rust", "repo": "mipli/baduk-rs", "path": "/tests/position.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> formatter.write_str( "4 whitespace separated floating point values: \"y1:f64 x1:f64 y2:f64 x2:f64\"", ) } fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> where E: de::Error, { ...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/services/src/datasets/external/pangaea/meta.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>/// This helper is used to map the pangaea /// data structure to our internal representation #[derive(Serialize, Deserialize, Debug)] #[serde(tag = "@type")] enum FeatureHelper { #[serde(rename = "GeoShape")] Box { #[serde(rename = "box", deserialize_with = "FeatureHelper::parse_coords")] ...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/services/src/datasets/external/pangaea/meta.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geo-engine/geoengine path: /services/src/datasets/external/pangaea/meta.rs ngine_datatypes::primitives::{ AxisAlignedRectangle, BoundingBox2D, Coordinate2D, FeatureDataType, Measurement, MultiPoint, MultiPolygon, TypedGeometry, VectorQueryRectangle, }; use geoengine_datatypes::spatial_re...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/services/src/datasets/external/pangaea/meta.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryanivandsouza/pe path: /rust/euler/src/solutions/problem_1.rs fn implementation1() -> String { <|fim_suffix|> format!("{}", result) } pub fn get_implementations() -> Vec<fn() -> String> { vec![ implementation1 ] }<|fim_middle|> let mut result = 0i32; for n in 1..1000 ...
code_fim
medium
{ "lang": "rust", "repo": "ryanivandsouza/pe", "path": "/rust/euler/src/solutions/problem_1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_implementations() -> Vec<fn() -> String> { vec![ implementation1 ] }<|fim_prefix|>// repo: ryanivandsouza/pe path: /rust/euler/src/solutions/problem_1.rs fn implementation1() -> String { let mut result = 0i32; for n in 1..1000 { if n % 3 == 0 || n % 5 ==0 { ...
code_fim
easy
{ "lang": "rust", "repo": "ryanivandsouza/pe", "path": "/rust/euler/src/solutions/problem_1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Default)] pub enum BoostFunction { Log2, #[default] Log10, Multiply, Add, /// Replaces the score with the value. Can be used to order by a field. Replace, }<|fim_prefix|>// repo: PSeitz/veloci pa...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/veloci", "path": "/src/search/request/boost_request.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PSeitz/veloci path: /src/search/request/boost_request.rs use ordered_float::OrderedFloat; #[derive(Serialize, Deserialize, Default, Clone, Debug, Hash, PartialEq, Eq, PartialOrd)] pub struct RequestBoostPart { pub path: String, /// The boost function that is applied on the existing scor...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/veloci", "path": "/src/search/request/boost_request.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: panicbit/terra_constgen path: /src/main.rs use std::env::args; use syn::Item::Const; use syn::*; use quote::quote; fn main() { let header_path = args().nth(1).expect("first arg needs to be header.h"); let bindings = bindgen::builder() .header(header_path) .generate().ex...
code_fim
medium
{ "lang": "rust", "repo": "panicbit/terra_constgen", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!(" {} = {},", item.ident, value); } } } println!("}}"); }<|fim_prefix|>// repo: panicbit/terra_constgen path: /src/main.rs use std::env::args; use syn::Item::Const; use syn::*; use quote::quote; fn main() { let header_path = args().nth(1).expect...
code_fim
hard
{ "lang": "rust", "repo": "panicbit/terra_constgen", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for item in file.items { if let Const(item) = item { if let Expr::Lit(ExprLit { lit, ..})= *item.expr { let value = match lit { Lit::Int(n) => quote! { #n }.to_string(), Lit::Float(n) => quote! { #n }.to_string(), ...
code_fim
medium
{ "lang": "rust", "repo": "panicbit/terra_constgen", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Discord { pub fn connect(api_key: &str) -> Result<Self> { unimplemented!() } }<|fim_prefix|>// repo: keringar/coin path: /src/discord/mod.rs pub mod connection; pub mod model; use error::*; <|fim_middle|>pub struct Discord { pub connection: connection::Connection, }
code_fim
medium
{ "lang": "rust", "repo": "keringar/coin", "path": "/src/discord/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: keringar/coin path: /src/discord/mod.rs pub mod connection; pub mod model; <|fim_suffix|>impl Discord { pub fn connect(api_key: &str) -> Result<Self> { unimplemented!() } }<|fim_middle|>use error::*; pub struct Discord { pub connection: connection::Connection, }
code_fim
medium
{ "lang": "rust", "repo": "keringar/coin", "path": "/src/discord/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: djipko/advent2020 path: /day6/src/main.rs use std::collections::HashSet; use std::error::Error; use std::io::{self, Read}; fn group_answers(answers: &str) -> usize { <|fim_suffix|>fn main() -> Result<(), Box<dyn Error>> { let mut buffer = String::new(); io::stdin().read_to_string(&mut b...
code_fim
hard
{ "lang": "rust", "repo": "djipko/advent2020", "path": "/day6/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer)?; let input = buffer.split("\n\n").collect::<Vec<&str>>(); println!( "Sum of yes answers {}", input .iter() .map(|group| { group_answers(&str::replace(group, "\n", "")) }) ...
code_fim
hard
{ "lang": "rust", "repo": "djipko/advent2020", "path": "/day6/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: graydon/rust-prehistory path: /src/test/run-pass/foreach-simple-outer-slot.rs // -*- rust -*- fn main() { let int sum = 0; for each (int i in first<|fim_suffix|> log sum; check (sum == 45); } iter first_ten() -> int { let int i = 0; while (i < 10) { log "first_ten"; put i; ...
code_fim
medium
{ "lang": "rust", "repo": "graydon/rust-prehistory", "path": "/src/test/run-pass/foreach-simple-outer-slot.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>0; while (i < 10) { log "first_ten"; put i; i = i + 1; } }<|fim_prefix|>// repo: graydon/rust-prehistory path: /src/test/run-pass/foreach-simple-outer-slot.rs // -*- rust -*- fn main() { let int sum = 0; for each (int i in first_ten()) { log "main"; log i; sum = sum + i; ...
code_fim
medium
{ "lang": "rust", "repo": "graydon/rust-prehistory", "path": "/src/test/run-pass/foreach-simple-outer-slot.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: believer/advent-of-code path: /rust/2017/day_02/src/lib.rs pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; pub fn part_01(input: &Vec<Vec<i32>>) -> i32 { input.iter().fold(0, |acc, r| { let lowest = r.first().unwrap(); let biggest = r.last().unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "believer/advent-of-code", "path": "/rust/2017/day_02/src/lib.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> if output % 1.0 == 0.0 { sum += output; } } } } sum as i32 }<|fim_prefix|>// repo: believer/advent-of-code path: /rust/2017/day_02/src/lib.rs pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; pub fn p...
code_fim
hard
{ "lang": "rust", "repo": "believer/advent-of-code", "path": "/rust/2017/day_02/src/lib.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: valarauca/dice_backend path: /dice_backend/src/syntaxhelper.rs pub struct CharacterLookup<'a> { buffer: &'a str, char_index: Box<[CharIndex]>, line_index: Box<[LineIndex]>, } impl<'a> CharacterLookup<'a> { pub fn new(arg: &'a str) -> CharacterLookup<'a> { let mut char_ind...
code_fim
hard
{ "lang": "rust", "repo": "valarauca/dice_backend", "path": "/dice_backend/src/syntaxhelper.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// get_span_lines is used to return the "lines" between "start" and "end" /// this means it'll skip forward to beginning of the "start" line, and /// the terminator of the "end" line. pub fn get_span_lines(self, start: usize, end: usize) -> &'a str { let line_start = self.get_line...
code_fim
hard
{ "lang": "rust", "repo": "valarauca/dice_backend", "path": "/dice_backend/src/syntaxhelper.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use super::*; impl IRQ { pub fn enabled() -> IRQ { let mut irq = IRQ::new(); irq.set_enabled_bits(0xFF); irq } } #[test] fn bit_helpers() { assert_eq!(isolate_rightmost_bit(0b110100), 0b100); ...
code_fim
hard
{ "lang": "rust", "repo": "jcomo/rustboy", "path": "/src/gameboy/irq/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jcomo/rustboy path: /src/gameboy/irq/mod.rs use crate::bits; pub enum Interrupt { VBlank, LCDC, Timer, Serial, Joypad, } impl Interrupt { fn from_bit(bit: u8) -> Option<Interrupt> { use self::Interrupt::*; match bit & 0b00011111 { 0b00001 =>...
code_fim
hard
{ "lang": "rust", "repo": "jcomo/rustboy", "path": "/src/gameboy/irq/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn ack_interrupt() { let mut irq = IRQ::new(); irq.set_interrupt(&Interrupt::VBlank); irq.set_interrupt(&Interrupt::Timer); irq.set_interrupt(&Interrupt::Joypad); assert_eq!(irq.ack_interrupt(), None); // Enable all but VBlank irq....
code_fim
hard
{ "lang": "rust", "repo": "jcomo/rustboy", "path": "/src/gameboy/irq/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> export(&all_prices); } fn export(vector: &Vec<Vec<i32>>) { let mut file = File::create("market_history.csv").unwrap(); for (x, inner_vec) in vector.iter().enumerate() { // TODO: Change this loop to a map for simplicity. let mut curr_price: i64 = 0; let mut line: String = Strin...
code_fim
hard
{ "lang": "rust", "repo": "foundoulis/market_sim", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foundoulis/market_sim path: /src/main.rs #![allow(unused_lints)] extern crate rustyline; pub mod minority; pub mod prediction; use minority::market::*; use std::fs::File; use std::io::prelude::*; use std::thread; fn main() { } fn main_minority() { let num_agents = 100; let num_...
code_fim
hard
{ "lang": "rust", "repo": "foundoulis/market_sim", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { let readline = rl.readline("|)]}> "); match readline { Ok(line) => { rl.add_history_entry(&line); if line == "quit" { break } else if line == "run" { thread::spawn(move || { ...
code_fim
hard
{ "lang": "rust", "repo": "foundoulis/market_sim", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aatifsyed/udpfwd path: /src/newtypes.rs use derive_more::{Deref, DerefMut, From, Into}; use evmap::ShallowCopy; use std::mem::ManuallyDrop; use std::net; #[derive(Deref, DerefMut, Debug, Clone, Copy, PartialEq, Eq, Hash, F<|fim_suffix|>safe fn shallow_copy(&self) -> ManuallyDrop<Self> { ...
code_fim
medium
{ "lang": "rust", "repo": "aatifsyed/udpfwd", "path": "/src/newtypes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>safe fn shallow_copy(&self) -> ManuallyDrop<Self> { ManuallyDrop::new(*self) } }<|fim_prefix|>// repo: aatifsyed/udpfwd path: /src/newtypes.rs use derive_more::{Deref, DerefMut, From, Into}; use evmap::ShallowCopy; use std::mem::Manua<|fim_middle|>llyDrop; use std::net; #[derive(Deref, Deref...
code_fim
medium
{ "lang": "rust", "repo": "aatifsyed/udpfwd", "path": "/src/newtypes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>rom, Into)] pub struct SocketAddr(net::SocketAddr); impl ShallowCopy for SocketAddr { unsafe fn shallow_copy(&self) -> ManuallyDrop<Self> { ManuallyDrop::new(*self) } }<|fim_prefix|>// repo: aatifsyed/udpfwd path: /src/newtypes.rs use derive_more::{Deref, DerefMut, From, Into}; use evmap:...
code_fim
medium
{ "lang": "rust", "repo": "aatifsyed/udpfwd", "path": "/src/newtypes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut mesh_builder = context.add_mesh(); mesh_builder.vertex(&positions); if !normals.is_empty() { mesh_builder.vertex(&normals); } let prototype = mesh_builder.build(); let mut entity_builder = scene.add_entity(&pro...
code_fim
hard
{ "lang": "rust", "repo": "Gordon-F/baryon", "path": "/src/asset/obj.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gordon-F/baryon path: /src/asset/obj.rs use std::{iter, path::Path}; /// Load entities from Wavefront Obj format. pub fn load_obj( path: impl AsRef<Path>, scene: &mut crate::Scene, node: crate::NodeRef, context: &mut crate::Context, ) -> fxhash::FxHashMap<String, (crate::EntityR...
code_fim
hard
{ "lang": "rust", "repo": "Gordon-F/baryon", "path": "/src/asset/obj.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ldcduc/moon path: /components/painting/src/paint_functions/border.rs use crate::color::style_color_to_paint_color; use crate::command::{DisplayCommand, DrawCommand}; use crate::primitive::Rect; use crate::LayoutBox; use layout::box_model::Edge; use style::value_processing::Property; pub fn pain...
code_fim
hard
{ "lang": "rust", "repo": "ldcduc/moon", "path": "/components/painting/src/paint_functions/border.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if layout_box.dimensions.border.right > 0. { let rect = create_border_rect(layout_box, Edge::Right); draw_commands.push(DrawCommand::FillRect(rect, border_right_color)); } if layout_box.dimensions.border.bottom > 0. { let rect = create_border_re...
code_fim
hard
{ "lang": "rust", "repo": "ldcduc/moon", "path": "/components/painting/src/paint_functions/border.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cf-official/news-bot path: /src/structures/article.rs use crate::news_types::NewsType; use crate::news_publishers::*; pub struct Article { pub headline: String, pub author: String, pub article_type: NewsType, pub link: String, pub preview_text: S<|fim_suffix|>tring::from(url...
code_fim
hard
{ "lang": "rust", "repo": "cf-official/news-bot", "path": "/src/structures/article.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>tring::from(url), preview_text: String::from(description), content: String::from(content), date_published: String::from(date_published), publisher, } } }<|fim_prefix|>// repo: cf-official/news-bot path: /src/structures/article.rs use crate::news...
code_fim
hard
{ "lang": "rust", "repo": "cf-official/news-bot", "path": "/src/structures/article.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: provable-things/ptokens-core path: /src/eos_on_eth/check_core_is_initialized.rs use crate::{ chains::{ eos::{core_initialization::check_eos_core_is_initialized::check_eos_core_is_initialized, eos_state::EosState}, eth::{core_initialization::check_eth_core_is_initialized::chec...
code_fim
medium
{ "lang": "rust", "repo": "provable-things/ptokens-core", "path": "/src/eos_on_eth/check_core_is_initialized.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[fuchsia::test] async fn test_list_with_data_with_manifest_and_archive() { let accessor = selectors::parse_selector::<selectors::FastError>( "./test/component:expose:fuchsia.diagnostics.ArchiveAccessor", ) .unwrap(); let params = BridgeStreamParameters ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/developer/ffx/plugins/inspect/list/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/plugins/inspect/list/src/lib.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { anyhow::Result, ffx_core::ffx_plugin, f...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/developer/ffx/plugins/inspect/list/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scott113341/advent_of_code_2018 path: /day_5/src/main.rs #![feature(dbg_macro)] use std::collections::HashMap; fn main() { let input = include_str!("input.txt") .trim() .to_string(); println!("part_1: {}", part_1(input.clone())); println!("part_2: {}", part_2(input...
code_fim
hard
{ "lang": "rust", "repo": "scott113341/advent_of_code_2018", "path": "/day_5/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (reacted, polymer) } fn react_fully(polymer: String) -> String { let mut reacted = true; let mut final_polymer = polymer; while reacted { let (new_reacted, new_final_polymer) = react(final_polymer); reacted = new_reacted; final_polymer = new_final_polymer; } ...
code_fim
hard
{ "lang": "rust", "repo": "scott113341/advent_of_code_2018", "path": "/day_5/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// INTERRUPTS pub const INT_START: u32 = 0x4000200; pub const IE_LO: u32 = 0x4000200; pub const IE_HI: u32 = 0x4000201; pub const IF_LO: u32 = 0x4000202; pub const IF_HI: u32 = 0x4000203; pub const IME: u32 = 0x4000208; pub const WSCNT_LO: u32 = 0x4000204; pub const INT_END: u32 = 0x4000208;<|fim_prefix|>...
code_fim
hard
{ "lang": "rust", "repo": "felixzhuologist/wasm-gba", "path": "/src/mem/io/addrs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: felixzhuologist/wasm-gba path: /src/mem/io/addrs.rs // graphics pub const GRAPHICS_START: u32 = 0x4000000; pub const DISPCNT_LO: u32 = 0x04000000; pub const DISPCNT_HI: u32 = 0x04000001; pub const DISPSTAT_LO: u32 = 0x04000004; pub const DISPSTAT_HI: u32 = 0x04000005; pub const VCOUNT_LO: u32 = ...
code_fim
hard
{ "lang": "rust", "repo": "felixzhuologist/wasm-gba", "path": "/src/mem/io/addrs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>extern "rust-intrinsic" { pub fn transmute<F, T>(from: F) -> T; }<|fim_prefix|>// repo: luqmana/rust-psp-hello path: /src/lang.rs // Lang items and intrinsics <|fim_middle|>#[lang = "copy"] trait Copy {} #[lang = "sized"] trait Sized {} #[lang = "sync"] trait Sync {}
code_fim
medium
{ "lang": "rust", "repo": "luqmana/rust-psp-hello", "path": "/src/lang.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luqmana/rust-psp-hello path: /src/lang.rs // Lang items and intrinsics <|fim_suffix|>extern "rust-intrinsic" { pub fn transmute<F, T>(from: F) -> T; }<|fim_middle|>#[lang = "copy"] trait Copy {} #[lang = "sized"] trait Sized {} #[lang = "sync"] trait Sync {}
code_fim
medium
{ "lang": "rust", "repo": "luqmana/rust-psp-hello", "path": "/src/lang.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn tokenize<'a>(_job: &'a mut Job) -> Result<(), Traced<LexerError>> { // TODO: do some final checks like // - job.cursor.position() == job.cursor.end() <- implicit alternative? Ok(()) // means we are done. /* if (empty($this->brackets) && preg_match($this->rege...
code_fim
medium
{ "lang": "rust", "repo": "colin-kiegel/twig-rust", "path": "/src/engine/parser/lexer/job/state/final_.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl TokenizeState for Final { fn state() -> Code { Code::Final } fn tokenize<'a>(_job: &'a mut Job) -> Result<(), Traced<LexerError>> { // TODO: do some final checks like // - job.cursor.position() == job.cursor.end() <- implicit alternative? Ok(()) // means w...
code_fim
medium
{ "lang": "rust", "repo": "colin-kiegel/twig-rust", "path": "/src/engine/parser/lexer/job/state/final_.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: colin-kiegel/twig-rust path: /src/engine/parser/lexer/job/state/final_.rs // This file is part of rust-web/twig // // For the copyright and license information, please view the LICENSE // file that was distributed with this source code. //! Final state of the lexer job. use super::{TokenizeSta...
code_fim
medium
{ "lang": "rust", "repo": "colin-kiegel/twig-rust", "path": "/src/engine/parser/lexer/job/state/final_.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blittable/rust-top-down path: /demos/borrowing_103/src/main.rs fn main() { the_real_owner(); test_to_owned_and_clone(); } //Borrow test One shows borrowing != taking ownership // 1) A borrow created in one scope // 2) An assignment of a heap allocated string in another scope to the borr...
code_fim
medium
{ "lang": "rust", "repo": "blittable/rust-top-down", "path": "/demos/borrowing_103/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn test_to_owned_and_clone() { let s1 = "I am boxed and owned".to_string(); let s2 = "I am boxed and owned".to_string(); let c1 = s1.to_owned(); let c2 = s2.clone(); println!("{:?}", c1); println!("{:?}", c2); println!("{:?}", c1 == s1); // compile-time error here (see be...
code_fim
hard
{ "lang": "rust", "repo": "blittable/rust-top-down", "path": "/demos/borrowing_103/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> waypoint_position = Pos( waypoint_position.0 * cos - waypoint_position.1 * sin, waypoint_position.0 * sin + waypoint_position.1 * cos, ); }; match instruction { Direction(direction, value) => { waypoint_position += direction.get_delta_posi...
code_fim
medium
{ "lang": "rust", "repo": "Nufflee/AdventOfCode-2020", "path": "/day12/src/part2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nufflee/AdventOfCode-2020 path: /day12/src/part2.rs use crate::ship::{Instruction, Pos}; pub fn solution(instructions: &[Instruction]) -> i32 { let mut waypoint_position = Pos(-10, 1); instructions .iter() .map(|instruction| { use Instruction::*; <|fim_suffix|> // Tru...
code_fim
medium
{ "lang": "rust", "repo": "Nufflee/AdventOfCode-2020", "path": "/day12/src/part2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m2700/rust-mpi-tool-support path: /app/pmpi-test-app/build.rs fn main() { use std::path::Path; println!( "cargo:rustc-link-search={}", Path::new("..") .join("..") .join("tool") <|fim_suffix|>rap() ...
code_fim
hard
{ "lang": "rust", "repo": "m2700/rust-mpi-tool-support", "path": "/app/pmpi-test-app/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> .join("target") .join("debug") .canonicalize() .unwrap() .display() ); println!("cargo:rustc-link-lib=mpi_test_tool"); }<|fim_prefix|>// repo: m2700/rust-mpi-tool-support path: /app/pmpi-test-app/build.rs fn main() { ...
code_fim
hard
{ "lang": "rust", "repo": "m2700/rust-mpi-tool-support", "path": "/app/pmpi-test-app/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>rive(Debug, Serialize, Deserialize)] pub struct TokenInfo { pub id: String, pub name: String, pub permissions: Vec<String>, }<|fim_prefix|>// repo: Sunspar/gw2rs path: /src/anet/token_info.rs /// `TokenInfo`s provide information on what an API token allows app<|fim_middle|>lications to look a...
code_fim
medium
{ "lang": "rust", "repo": "Sunspar/gw2rs", "path": "/src/anet/token_info.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sunspar/gw2rs path: /src/anet/token_info.rs /// `TokenInfo`s provide information on what an API token allows app<|fim_suffix|>id: String, pub name: String, pub permissions: Vec<String>, }<|fim_middle|>lications to look at on behalf /// of the user who created them. #[derive(Debug, Serial...
code_fim
medium
{ "lang": "rust", "repo": "Sunspar/gw2rs", "path": "/src/anet/token_info.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>id: String, pub name: String, pub permissions: Vec<String>, }<|fim_prefix|>// repo: Sunspar/gw2rs path: /src/anet/token_info.rs /// `TokenInfo`s provide information on what an API token allows app<|fim_middle|>lications to look at on behalf /// of the user who created them. #[derive(Debug, Serial...
code_fim
medium
{ "lang": "rust", "repo": "Sunspar/gw2rs", "path": "/src/anet/token_info.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match pkt.get_cmd_id() { 0 => // OpenLogger { // Wait for SVC to complete let post_ctx = SvcWait::new(pre_ctx).await; let resp = hipc_get_packet(); // Try to hook first handle/domain if it exists if (resp.hook_first_h...
code_fim
hard
{ "lang": "rust", "repo": "realTobby/HashtagBlessedII", "path": "/src/modules/log.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: realTobby/HashtagBlessedII path: /src/modules/log.rs /* * Copyright (c) 2015-2021, SALT. * This file is part of HashtagBlessedII and is distributed under the 3-clause BSD license. * See LICENSE.md for terms of use. */ use core::{future::Future, pin::Pin}; use crate::hos::{hport::HPort, hhan...
code_fim
hard
{ "lang": "rust", "repo": "realTobby/HashtagBlessedII", "path": "/src/modules/log.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> return Ok(()); } tracing::debug!("Starting new Round"); let mod_role = match util::roles::find_role(MOD_ROLE_NAME, guild_id, ctx.http()).await { Ok(r) => r, Err(util::roles::FindRoleError::NotFound) => { tracing::error!("'Game Master'-Role does not exist o...
code_fim
hard
{ "lang": "rust", "repo": "kiennguyenchi/waswolf", "path": "/src/commands/werewolf.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kiennguyenchi/waswolf path: /src/commands/werewolf.rs use serenity::{ client::Context, framework::standard::CommandResult, http::CacheHttp, model::{channel::Message, id::GuildId}, prelude::Mutex, }; use crate::{ get_storage, roles::WereWolfRoleConfig, rounds::Round, stor...
code_fim
hard
{ "lang": "rust", "repo": "kiennguyenchi/waswolf", "path": "/src/commands/werewolf.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaxOhn/Bathbot path: /bathbot-model/src/twilight_gateway/session.rs use std::{collections::HashMap, hash::BuildHasher}; use rkyv::{ collections::{hash_map::HashMapResolver, ArchivedHashMap}, out_field, ser::{ScratchSpace, Serializer}, with::{ArchiveWith, DeserializeWith, RefAsBo...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot-model/src/twilight_gateway/session.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>impl<H, S: Fallible + ?Sized> SerializeWith<Sessions<H>, S> for SessionsRkyv where S: Serializer + ScratchSpace, { #[inline] fn serialize_with(map: &Sessions<H>, serializer: &mut S) -> Result<Self::Resolver, S::Error> { let iter = map .iter() .map(|(shard_id, se...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot-model/src/twilight_gateway/session.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> init(); let binary_blob = fs::read("test/test_nopie.riscv64").expect("Can't read binary"); let binary = ElfBinary::new(binary_blob.as_slice()).expect("Got proper ELF file"); assert!(!binary.is_pie()); } #[test] fn check_tls() { init(); let binary_blob = fs::read("test/tls.riscv6...
code_fim
hard
{ "lang": "rust", "repo": "gz/rust-elfloader", "path": "/src/arch/riscv/test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gz/rust-elfloader path: /src/arch/riscv/test.rs use std::fs; use crate::arch::test::*; use crate::*; #[test] fn load_pie_elf() { init(); let binary_blob = fs::read("test/test.riscv64").expect("Can't read binary"); let binary = ElfBinary::new(binary_blob.as_slice()).expect("Got prop...
code_fim
hard
{ "lang": "rust", "repo": "gz/rust-elfloader", "path": "/src/arch/riscv/test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let binary_blob = fs::read("test/tls.riscv64").expect("Can't read binary"); let binary = ElfBinary::new(binary_blob.as_slice()).expect("Got proper ELF file"); let mut loader = TestLoader::new(0x1000_0000); binary.load(&mut loader).expect("Can't load?"); /* readelf -l test/tls.riscv...
code_fim
hard
{ "lang": "rust", "repo": "gz/rust-elfloader", "path": "/src/arch/riscv/test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn check_compile_status(shader: GLuint) -> Result<(), ShaderError> { unsafe { // Get the compile status let mut status = gl::FALSE as GLint; gl::GetShaderiv(shader, gl::COMPILE_STATUS, &mut status); // Fail on error if status != (gl::TRUE as GLint) { ...
code_fim
hard
{ "lang": "rust", "repo": "drewet/sb6rust", "path": "/src/shader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drewet/sb6rust path: /src/shader.rs /* * Copyright (c) 2012-2013 Graham Sellers * Copyright (c) 2014 Cameron Hart * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Softwa...
code_fim
hard
{ "lang": "rust", "repo": "drewet/sb6rust", "path": "/src/shader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn create_from_source(src: &str, shader_type: GLenum) -> Result<GLuint, ShaderError> { unsafe { let result = gl::CreateShader(shader_type); gl::ShaderSource(result, 1, &ffi::CString::from_slice(src.as_bytes()).as_ptr(), ptr::null()); gl::CompileShader(result); match...
code_fim
hard
{ "lang": "rust", "repo": "drewet/sb6rust", "path": "/src/shader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adetante/deconz-sp path: /deconz-sp/src/protocol/codec.rs use byteorder::{ByteOrder, LittleEndian}; use bytes::{BufMut, BytesMut}; use log::*; use serial_line_ip::{Decoder as SLIPDecoder, Encoder as SLIPEncoder}; use tokio::codec::{Decoder, Encoder}; use crate::protocol::{IncomingMessage, Outgo...
code_fim
hard
{ "lang": "rust", "repo": "adetante/deconz-sp", "path": "/deconz-sp/src/protocol/codec.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Codec { pub fn new() -> Self { Codec {} } } impl Decoder for Codec { type Item = IncomingMessage; type Error = Error; fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<IncomingMessage>, Error> { // TODO: validate CRC if buf.len() < 1 { ...
code_fim
hard
{ "lang": "rust", "repo": "adetante/deconz-sp", "path": "/deconz-sp/src/protocol/codec.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// 0b1: Timer X counter is reset upon timer Y compare Z event pub const ResetCounter: u32 = 0b1; } } /// Timer E Compare 2 pub mod TIMECMP2 { /// Offset (29 bits) pub const offset: u32 = 29; /// Mask (1 bit: 1 << 29) pub const m...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32f3/stm32f3x4/hrtim_timb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamgreig/stm32ral path: /src/stm32f3/stm32f3x4/hrtim_timb.rs Timer x pub const Start: u32 = 0b1; } } /// Synchronization Resets Timer x pub mod SYNCRSTx { /// Offset (10 bits) pub const offset: u32 = 10; /// Mask (1 bit: 1 << 10) ...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32f3/stm32f3x4/hrtim_timb.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamgreig/stm32ral path: /src/stm32f3/stm32f3x4/hrtim_timb.rs offset: u32 = 23; /// Mask (1 bit: 1 << 23) pub const mask: u32 = 1 << offset; /// Read-only values (empty) pub mod R {} /// Write-only values (empty) pub mod W {} pub use super...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32f3/stm32f3x4/hrtim_timb.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/winapi/src/um/shellapi.rs ; use um : : winnt : : { CHAR HANDLE HRESULT LPCSTR LPCWSTR LPSTR LPWSTR PCSTR PCWSTR PCZZSTR PCZZWSTR PWSTR PZZSTR PZZWSTR ULARGE_INTEGER WCHAR } ; use um : : winuser : : WM_USER ; DECLARE_HANDLE ! { HDROP HDROP__ } e...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/winapi/src/um/shellapi.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ToCaller : * mut ULARGE_INTEGER pulTotalNumberOfBytes : * mut ULARGE_INTEGER pulTotalNumberOfFreeBytes : * mut ULARGE_INTEGER ) - > BOOL ; pub fn SHGetNewLinkInfoA ( pszLinkTo : LPCSTR pszDir : LPCSTR pszName : LPSTR pfMustCopy : * mut BOOL uFlags : UINT ) - > BOOL ; pub fn SHGetNewLinkInfoW ( pszLinkTo :...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/winapi/src/um/shellapi.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/winapi/src/um/shellapi.rs ORD pData : PAPPBARDATA ) - > UINT_PTR ; pub fn DoEnvironmentSubstA ( pszSrc : LPSTR cchSrc : UINT ) - > DWORD ; pub fn DoEnvironmentSubstW ( pszSrc : LPWSTR cchSrc : UINT ) - > DWORD ; pub fn ExtractIconExA ( lpszFile...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/winapi/src/um/shellapi.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuyoyuppe/rust path: /src/librustc_plugin_impl/lib.rs //! Infrastructure for compiler plugins. //! //! Plugins are a deprecated way to extend the behavior of `rustc` in various ways. //! //! See the [`plugin` //! feature](https://doc.rust-lang.org/nightly/unstable-book/language-features/plugin.h...
code_fim
easy
{ "lang": "rust", "repo": "yuyoyuppe/rust", "path": "/src/librustc_plugin_impl/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub use registry::Registry; pub mod registry; pub mod load; pub mod build;<|fim_prefix|>// repo: yuyoyuppe/rust path: /src/librustc_plugin_impl/lib.rs //! Infrastructure for compiler plugins. //! //! Plugins are a deprecated way to extend the behavior of `rustc` in various ways. //! //! See the [`plugin...
code_fim
easy
{ "lang": "rust", "repo": "yuyoyuppe/rust", "path": "/src/librustc_plugin_impl/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn find_someone(optionals: &[Option<i32>]) { for opt_int in optionals.iter() { if let Some(1) = opt_int { println!("You found someone!"); } } } fn plus_one(x: Option<i32>) -> Option<i32> { match x { None => None, Some(num) => Some(num + 1), } }<...
code_fim
hard
{ "lang": "rust", "repo": "Medsko/study-crate", "path": "/src/prepackages/enums/matching.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Medsko/study-crate path: /src/prepackages/enums/matching.rs #[derive(Debug)] enum UsState { Alabama, Alaska, Oregon, } enum Coin { Penny, Nickel, Dime, Quarter(UsState), } impl Coin { fn value_in_cents(&self) -> u8 { match self { Coin::Penny...
code_fim
medium
{ "lang": "rust", "repo": "Medsko/study-crate", "path": "/src/prepackages/enums/matching.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} fn find_someone(optionals: &[Option<i32>]) { for opt_int in optionals.iter() { if let Some(1) = opt_int { println!("You found someone!"); } } } fn plus_one(x: Option<i32>) -> Option<i32> { match x { None => None, Some(num) => Some(num + 1), }...
code_fim
hard
{ "lang": "rust", "repo": "Medsko/study-crate", "path": "/src/prepackages/enums/matching.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kamiyaa/wordexp-rs path: /src/lib.rs extern crate libc; mod ll; use std::ffi::{CStr, CString}; /// Append the words found to the array resulting from a previous call. pub const WRDE_DOOFFS: i32 = 1; /// Insert we_offs initial Nones in the array we_wordv. (These are not counted in the returned...
code_fim
hard
{ "lang": "rust", "repo": "kamiyaa/wordexp-rs", "path": "/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl WordexpErrorType { /// converts a C wordexp error code to a Rust enum pub fn from(error_code: i32) -> Self { match error_code { WRDE_BADCHAR => WordexpErrorType::BadChar, WRDE_BADVAL => WordexpErrorType::BadVal, WRDE_CMDSUB => WordexpErrorType::CmdS...
code_fim
hard
{ "lang": "rust", "repo": "kamiyaa/wordexp-rs", "path": "/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/proc-macro/auxiliary/modify-ast.rs // force-host // no-prefer-dynamic #![crate_type = "proc-macro"] extern crate proc_macro; use proc_macro::*; #[proc_macro_attribute] pub fn assert1(_a: TokenStream, b: TokenStream) -> TokenStream { asse...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/proc-macro/auxiliary/modify-ast.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut a = a.into_iter(); let mut b = b.into_iter(); for (a, b) in a.by_ref().zip(&mut b) { match (a, b) { (TokenTree::Group(a), TokenTree::Group(b)) => { assert_eq!(a.delimiter(), b.delimiter()); assert_eq(a.stream(), b.stream()); ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/proc-macro/auxiliary/modify-ast.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shybyte/risp path: /src/eval.rs use std::collections::HashMap; use types::*; use types::RispType::*; use environment::*; use core::create_core_environment; use parse; use std::rc::Rc; pub fn eval(ast: RispType, env: &mut Environment) -> RispResult { match ast { List(list) => { ...
code_fim
hard
{ "lang": "rust", "repo": "shybyte/risp", "path": "/src/eval.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(eval_str(r" (do (def x 1234) (def plus20 (fn [x y] (+ x y 20))) (plus20 1 2) x ) "), Ok(Int(1234))); } #[test] fn test_eval_defn() { assert_eq!(eval_str(r" (do (defn plus20 [x y] (+ x y 20)) (plus20 1 2) ) "), Ok(...
code_fim
hard
{ "lang": "rust", "repo": "shybyte/risp", "path": "/src/eval.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: linebender/runebender path: /runebender-lib/src/bez_cache.rs //! A mapping of component ids to glyphs that contain that id //! //! this is used to invalidate glyphs appropriately when components change use std::borrow::Cow; use std::collections::HashMap; use std::sync::Arc; use druid::kurbo::{...
code_fim
hard
{ "lang": "rust", "repo": "linebender/runebender", "path": "/runebender-lib/src/bez_cache.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }