text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>3463, 62497, 36763, -23213, 51852, -19348, 85914, 7920, 20129, 49462, -3115, -33163, -55592, -46299, -30425, 3169, -56949, -40171, 63363, 7086, 97542, -11425, -62390, -6570, 35953, 74457, 40908, -25679, -74921, 97436, -11215, -9904, 80789, 45694, -66463, -71...
code_fim
hard
{ "lang": "rust", "repo": "mapx/leetcode-rust", "path": "/src/n1330_reverse_subarray_to_maximize_array_value.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mapx/leetcode-rust path: /src/n1330_reverse_subarray_to_maximize_array_value.rs -52644, -55111, -61895, -50660, 21600, -29881, 16838, 49417, -49278, -22026, -90723, 26588, 85166, 31908, 75304, -64135, 92130, 51081, 54869, -74256, -20522, 86607, -27006, -75828, ...
code_fim
hard
{ "lang": "rust", "repo": "mapx/leetcode-rust", "path": "/src/n1330_reverse_subarray_to_maximize_array_value.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..n - 2 { let a_i = arr.get_at(i); let ai_rem = a_i - 2020; for j in i + 1..n - 1 { let a_j = arr.get_at(j); let a_i_j = ai_rem + a_j; for k in j + 1..n { let a_k = arr.get_at(k); let a_i_j_k = a_i_j ...
code_fim
hard
{ "lang": "rust", "repo": "aldanor/aoc-2020", "path": "/rust/src/day01/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aldanor/aoc-2020 path: /rust/src/day01/mod.rs use arrayvec::ArrayVec; use crate::utils::*; #[inline] fn find_sum_min2(s: &[i16]) -> i16 { let (mut a, mut b) = (i16::MAX, i16::MAX); for x in s { if *x >= b { // most likely continue; } else if *x >...
code_fim
hard
{ "lang": "rust", "repo": "aldanor/aoc-2020", "path": "/rust/src/day01/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] pub fn part1(s: &[u8]) -> u32 { let s = parse_input(s); let mut arr = [0i16; 4096]; for &x in &s { let x = x.min(2020) as usize; let rem = 2020 - x; arr.set_at(rem, x as _); let y = arr.get_at(x); if y != 0 { return (x as u32) * (y ...
code_fim
hard
{ "lang": "rust", "repo": "aldanor/aoc-2020", "path": "/rust/src/day01/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn mulr(inst: &Vec<usize>, reg: &Vec<usize>) -> Vec<usize> { instrr(inst, reg, &|a, b| a * b) } fn muli(inst: &Vec<usize>, reg: &Vec<usize>) -> Vec<usize> { instri(inst, reg, &|a, b| a * b) } fn banr(inst: &Vec<usize>, reg: &Vec<usize>) -> Vec<usize> { instrr(inst, reg, &|a, b| a & b) } fn ...
code_fim
hard
{ "lang": "rust", "repo": "lawrencecrane/adventofcode2018", "path": "/day_16_chronal_classification/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lawrencecrane/adventofcode2018 path: /day_16_chronal_classification/src/main.rs extern crate regex; use std::fs::File; use std::io::prelude::*; use std::collections::HashSet; use std::collections::HashMap; use regex::Regex; const OPTCODES: [&Fn(&Vec<usize>, &Vec<usize>) -> Vec<usize>; 16] = [ ...
code_fim
hard
{ "lang": "rust", "repo": "lawrencecrane/adventofcode2018", "path": "/day_16_chronal_classification/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let output = program.lines() .filter(|line| line.len() != 0) .fold(vec![0, 0, 0, 0], |out, line| { let inst: Vec<usize> = line.split(' ').map(|x| -> usize { x.parse().unwrap() }).collect(); let mapping = optcode_mapping.get(&inst[0]).unwrap(); OPTCOD...
code_fim
hard
{ "lang": "rust", "repo": "lawrencecrane/adventofcode2018", "path": "/day_16_chronal_classification/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub injection_mode: InjectionMode, pub dll_release: ReleaseChannel, } impl Config { fn new(filename: &str) -> Result<Config, &'static str> { let file_contents = fs::read_to_string(filename).or(Err("failed to read file"))?; serde_yaml::from_str(&file_contents).or(Err("failed ...
code_fim
medium
{ "lang": "rust", "repo": "mcoot/TribesLauncher2", "path": "/tribeslauncher/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mcoot/TribesLauncher2 path: /tribeslauncher/src/config.rs use std::fs; use serde::{Serialize, Deserialize}; use serde_yaml; #[derive(Serialize, Deserialize, Debug)] pub enum LoginServer { HiRez, TAServer, Custom {ip: String}, } #[derive(Serialize, Deserialize, Debug)] pub enum Inje...
code_fim
medium
{ "lang": "rust", "repo": "mcoot/TribesLauncher2", "path": "/tribeslauncher/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let serialized = serde_yaml::to_string(self).or(Err("failed to serialize"))?; fs::write(filename, serialized).or(Err("failed to write file")) } }<|fim_prefix|>// repo: mcoot/TribesLauncher2 path: /tribeslauncher/src/config.rs use std::fs; use serde::{Serialize, Deserialize}; use serde_ya...
code_fim
hard
{ "lang": "rust", "repo": "mcoot/TribesLauncher2", "path": "/tribeslauncher/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ing-systems/crcxx path: /src/internals/crc32.rs //! Low level CRC-32 functions. use crate::imp_crc; imp_crc!(u32); #[inline] fn update_slice_by_4<'a>( mut crc: u32, mut bytes: &'a [u8], lut: &[[u32; 256]], reflect: bool, ) -> (u32, &'a [u8]) { const STEP: usize = 4; assert!(lut.le...
code_fim
hard
{ "lang": "rust", "repo": "ing-systems/crcxx", "path": "/src/internals/crc32.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for sample in SAMPLES { assert_eq!( update_no_lut(INIT, WIDTH, POLY, REFLECT, sample.0.as_bytes()) ^ XOR_OUT, sample.1 ); assert_eq!( update_lut_32(INIT, sample.0.as_bytes(), &lut32, REFLECT) ^ XOR_OUT, ...
code_fim
hard
{ "lang": "rust", "repo": "ing-systems/crcxx", "path": "/src/internals/crc32.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nabijaczleweli/gen-epub-book.rs path: /tests/ops/book/from_elements/incorrect/missing.rs use gen_epub_book::ops::{BookElement, EPubBook}; use gen_epub_book::Error; use chrono::DateTime; #[test] fn name() { assert_eq!(EPubBook::from_elements(vec![BookElement::Author("nabijaczleweli".to_stri...
code_fim
hard
{ "lang": "rust", "repo": "nabijaczleweli/gen-epub-book.rs", "path": "/tests/ops/book/from_elements/incorrect/missing.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(EPubBook::from_elements(vec![BookElement::Name("Simple ePub demonstration".to_string()), BookElement::Author("nabijaczleweli".to_string()), BookElement::Date(DateTime::parse_from_rfc3339("2017-02-08T15:3...
code_fim
hard
{ "lang": "rust", "repo": "nabijaczleweli/gen-epub-book.rs", "path": "/tests/ops/book/from_elements/incorrect/missing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn language() { assert_eq!(EPubBook::from_elements(vec![BookElement::Name("Simple ePub demonstration".to_string()), BookElement::Author("nabijaczleweli".to_string()), BookElement::Date(DateTime::parse_from_...
code_fim
hard
{ "lang": "rust", "repo": "nabijaczleweli/gen-epub-book.rs", "path": "/tests/ops/book/from_elements/incorrect/missing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timando/rsip path: /src/headers/untyped/contact.rs use rsip_derives::{ToTypedHeader, UntypedHeader}; /// The `Contact` header in its [untyped](super) f<|fim_suffix|> PartialEq, Eq, Clone)] pub struct Contact(String);<|fim_middle|>orm. #[derive(ToTypedHeader, UntypedHeader, Debug,
code_fim
easy
{ "lang": "rust", "repo": "timando/rsip", "path": "/src/headers/untyped/contact.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>orm. #[derive(ToTypedHeader, UntypedHeader, Debug, PartialEq, Eq, Clone)] pub struct Contact(String);<|fim_prefix|>// repo: timando/rsip path: /src/headers/untyped/contact.rs use rsip_derives::{ToTypedHeader, UntypedHeader}; <|fim_middle|> /// The `Contact` header in its [untyped](super) f
code_fim
easy
{ "lang": "rust", "repo": "timando/rsip", "path": "/src/headers/untyped/contact.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>*; pub use adminaction::*; pub use policy::*; pub use resource::*; pub use statement::*;<|fim_prefix|>// repo: 01intelligence/hulk path: /src/iam/policy/mod.rs mod action; mod adminaction; mod policy; mo<|fim_middle|>d resource; mod statement; pub use action::
code_fim
easy
{ "lang": "rust", "repo": "01intelligence/hulk", "path": "/src/iam/policy/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 01intelligence/hulk path: /src/iam/policy/mod.rs mod action; mod adminaction; mod policy; mod resource; mod statement; pub use action::<|fim_suffix|>; pub use resource::*; pub use statement::*;<|fim_middle|>*; pub use adminaction::*; pub use policy::*
code_fim
easy
{ "lang": "rust", "repo": "01intelligence/hulk", "path": "/src/iam/policy/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>; pub use resource::*; pub use statement::*;<|fim_prefix|>// repo: 01intelligence/hulk path: /src/iam/policy/mod.rs mod action; mod adminaction; mod policy; mo<|fim_middle|>d resource; mod statement; pub use action::*; pub use adminaction::*; pub use policy::*
code_fim
medium
{ "lang": "rust", "repo": "01intelligence/hulk", "path": "/src/iam/policy/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(res) = response.result { return Ok(res.order_id); } else { return Err(Error::Http(response.into())); } } } #[async_trait] impl CancelOrders for Client { async fn cancel_order(&self, active_order_id: ActiveOrderId, symbol: &str) -> Result...
code_fim
hard
{ "lang": "rust", "repo": "foonsun/bybit-rs", "path": "/src/rest/orders.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foonsun/bybit-rs path: /src/rest/orders.rs use crate::http::{Client, Query, Response}; use crate::order::*; use crate::{Error, Result}; use async_trait::async_trait; use serde::Serialize; #[derive(Serialize, Clone, Debug, Default)] pub struct ListOrdersFilter { pub symbol: String, pub o...
code_fim
hard
{ "lang": "rust", "repo": "foonsun/bybit-rs", "path": "/src/rest/orders.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[async_trait] pub trait UpdateOrders { async fn update_order( &self, active_order_id: ActiveOrderId, data: UpdateOrderData, ) -> Result<OrderId>; } #[async_trait] pub trait CancelOrders { async fn cancel_order(&self, active_order_id: ActiveOrderId, symbol: &str) -> Re...
code_fim
hard
{ "lang": "rust", "repo": "foonsun/bybit-rs", "path": "/src/rest/orders.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.e } } impl DerefMut for Event { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { &mut self.e } }<|fim_prefix|>// repo: FerionVE/guion_sdl2 path: /src/event/mod.rs use crate::event::key::Key; use crate::event::destination::SDLDestination; use super::*; <|fim...
code_fim
hard
{ "lang": "rust", "repo": "FerionVE/guion_sdl2", "path": "/src/event/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FerionVE/guion_sdl2 path: /src/event/mod.rs use crate::event::key::Key; use crate::event::destination::SDLDestination; use super::*; pub mod imp; pub mod destination; pub mod consuming; pub mod position; pub mod key; pub mod cast; #[derive(Clone)] pub struct Event { pub e: SDLEvent, ws...
code_fim
medium
{ "lang": "rust", "repo": "FerionVE/guion_sdl2", "path": "/src/event/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Deref for Event { type Target = SDLEvent; #[inline] fn deref(&self) -> &Self::Target { &self.e } } impl DerefMut for Event { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { &mut self.e } }<|fim_prefix|>// repo: FerionVE/guion_sdl2 path: /src/eve...
code_fim
medium
{ "lang": "rust", "repo": "FerionVE/guion_sdl2", "path": "/src/event/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sajayantony/oras-rs path: /krustlet/crates/krator-derive/src/lib.rs //! A crate for deriving state machine traits in Kubelet. Right now this crate only consists of a //! derive macro for the `TransitionTo` trait. In addition to the `derive` attribute, this macro //! also requires the use of a cu...
code_fim
hard
{ "lang": "rust", "repo": "sajayantony/oras-rs", "path": "/krustlet/crates/krator-derive/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[proc_macro_derive(TransitionTo, attributes(transition_to))] pub fn derive_transition_to(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); let name = input.ident; let generics = input.generics; let mut transitions = get_transitions(input.attrs); ...
code_fim
hard
{ "lang": "rust", "repo": "sajayantony/oras-rs", "path": "/krustlet/crates/krator-derive/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(id) = attr.path.get_ident() { if id == ATTRIBUTE_NAME { attr.parse_args::<Transitions>().ok() } else { None } } else { None } } fn generate_impl(transitions: Transitions, generics: Generics, name: Ident) -> TokenStream { ...
code_fim
hard
{ "lang": "rust", "repo": "sajayantony/oras-rs", "path": "/krustlet/crates/krator-derive/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RGafiyatullin/tfsi path: /src/providers/one/provide_once_tests.rs use crate::prelude::*; use providers::*; #[test] fn t01() { struct A; let p = ProvideOnce::from(A); let _val_a: A = p.provide(); } #[test] #[should_panic] fn t02() { struct A; <|fim_suffix|> let _val_a: A =...
code_fim
easy
{ "lang": "rust", "repo": "RGafiyatullin/tfsi", "path": "/src/providers/one/provide_once_tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let p = ProvideOnce::from(A); let _val_a: A = p.provide(); let _val_a: A = p.provide(); }<|fim_prefix|>// repo: RGafiyatullin/tfsi path: /src/providers/one/provide_once_tests.rs use crate::prelude::*; use providers::*; #[test] fn t01() { struct A; let p = ProvideOnce::from(A); ...
code_fim
easy
{ "lang": "rust", "repo": "RGafiyatullin/tfsi", "path": "/src/providers/one/provide_once_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oblique/aoc-2020 path: /src/bin/day16.rs use anyhow::{Context, Result}; use aoc_2020::file_lines; use std::collections::HashMap; use std::iter; use std::ops::RangeInclusive; struct Data { rules: HashMap<String, RuleRange>, my_ticket: Vec<u32>, nearby_tickets: Vec<Vec<u32>>, } struc...
code_fim
hard
{ "lang": "rust", "repo": "oblique/aoc-2020", "path": "/src/bin/day16.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> for (_, rule) in &self.rules { if rule.contains(field) { return true; } } false } fn discard_invalid_tickets(&mut self) { let mut i = 0; 'outer: while i < self.nearby_tickets.len() { for j in 0..self.nea...
code_fim
hard
{ "lang": "rust", "repo": "oblique/aoc-2020", "path": "/src/bin/day16.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let (pos, max) = fields_count .iter() .enumerate() .max_by_key(|x| x.1) .unwrap(); let max_count = fields_count.iter().filter(|x| *x == max).count(); if max_...
code_fim
hard
{ "lang": "rust", "repo": "oblique/aoc-2020", "path": "/src/bin/day16.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: compclub/projects path: /jp-quantum/src/vector.rs use std::fmt; use std::ops::{Add, Sub}; pub type Complex = nalgebra::Complex<f64>; /// A vector of length (2^n) of complex numbers. #[derive(Debug, Clone, PartialEq)] pub struct Vector { pub(crate) size: usize, pub(crate) vector: nalgeb...
code_fim
hard
{ "lang": "rust", "repo": "compclub/projects", "path": "/jp-quantum/src/vector.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn norm(&self) -> f64 { self.vector.norm() } } impl Distribution { pub fn sample(&self) -> String { use rand::prelude::*; let mut rng = thread_rng(); self.probabilities_of_bitstrings .choose_weighted(&mut rng, |(p, _)| *p) .unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "compclub/projects", "path": "/jp-quantum/src/vector.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sagebind/websnip path: /src/pdf.rs use std::path::PathBuf; use std::sync::mpsc::{self, Sender, Receiver}; use std::sync::Mutex; use std::thread::{self, Builder, Thread}; use wkhtmltopdf::PdfApplication; pub struct PdfGenerator { sender: Mutex<Sender<Request>>, } impl PdfGenerator { pu...
code_fim
hard
{ "lang": "rust", "repo": "sagebind/websnip", "path": "/src/pdf.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Err(e) = pdf.save(&request.path) { warn!("error saving pdf: {:?}", e); } request.requestor.unpark(); } } } struct Request { title: String, html: String, path: PathBuf, requestor: Thread, }<|fim_prefix|>// repo: sagebi...
code_fim
hard
{ "lang": "rust", "repo": "sagebind/websnip", "path": "/src/pdf.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Menschenkindlein/left-right path: /src/main.rs extern crate piston_window; extern crate left_right; extern crate find_folder; use piston_window::*; use left_right::App; fn main() { let mut window: PistonWindow = WindowSettings::new("Left/Right", [512; 2]).build().unwrap(); let assets...
code_fim
hard
{ "lang": "rust", "repo": "Menschenkindlein/left-right", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut app = App::new(); while let Some(e) = window.next() { e.update(|args| app.update(args.dt)); e.press(|button| if let Button::Keyboard(key) = button { app.key(key) }); window.draw_2d(&e, |c, g| app.view().render(c, g, &mut glyphs)); } }<|fim_p...
code_fim
hard
{ "lang": "rust", "repo": "Menschenkindlein/left-right", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kumavale/toydb path: /src/main.rs use std::collections::HashMap; #[derive(Clone, Debug, PartialEq)] enum Type { Int(Option<i32>), Text(Option<String>), } #[derive(Clone, Debug)] struct Table { name: String, order: Vec<String>, column: HashMap<String, Type>, max...
code_fim
hard
{ "lang": "rust", "repo": "kumavale/toydb", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut table1 = Table::new( "table1", vec![ ("id", Type::Int(None)), ("name", Type::Text(None)), ("price", Type::Int(None)), ]); table1.insert(vec![("id", Type::Int(Some(1))), ("name", Type::Text(Some("apple".to_owned...
code_fim
hard
{ "lang": "rust", "repo": "kumavale/toydb", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let dir = vec![(-1, 0), (0, -1), (0, 1), (1, 0)]; for (dr, dc) in dir { if dr == 0 && dc == 0 { continue; } let (nr, nc) = (r_i as i64 + dr, c_i as i64 + dc); if !(0..h as i64).contains(&nr) || !(0..w as i64).contains(&nc) { ...
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/agc033/src/bin/a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/agc033/src/bin/a.rs use std::{cmp::max, cmp::Reverse, collections::BinaryHeap}; use proconio::input; use proconio::marker::Chars; fn main() { input! { h: usize, w: usize, a: [Chars; h], }; let inf = h * w + ...
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/agc033/src/bin/a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samuwen/rq_injector path: /src/image_loader.rs use crate::request_utils::get_image_from_remote; use getset::Getters; use log::*; use std::fs::File; use std::path::PathBuf; #[derive(Clone, Debug, Default, Getters)] #[getset(get = "pub")] pub struct ImageLoader { path: PathBuf, map_id: St...
code_fim
medium
{ "lang": "rust", "repo": "samuwen/rq_injector", "path": "/src/image_loader.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn load_map_image(&mut self, is_offline: bool, mut image_path: PathBuf) { let mut path = image_path.clone(); path.push(format!("{}.jpg", self.map_id)); self.path = path; info!("Attempting to load image at: {:?}", self.path); let file_result = File::open(&sel...
code_fim
medium
{ "lang": "rust", "repo": "samuwen/rq_injector", "path": "/src/image_loader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pbrenna/oa_evol path: /hill_local/src/main.rs extern crate oarray; //use simplelog::*; use std::env; mod hill_climb; use oarray::OArray; use std::io::{self}; fn main() { let t = env::args() .nth(1) .expect("Fornire parametro t come argomento") .parse() .unw...
code_fim
hard
{ "lang": "rust", "repo": "pbrenna/oa_evol", "path": "/hill_local/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>arget_t = t; let old_fit = oa.fitness(); let old_oa = oa.clone(); let mut count = 0; loop { let out = hill_climb::hill_climb(oa); if out.0.fitness() > -1.0{ println!("{}", old_oa); println!("{}", out.0); ...
code_fim
hard
{ "lang": "rust", "repo": "pbrenna/oa_evol", "path": "/hill_local/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: visioncortex/polypartition path: /webapp/src/polypartition/triangulation/monotone.rs use crate::polypartition::{EdgeVec, Polygon, PolygonInterface}; use crate::polypartition::util::{add_diagonal, f64_approximately, is_above, is_convex, MonotoneVertex, ScanLineEdge}; use crate::polypartition::enu...
code_fim
hard
{ "lang": "rust", "repo": "visioncortex/polypartition", "path": "/webapp/src/polypartition/triangulation/monotone.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> helpers[index] = v_index2; }, VertexType::Regular => { if is_above(&v.p, &vertices[v.previous].p) { if edge_tree_pointers[v.previous].is_none() { return Err("Pointer is NULL."); } ...
code_fim
hard
{ "lang": "rust", "repo": "visioncortex/polypartition", "path": "/webapp/src/polypartition/triangulation/monotone.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut new_edge = ScanLineEdge::default(); new_edge.p1 = v2.p; new_edge.p2 = vertices[v2.next].p; new_edge.index = v_index2; let ptr = edge_tree.insert(new_edge); edge_tree_pointers[v_i...
code_fim
hard
{ "lang": "rust", "repo": "visioncortex/polypartition", "path": "/webapp/src/polypartition/triangulation/monotone.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use blockchain::{Block, BlockChain}; pub use node::Node; pub use peer_discovery::{read_node_config, ConnectionManager, PeerError, ProtocolMessage}; pub use utxo::{Transaction, TransactionError, UTXO};<|fim_prefix|>// repo: HirotoShioi/nano_chain path: /src/lib.rs extern crate base64; extern crate ctr...
code_fim
easy
{ "lang": "rust", "repo": "HirotoShioi/nano_chain", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HirotoShioi/nano_chain path: /src/lib.rs extern crate base64; extern crate ctrlc; extern crate hex; extern crate log; extern crate pretty_env_logger; extern crate rand; extern crate serde; extern crate serde_json; extern crate sha3; <|fim_suffix|>pub use blockchain::{Block, BlockChain}; pub use...
code_fim
easy
{ "lang": "rust", "repo": "HirotoShioi/nano_chain", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_time_format() { let mut time = FormattedTime::Fmt1(Duration::new(30, 0)); assert_eq!(String::from("00:30"), format!("{}", time)); time = FormattedTime::Fmt1(Duration::new(90, 0)); assert_eq!(String::from("01:30"), format!("{}", time)); time =...
code_fim
hard
{ "lang": "rust", "repo": "koushiro/pbar", "path": "/src/format.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koushiro/pbar path: /src/format.rs use std::fmt; use std::time::Duration; use crate::util::*; const KIB: f64 = 1024.; const MIB: f64 = 1_048_576.; const GIB: f64 = 1_073_741_824.; const TIB: f64 = 1_099_511_627_776.; const KB: f64 = 1e3; const MB: f64 = 1e6; const GB: f64 = 1e9; const TB: f64...
code_fim
hard
{ "lang": "rust", "repo": "koushiro/pbar", "path": "/src/format.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, 'b, T> SliceMut<'a, uint, MutRow<'a, T>> for MutRow<'b, T> { fn slice_mut(&'a mut self, start: uint, end: uint) -> Result<MutRow<'a, T>> { self.0.slice_mut(start, end).map(MutRow) } from_to_mut!(MutRow<'a, T>); } impl<'a, 'b, T> SliceMut<'a, (uint, uint), MutView<'a, T>> for...
code_fim
hard
{ "lang": "rust", "repo": "flying-sheep/linalg.rs", "path": "/src/slice.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.0.slice(start, end).map(Row) } from_to!(Row<'a, T>); } macro_rules! from_to2 { ($ty:ty) => { fn slice_from(&'a self, start: (uint, uint)) -> Result<$ty> { Slice::slice(self, start, self.size()) } fn slice_to(&'a self, end: (uint, uint)) -> Re...
code_fim
hard
{ "lang": "rust", "repo": "flying-sheep/linalg.rs", "path": "/src/slice.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flying-sheep/linalg.rs path: /src/slice.rs use std::mem; use std::raw::{self, Repr}; use { Col, ColVec, Diag, Error, Mat, MutCol, MutDiag, MutRow, MutView, Result, Row, RowVec, View, strided, }; use traits::{Matrix, Slice, SliceMut}; impl<'a, T> ::Slice<'a, uint, strided::Slice<'a, T>>...
code_fim
hard
{ "lang": "rust", "repo": "flying-sheep/linalg.rs", "path": "/src/slice.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn is_comment_should_return_false_when_body_string() { assert!(!Line::is_comment("吾輩は猫である")); } #[test] fn is_comment_should_return_true_when_comment_string() { assert!(Line::is_comment("// 吾輩は猫である")); } #[test] fn is_comment_should_return_true_whe...
code_fim
hard
{ "lang": "rust", "repo": "Hitomaru/naromat", "path": "/src/entities/line.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn get_min() { let source = "我"; let expected = " 我"; let line = Line::new(&source); assert_eq!(line.get(), expected); } #[test] fn is_comment_should_return_false_when_body_string() { assert!(!Line::is_comment("吾輩は猫である")); } #[t...
code_fim
hard
{ "lang": "rust", "repo": "Hitomaru/naromat", "path": "/src/entities/line.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hitomaru/naromat path: /src/entities/line.rs use crate::entities::sentence::Sentence; use regex::Regex; /// Structure of novel line /// /// Lines are defined below: /// * Starts after breakline or chapter head /// * End with breakline pub struct Line { elements: Vec<Sentence>, } /// Implem...
code_fim
hard
{ "lang": "rust", "repo": "Hitomaru/naromat", "path": "/src/entities/line.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timvisee/mpris-rs path: /src/find.rs use failure::Fail; use std::rc::Rc; use dbus::ffidisp::{BusType, Connection}; use dbus::{arg, Message}; use super::DBusError; use crate::player::{Player, DEFAULT_TIMEOUT_MS, MPRIS2_PATH, MPRIS2_PREFIX}; use crate::pooled_connection::PooledConnection; use c...
code_fim
hard
{ "lang": "rust", "repo": "timvisee/mpris-rs", "path": "/src/find.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(first_paused.or(first_with_track).or(Some(0))) } /// Find a [`Player`] by it's MPRIS [`Identity`][identity]. Returns [`NoPlayerFound`](FindingError::NoPlayerFound) if no direct match found. /// /// [identity]: https://specifications.freedesktop.org/mpris-spec/latest/Media_Playe...
code_fim
hard
{ "lang": "rust", "repo": "timvisee/mpris-rs", "path": "/src/find.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hdamron17/pico-args path: /test-apps/pico-args-app/app.rs use pico_args::Arguments; #[derive(Debug)] struct AppArgs { help: bool, number: u32, opt_number: Option<u32>, width: u32, free: Vec<String>, } fn parse_width(s: &str) -> Result<u32, String> { let w = s.parse().ma...
code_fim
medium
{ "lang": "rust", "repo": "hdamron17/pico-args", "path": "/test-apps/pico-args-app/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Err(e) = submain() { eprintln!("Error: {}.", e); } } fn submain() -> Result<(), pico_args::Error> { let mut args = Arguments::from_env(); let args = AppArgs { help: args.contains(["-h", "--help"]), number: args.value_from_str("--number")?, opt_number...
code_fim
hard
{ "lang": "rust", "repo": "hdamron17/pico-args", "path": "/test-apps/pico-args-app/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let w = s.parse().map_err(|_| "not a number")?; if w != 0 { Ok(w) } else { Err("width must be positive".to_string()) } } fn main() { if let Err(e) = submain() { eprintln!("Error: {}.", e); } } fn submain() -> Result<(), pico_args::Error> { let mut args...
code_fim
medium
{ "lang": "rust", "repo": "hdamron17/pico-args", "path": "/test-apps/pico-args-app/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xfe/experiments path: /rust/hello/src/threads.rs use std::sync::mpsc; use std::sync::{Arc, Condvar, Mutex}; use std::{thread, time}; fn simple_mutex() { let m = Arc::new(Mutex::new(0)); // Clone the pointer because we don't want to move m // into the thread -- it'll become inacces...
code_fim
hard
{ "lang": "rust", "repo": "0xfe/experiments", "path": "/rust/hello/src/threads.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let pair2 = Arc::clone(&pair); let tid2 = thread::spawn(move || { { // Deref the Arc pointer, then take a ref to the tuple let (lock, cv) = &*pair2; // lock() returns a MutexGuard, which is a scoped (RAII) mutex. let mut done = lock.lock().u...
code_fim
hard
{ "lang": "rust", "repo": "0xfe/experiments", "path": "/rust/hello/src/threads.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jkrueger1/stm32-eth path: /src/bin/seqgen.rs #![no_main] #![no_std] #![feature(cell_update)] #[macro_use] extern crate log; #[macro_use] extern crate cortex_m; #[macro_use] extern crate cortex_m_rt; extern crate stm32f429 as board; extern crate stm32_eth as eth; extern crate panic_itm; extern c...
code_fim
hard
{ "lang": "rust", "repo": "jkrueger1/stm32-eth", "path": "/src/bin/seqgen.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>static LOGGER: ItmLogger = ItmLogger; static ETH_TIME: Mutex<Cell<i64>> = Mutex::new(Cell::new(0)); entry!(main); fn main() -> ! { // enable logging if someone is listening on ITM if itm().is_fifo_ready() { log::set_logger(&LOGGER).unwrap(); log::set_max_level(LevelFilter::Info);...
code_fim
hard
{ "lang": "rust", "repo": "jkrueger1/stm32-eth", "path": "/src/bin/seqgen.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn from_str(s: &str) -> Result<Self, Self::Err> { let instructions: Vec<Instruction> = s.lines().map(|line| line.parse().unwrap()).collect(); Ok(BootCode { instructions }) } } #[cfg(test)] mod tests { use super::*; #[test] fn example() { let mut code: BootCod...
code_fim
hard
{ "lang": "rust", "repo": "Mirko-von-Leipzig/advent-of-code-2020", "path": "/mirko/src/bin/day_08.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mirko-von-Leipzig/advent-of-code-2020 path: /mirko/src/bin/day_08.rs use std::collections::HashSet; fn main() { let mut code: BootCode = include_str!("../../inputs/08.txt").parse().unwrap(); let (part_1, _) = code.run_code(); let part_2 = code.fix_code(); println!("part 1: {}"...
code_fim
hard
{ "lang": "rust", "repo": "Mirko-von-Leipzig/advent-of-code-2020", "path": "/mirko/src/bin/day_08.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sonos/tract path: /examples/pytorch-resnet/src/main.rs use tract_ndarray::Array; use tract_onnx::prelude::*; fn main() -> TractResult<()> { let model = tract_onnx::onnx() // load the model .model_for_path("resnet.onnx")? // specify input type and shape .with_...
code_fim
hard
{ "lang": "rust", "repo": "sonos/tract", "path": "/examples/pytorch-resnet/src/main.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let result = model.run(tvec!(image.into()))?; // find and display the max value with its index let best = result[0] .to_array_view::<f32>()? .iter() .cloned() .zip(1..) .max_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); println!("result: {best:?}"); ...
code_fim
hard
{ "lang": "rust", "repo": "sonos/tract", "path": "/examples/pytorch-resnet/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fonline-roleplay/fo_proto_format path: /src/serde_toml.rs use serde::{Deserialize, Serialize, de::DeserializeOwned}; use std::{collections::BTreeMap, path::Path}; use std::fmt::Debug; pub trait Proto: Debug + DeserializeOwned + Debug { fn proto_id(&self) -> u16; } #[derive(Deserialize, Ser...
code_fim
hard
{ "lang": "rust", "repo": "fonline-roleplay/fo_proto_format", "path": "/src/serde_toml.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Serialize, Debug)] #[allow(bad_style)] pub struct Protos<T> { #[serde(alias = "Critter proto")] Proto: Vec<T>, } pub fn proto_from_toml<T: Proto>(toml: &str) -> Result<Protos<T>, toml::de::Error> { toml::de::from_str(toml) } fn proto_from_ini<T: Proto>(ini: &str, filena...
code_fim
hard
{ "lang": "rust", "repo": "fonline-roleplay/fo_proto_format", "path": "/src/serde_toml.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn fopro_toml_all() { for file in std::fs::read_dir("../FO4RP/proto/items/") .unwrap() .filter_map(|r| r.ok()) { let file = file.path(); if !file.is_file() || file.extension() != Some...
code_fim
hard
{ "lang": "rust", "repo": "fonline-roleplay/fo_proto_format", "path": "/src/serde_toml.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut new_path: PathBuf = base_path; let original_filename = original_path .file_name() .ok_or(anyhow!("the path terminates in `..` or `/`"))? .to_str() .ok_or(anyhow!("path with non-UTF-8 character"))?; let new_filename = format!("__chaosfs__{}__", original_f...
code_fim
medium
{ "lang": "rust", "repo": "James-Dao/toda", "path": "/src/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: James-Dao/toda path: /src/utils.rs use std::path::{Path, PathBuf}; use anyhow::{anyhow, Result}; pub fn encode_path<P: AsRef<Path>>(original_path: P) -> Result<(PathBuf, PathBuf)> { let original_path: PathBuf = original_path.as_ref().to_owned(); <|fim_suffix|> let mut new_path: PathBuf...
code_fim
medium
{ "lang": "rust", "repo": "James-Dao/toda", "path": "/src/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let n: usize = s .parse() .map_err(|err: ParseIntError| ParseError::ValueInvalid(err.to_string()))?; if n < N_MIN { return Err(ParseError::ValueInvalid( "invalid fixedstring n".to_string(), )); } Ok(Self(n)) ...
code_fim
hard
{ "lang": "rust", "repo": "yutiansut/clickhouse-rs-1", "path": "/clickhouse-data-type/src/fixed_string.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yutiansut/clickhouse-rs-1 path: /clickhouse-data-type/src/fixed_string.rs use std::{convert::TryFrom, num::ParseIntError}; use pest::iterators::Pairs; use crate::{type_name_parser::Rule, ParseError}; <|fim_suffix|> Ok(Self(n)) } } pub(crate) fn get_n(mut fixed_string_pairs: Pairs<...
code_fim
hard
{ "lang": "rust", "repo": "yutiansut/clickhouse-rs-1", "path": "/clickhouse-data-type/src/fixed_string.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if n < N_MIN { return Err(ParseError::ValueInvalid( "invalid fixedstring n".to_string(), )); } Ok(Self(n)) } } pub(crate) fn get_n(mut fixed_string_pairs: Pairs<'_, Rule>) -> Result<FixedStringN, ParseError> { let n_pair = fixed_str...
code_fim
medium
{ "lang": "rust", "repo": "yutiansut/clickhouse-rs-1", "path": "/clickhouse-data-type/src/fixed_string.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } async fn loop_(&self, service_id: &str, tx: &mut Sender) -> Result { let now = Utc::now(); match calc_sunrise_and_set(now, self.secrets.latitude, self.secrets.longitude)? { SunriseAndSet::Daylight(sunrise, sunset) => { if now < sunrise ...
code_fim
hard
{ "lang": "rust", "repo": "eigenein/my-iot-rs", "path": "/src/services/solar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eigenein/my-iot-rs path: /src/services/solar.rs use crate::prelude::*; use crate::services::prelude::*; use spa::{calc_sunrise_and_set, SunriseAndSet}; /// Emits durations to and after sunrise and sunset. #[derive(Deserialize, Debug, Clone, Serialize)] pub struct Solar { /// Message interva...
code_fim
hard
{ "lang": "rust", "repo": "eigenein/my-iot-rs", "path": "/src/services/solar.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Defaults to one minute. const fn default_interval_millis() -> u64 { 60000 } impl Solar { pub fn spawn(self, service_id: String, bus: &mut Bus) -> Result { let mut tx = bus.add_tx(); task::spawn(async move { loop { handle_service_result( ...
code_fim
hard
{ "lang": "rust", "repo": "eigenein/my-iot-rs", "path": "/src/services/solar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: msmithr/Chip8-Rust path: /src/processor/operation_tests.rs use super::cpu::*; use super::operation_map::function_from_instruction; use super::operations::*; use super::CHIP8_HEIGHT; use super::CHIP8_WIDTH; fn setup(bytes: u16) -> (Cpu, Opcode, fn(&mut Cpu, &Opcode)) { let empty_program = Ve...
code_fim
hard
{ "lang": "rust", "repo": "msmithr/Chip8-Rust", "path": "/src/processor/operation_tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (mut cpu, instruction, function) = setup(0xf815); cpu.delay_timer = 0x66; cpu.register[0x8] = 0x3; function(&mut cpu, &instruction); assert_eq!(cpu.register[0x8], 0x3); assert_eq!(cpu.delay_timer, 0x3); } #[test] fn test_set_sound_timer() { let (mut cpu, instruction, funct...
code_fim
hard
{ "lang": "rust", "repo": "msmithr/Chip8-Rust", "path": "/src/processor/operation_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (mut cpu, instruction, function) = setup(0xf555); cpu.register_i = 0x50; cpu.register[0x0] = 0x3; cpu.register[0x1] = 0x8; cpu.register[0x2] = 0x9; cpu.register[0x3] = 0xe; cpu.register[0x4] = 0x1; cpu.register[0x5] = 0xa; function(&mut cpu, &instruction); asser...
code_fim
hard
{ "lang": "rust", "repo": "msmithr/Chip8-Rust", "path": "/src/processor/operation_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>enum Bar<T> { Bla(T) } struct Baz<'a> { inner: for<'b> Foo<Bar<&'b ()>> + 'a, } fn main() {}<|fim_prefix|>// repo: tylerwhall/rust path: /src/test/run-pass/issue-20396.rs // Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at ...
code_fim
medium
{ "lang": "rust", "repo": "tylerwhall/rust", "path": "/src/test/run-pass/issue-20396.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tylerwhall/rust path: /src/test/run-pass/issue-20396.rs // Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // ht...
code_fim
medium
{ "lang": "rust", "repo": "tylerwhall/rust", "path": "/src/test/run-pass/issue-20396.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/vpunpckhbw.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vpunpckhbw_1() { run...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vpunpckhbw.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn vpunpckhbw_4() { run_test(&Instruction { mnemonic: Mnemonic::VPUNPCKHBW, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM7)), operand3: Some(Indirect(RAX, Some(OperandSize::Xmmword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vpunpckhbw.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VPUNPCKHBW, operand1: Some(Direct(YMM6)), operand2: Some(Direct(YMM7)), operand3: Some(IndirectDisplaced(ECX, 1546749812, Some(OperandSize::Ymmword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcas...
code_fim
medium
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vpunpckhbw.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/rust-nlopt path: /build.rs use std::env; fn main() { let dst = cmake::Config::new("./nlopt-2.5.0") .define("BUILD_SHARED_LIBS", "OFF") .define("CMAKE_CXX_COMPILER", "c++") .define("NLOPT_CXX<|fim_suffix|>", "OFF") .define("NLOPT_LINK_PYTHON", "OFF") ...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/rust-nlopt", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("cargo:rustc-link-search=native={}/lib64", dst.display()); if env::var("CARGO_CFG_TARGET_ENV").unwrap() == "msvc" { println!("cargo:rustc-link-lib=static=nlopt"); } }<|fim_prefix|>// repo: iCodeIN/rust-nlopt path: /build.rs use std::env; fn main() { let dst = cmake::Config:...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/rust-nlopt", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns a reference to the document. pub fn document(&self) -> &'a Document { self.doc } /// Returns the node handle. pub fn node(&self) -> NodeHandle<'a> { self.node_id.to_handle(self.doc.tree()) } /// Returns the object type. pub fn get_typed(&self) ...
code_fim
hard
{ "lang": "rust", "repo": "lo48576/fbxcel-dom", "path": "/src/v7400/object.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns object subclass. pub fn subclass(&self) -> &'a str { self.doc .objects_cache() .resolve_class_string(self.object_meta.subclass_sym()) } /// Returns an iterator of destination objects and connection labels. pub fn destination_objects(&self) -...
code_fim
hard
{ "lang": "rust", "repo": "lo48576/fbxcel-dom", "path": "/src/v7400/object.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lo48576/fbxcel-dom path: /src/v7400/object.rs //! Objects-related stuff. //! //! # Object //! //! There are some data associated to objects. //! //! ## Object metadata //! //! Each object node has object metadata. //! A metadata consists of four elements: //! //! ### Object ID //! //! Each objec...
code_fim
hard
{ "lang": "rust", "repo": "lo48576/fbxcel-dom", "path": "/src/v7400/object.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use crate::cursor::{Cursor, FuncCursor}; use crate::dominator_tree::DominatorTree; use crate::flowgraph::ControlFlowGraph; use crate::ir::{types, Function, InstBuilder}; use crate::loop_analysis::{Loop, LoopAnalysis}; use alloc::vec::Vec; #[test] f...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/cranelift/codegen/src/loop_analysis.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }