text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: kurodenjiro/tinychain path: /host/btree/src/file.rs lay for Node { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.leaf { writeln!(f, "leaf node:")?; } else { writeln!(f, "non-leaf node:")?; } write!( f, ...
code_fim
hard
{ "lang": "rust", "repo": "kurodenjiro/tinychain", "path": "/host/btree/src/file.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let root: BlockId = Uuid::new_v4().into(); let node = Node::new(true, None); file.clone() .create_block(txn_id, root.clone(), node, DEFAULT_BLOCK_SIZE) .await?; Ok(BTreeFile::new(file, schema, order, root)) } fn _delete_range<'a>( &...
code_fim
hard
{ "lang": "rust", "repo": "kurodenjiro/tinychain", "path": "/host/btree/src/file.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kurodenjiro/tinychain path: /host/btree/src/file.rs debug!("validate {}", self); debug!("range: {:?}", range); for key in &self.keys { debug!("key: {}", key); assert_eq!(key.value.len(), schema.len()); assert!(range.prefix().len() <= ...
code_fim
hard
{ "lang": "rust", "repo": "kurodenjiro/tinychain", "path": "/host/btree/src/file.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: minus3theta/contest path: /cargo/abc233/src/bin/d.rs #[allow(unused_imports)] use itertools::Itertools; #[allow(unused_imports)] use num::Integer; #[allow(unused_imports)] use proconio::derive_readable; use proconio::fastout; use proconio::input; #[allow(unused_imports)] use proconio::marker::*;...
code_fim
medium
{ "lang": "rust", "repo": "minus3theta/contest", "path": "/cargo/abc233/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input! { n: usize, k: i64, a: [i64; n], } let mut map: HashMap<i64, i64> = Some((0, 1)).into_iter().collect(); let mut sum = 0; let mut ans = 0; for &a in &a { sum += a; ans += map.get(&(sum - k)).unwrap_or(&0); *map.entry(sum).or_ins...
code_fim
medium
{ "lang": "rust", "repo": "minus3theta/contest", "path": "/cargo/abc233/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> b = b * b_factor % divisor; } for i in 0..cycles { if low16(valid_a[i]) == low16(valid_b[i]) { matches += 1; } } matches } fn low16(n: usize) -> usize { n & 0b1111_1111_1111_1111 } #[cfg(test)] mod test { use super::*; #[test] #[igno...
code_fim
hard
{ "lang": "rust", "repo": "twking7/adventofcode2017", "path": "/src/day15.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use super::*; #[test] #[ignore] fn test_part1() { assert_eq!(part1(65, 8921, 40_000_000), 588); } #[test] #[ignore] fn test_part2() { assert_eq!(part2(65, 8921, 1056), 1); assert_eq!(part2(65, 8921, 5_000_000), 309); } }...
code_fim
hard
{ "lang": "rust", "repo": "twking7/adventofcode2017", "path": "/src/day15.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twking7/adventofcode2017 path: /src/day15.rs fn part1(mut a: usize, mut b: usize, cycles: usize) -> usize { let a_factor = 16_807; let b_factor = 48_271; let divisor = 2_147_483_647; let mut matches = 0; for _ in 0..cycles { if low16(a) == low16(b) { matc...
code_fim
medium
{ "lang": "rust", "repo": "twking7/adventofcode2017", "path": "/src/day15.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VenmoTools/OperatingSystem path: /kernel/src/process/types.rs use core::sync::atomic::{AtomicUsize, Ordering}; <|fim_suffix|>atomic_type!(ProcessId,usize,AtomicProcessId,AtomicUsize); atomic_type!(SchemeId,usize,AtomicSchemeId,AtomicUsize); atomic_type!(FileDescriptor,usize,AtomicFileDescriptor...
code_fim
easy
{ "lang": "rust", "repo": "VenmoTools/OperatingSystem", "path": "/kernel/src/process/types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub const MAX_PROCESS: usize = (isize::max_value() as usize) - 1; pub const MAX_FILES: usize = 65_536;<|fim_prefix|>// repo: VenmoTools/OperatingSystem path: /kernel/src/process/types.rs use core::sync::atomic::{AtomicUsize, Ordering}; <|fim_middle|>use system::atomic_type; atomic_type!(ProcessId,usize...
code_fim
hard
{ "lang": "rust", "repo": "VenmoTools/OperatingSystem", "path": "/kernel/src/process/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Debug for AssignedUrl { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "port: {:?}, url: {:?}, max_conn_count: {:?}, id: {:?}", self.port, self.url, self.max_conn_count, self.id) } } fn main() { env_logger::init().unwrap(); let client = Client::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "banyan/rust-localtunnel", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let decoded: AssignedUrl = json::decode(&body).unwrap(); debug!("Decoded: {:?}", decoded); println!("{}", decoded.url); let threads = (0..decoded.max_conn_count).map(|x| { let host = format!("{}:{}", "localtunnel.me", decoded.clone().port); thread::spawn(move || { ...
code_fim
hard
{ "lang": "rust", "repo": "banyan/rust-localtunnel", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: banyan/rust-localtunnel path: /src/main.rs extern crate hyper; extern crate rustc_serialize; use rustc_serialize::json; #[macro_use] extern crate log; extern crate env_logger; use hyper::Client; use hyper::header::Connection; use std::io::{self, Read, Write}; use std::net::{TcpStream, Shutdow...
code_fim
hard
{ "lang": "rust", "repo": "banyan/rust-localtunnel", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn entities_containing(child_id: &str, conn: &Connection) -> Result<Vec<String>> { let mut stmt = conn.prepare_cached( "SELECT entity_id from entity_geometry_parts WHERE contained_entity_id = ?", )?; let ids = stmt .query_map([child_id], |r| Ok(r.get_unwrap(0)))? .m...
code_fim
hard
{ "lang": "rust", "repo": "tyrylu/feel-the-streets", "path": "/server/src/db.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn areas_containing(entity_id: &str, conn: &Connection) -> Result<Vec<i64>> { let mut stmt = conn.prepare_cached("SELECT area_id from area_entities WHERE entity_id = ?")?; let ids = stmt .query_map([entity_id], |r| Ok(r.get_unwrap(0)))? .map(|a| a.expect("Could not get area id"...
code_fim
hard
{ "lang": "rust", "repo": "tyrylu/feel-the-streets", "path": "/server/src/db.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tyrylu/feel-the-streets path: /server/src/db.rs use crate::Result; use osm_api::object::{OSMObject, OSMObjectType}; use osm_api::object_manager::OSMObjectManager; use osm_api::{BoundaryRect, SmolStr}; use rusqlite::named_params; pub use rusqlite::Connection; use std::collections::HashSet; pub f...
code_fim
hard
{ "lang": "rust", "repo": "tyrylu/feel-the-streets", "path": "/server/src/db.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let client = Client { user_id, player_id: player_id.clone(), sender: None, }; clients.write().await.insert(client_id.clone(), client); room .players .write() .await .insert(player_id.clone(), Player::new(player_id, client_id.clone())); return Ok(json(&RegisterRespon...
code_fim
hard
{ "lang": "rust", "repo": "konser/rust-gameserver", "path": "/src/network/handler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> clients.write().await.insert(client_id.clone(), client); room .players .write() .await .insert(player_id.clone(), Player::new(player_id, client_id.clone())); return Ok(json(&RegisterResponse { url: format!("ws://127.0.0.1:8000/ws/{}", client_id), })); } pub async fn handle_un...
code_fim
medium
{ "lang": "rust", "repo": "konser/rust-gameserver", "path": "/src/network/handler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: konser/rust-gameserver path: /src/network/handler.rs use super::socket; use super::Client; use crate::Player; use crate::{Clients, Messages, Result, Room}; use serde::{Deserialize, Serialize}; use uuid::Uuid; use warp::{http::StatusCode, reply::json, Reply}; <|fim_suffix|> clients.write().awai...
code_fim
hard
{ "lang": "rust", "repo": "konser/rust-gameserver", "path": "/src/network/handler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl Source<$Type0> for LaggedFibonacciRand<$Type0> { fn gen(&mut self) -> Result<$Type0> { self.check_init(); let ps = if self.idx < self.short_lag {(self.long_lag + self.idx) - self.short_lag} else {self.idx - self.short_lag} as usize; ...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/rmath", "path": "/src/rand/lagged_fibonacci_rand.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mengsuenyan/rmath path: /src/rand/lagged_fibonacci_rand.rs use crate::rand::{PrimitiveType, Seed, Result, RandError, RandErrKind, LinearCongruentialRand, Source}; use std::fmt::Debug; use std::cell::Cell; /// implements a subtract-with-carry(lagged Fibonacci) algorithm /// lagged fibonacci alg...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/rmath", "path": "/src/rand/lagged_fibonacci_rand.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> OnceSeed<T> { fn new(seed: T) -> Result<Self> { Ok(Self{ seed: Cell::new(Some(seed)) }) } } impl<T: PrimitiveType> Seed<T> for OnceSeed<T> { fn seed(&self) -> Result<T> { self.seed.take().ok_or(RandError::new(RandErrKind::NoNewRandSeedGen, "OnceSeed only generate seed ...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/rmath", "path": "/src/rand/lagged_fibonacci_rand.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Gets an [`Entity`] from its [`EntityId`]. /// /// Returns `None` if the entity no longer exists. This /// could be the case if: /// * The entity has been unloaded (and possibly saved to disk) /// * The entity has died pub fn entity(&self, id: EntityId) -> Result<Entity, Ent...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/quill", "path": "/crates/quill/src/game.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/quill path: /crates/quill/src/game.rs use std::marker::PhantomData; use libcraft_core::Position; use quill_common::entity_init::EntityInit; use crate::{ query::{Query, QueryIter}, EntityBuilder, }; use crate::{Entity, EntityId}; /// Error returned from [`Game::entity`] if the ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/quill", "path": "/crates/quill/src/game.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Game { /// For Quill internal use only. Do not call. #[doc(hidden)] pub fn new() -> Self { Self { _not_send_sync: PhantomData, } } /// Gets an [`Entity`] from its [`EntityId`]. /// /// Returns `None` if the entity no longer exists. This ///...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/quill", "path": "/crates/quill/src/game.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Zach7893/AdventofCode2017 path: /2017/day2/src/main.rs // the goal for this program is to find difference between the max and min number from each row, // then add them all together use std::fs; fn main() { let input_file = fs::read_to_string("/Users/zachspalding/Documents/Advent_of_Co...
code_fim
hard
{ "lang": "rust", "repo": "Zach7893/AdventofCode2017", "path": "/2017/day2/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for line in s.lines() { let v: Vec<u16> = line.split_whitespace().map(|x| x.parse::<u16>().unwrap()).collect(); for i in 0..v.len() { for j in i+1..v.len() { if v[i] % v[j] == 0 { total += v[i] / v[j]; } else if v[j] % v[...
code_fim
medium
{ "lang": "rust", "repo": "Zach7893/AdventofCode2017", "path": "/2017/day2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/standback/src/v1_50.rs use core::cell::{RefCell, UnsafeCell}; #[cfg(feature = "std")] use std::collections::{btree_map, hash_map}; use crate::traits::{Float, Sealed}; pub trait Bool_v1_50: Sealed<bool> { fn then<T, F: FnOnce() -> T>(self, f: F) -> Opt...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/standback/src/v1_50.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { btree_map::Entry::Occupied(entry) => entry.into_mut(), btree_map::Entry::Vacant(entry) => { let value = default(entry.key()); entry.insert(value) } } } } #[cfg(feature = "std")] pub trait HashMapEntry_v1_...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/standback/src/v1_50.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crev-dev/cargo-crev path: /cargo-crev/src/review.rs use crate::{ edit, opts, opts::{CargoOpts, CrateSelector}, prelude::*, term, url_to_status_str, }; use anyhow::format_err; use crev_data::{ proof::{self, ContentExt}, Rating, }; use crev_lib::{self, local::Local, TrustPr...
code_fim
hard
{ "lang": "rust", "repo": "crev-dev/cargo-crev", "path": "/cargo-crev/src/review.rs", "mode": "psm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Some(proof::PackageInfo { id: proof::PackageVersionId::new( PROJECT_SOURCE_CRATES_IO.to_owned(), crate_.name().to_string(), diff_base_version.clone(), ), digest: digest.into_vec(), digest_type: proof::d...
code_fim
hard
{ "lang": "rust", "repo": "crev-dev/cargo-crev", "path": "/cargo-crev/src/review.rs", "mode": "spm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TimonPost/laminar_file_share path: /file_client/src/main.rs use std::{thread, time::Duration}; use cursive::{ traits::Identifiable, views::{Dialog, LinearLayout, Panel}, Cursive, Vec2, }; use file_common::{file_bytes, AcknowledgementBoardView, Options}; use crate::client::Client; ...
code_fim
hard
{ "lang": "rust", "repo": "TimonPost/laminar_file_share", "path": "/file_client/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> cursive } /// Refreshes the UI. fn step_ui(cursive: &mut Cursive, client: &Client) { if let Some(ref mut table_view) = cursive.find_id::<AcknowledgementBoardView>("table") { for x in client.sent_packets() { table_view.mark_sent(*x); } for x in client.acked_pac...
code_fim
hard
{ "lang": "rust", "repo": "TimonPost/laminar_file_share", "path": "/file_client/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m3ta4a/snake path: /src/state.rs use crate::pellet::Pellet; use crate::snake::Snake; use dynamo_lib::geometry::quad::Quad; use dynamo_lib::geometry::Geometry; use dynamo_lib::renderer::render_text::{RenderText, TextRenderer, UNBOUNDED_F32}; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum ...
code_fim
hard
{ "lang": "rust", "repo": "m3ta4a/snake", "path": "/src/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn update_geometry(&self, geometry: &mut Geometry) { if self.snake.visible { for quad in self.walls.iter() { geometry.push_quad(&quad); } for quad in self.snake.body.iter() { geometry.push_quad(&quad); } } if self.pellet.visible { geometry.push...
code_fim
hard
{ "lang": "rust", "repo": "m3ta4a/snake", "path": "/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xiuxiu62/engine-q path: /crates/nu-protocol/src/ast/call.rs use super::Expression; use crate::{DeclId, Span, Spanned}; #[derive(Debug, Clone)] pub struct Call { /// identifier of the declaration to call pub decl_id: DeclId, pub head: Span, pub positional: Vec<Expression>, pu...
code_fim
hard
{ "lang": "rust", "repo": "xiuxiu62/engine-q", "path": "/crates/nu-protocol/src/ast/call.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_flag_expr(&self, flag_name: &str) -> Option<Expression> { for name in &self.named { if flag_name == name.0.item { return name.1.clone(); } } None } pub fn nth(&self, pos: usize) -> Option<Expression> { self.po...
code_fim
medium
{ "lang": "rust", "repo": "xiuxiu62/engine-q", "path": "/crates/nu-protocol/src/ast/call.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: msaf1980/rust-lang-book path: /04_ownership/slice/src/main.rs mod utils; use utils::first_word; use utils::first_word2; fn main() { let s = String::from("hello world"); //String slice range indices must occur at valid UTF-8 character boundaries. //If you attempt to create a string ...
code_fim
medium
{ "lang": "rust", "repo": "msaf1980/rust-lang-book", "path": "/04_ownership/slice/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let hello = first_word(&s); println!("again, {}!", hello); let hello = first_word2(&s); println!("again, {}!", hello); }<|fim_prefix|>// repo: msaf1980/rust-lang-book path: /04_ownership/slice/src/main.rs mod utils; use utils::first_word; use utils::first_word2; fn main() { <|fim_middle...
code_fim
hard
{ "lang": "rust", "repo": "msaf1980/rust-lang-book", "path": "/04_ownership/slice/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn max_explored_trace_per_slice(&self) -> usize { self.max_explored_trace_per_slice } fn max_trace_per_slice(&self) -> usize { self.max_trace_per_slice } fn step_in_anytime(&self) -> bool { self.step_in_anytime } fn is_rough(&self) -> bool { s...
code_fim
hard
{ "lang": "rust", "repo": "apicad1/artifact", "path": "/src/src/analyzer/src/bin/analyzer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apicad1/artifact path: /src/src/analyzer/src/bin/analyzer.rs use llir::Module; use std::collections::HashMap; use std::path::PathBuf; use structopt::StructOpt; use analyzer::{call_graph::*, feature_extraction::*, options::*, slicer::*, symbolic_execution::*, utils::*}; #[derive(StructOpt, Debu...
code_fim
hard
{ "lang": "rust", "repo": "apicad1/artifact", "path": "/src/src/analyzer/src/bin/analyzer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while let Some(event) = self .server .as_mut() .expect("no server mobilized") .next() .now_or_never() { if let Event::DropNonVotingMembers = event.expect("unexpected end of server events") {...
code_fim
hard
{ "lang": "rust", "repo": "rhymu8354/Raft", "path": "/src/server/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rhymu8354/Raft path: /src/server/tests.rs ration to {:?}", ids); } } } async fn expect_no_reconfiguration(&mut self) { self.synchronize().await; self.expect_no_reconfiguration_now(); } fn expect_non_voting_members_added_now( &mut self...
code_fim
hard
{ "lang": "rust", "repo": "rhymu8354/Raft", "path": "/src/server/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rhymu8354/Raft path: /src/server/tests.rs {}, should be {})", *prev_log_index, args.expected_prev_log_index ); assert_eq!( *prev_log_term, args.expected_prev_log_term, "wrong previous log term in append entries (was {}, sho...
code_fim
hard
{ "lang": "rust", "repo": "rhymu8354/Raft", "path": "/src/server/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TmLev/mist path: /mist/src/algorithms/vdb12/providers/public.rs use std::{ cmp::max, error::Error, path::Path, time::{Duration, Instant}, }; use uuid::Uuid; use crate::vdb12::{Application, Cost, InstanceType}; const MINIMAL_RUNTIME: Duration = Duration::from_secs(60); #[deriv...
code_fim
hard
{ "lang": "rust", "repo": "TmLev/mist", "path": "/mist/src/algorithms/vdb12/providers/public.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> total += match cheapest_instance_type { None => return None, Some(instance_type) => instance_type.price * runtime.as_secs_f64(), }; } Some(total) } }<|fim_prefix|>// repo: TmLev/mist path: /mist/src/algorithms/vdb12/providers/pu...
code_fim
hard
{ "lang": "rust", "repo": "TmLev/mist", "path": "/mist/src/algorithms/vdb12/providers/public.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn kankan4(){ let p = Point3{x: 5, y: 10}; println!("p.x = {}",p.x()); } //------------------------------------------------------- #[derive(Debug)] struct Point4<T, U> { x: T, y: U, } impl<T, U> Point4<T, U> where T: Debug+Copy{ fn mixup<V, W>(self, other: Point4<V, W>) -> Point4...
code_fim
hard
{ "lang": "rust", "repo": "honestold3/myrust", "path": "/generics_proj/src/syntax/generic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: honestold3/myrust path: /generics_proj/src/syntax/generic.rs use std::cmp::PartialOrd; use std::fmt::Debug; //pub fn largest<T: PartialOrd + Copy + Debug>(list: &[T]) -> T { pub fn largest<T>(list: &[T]) -> T where T: PartialOrd + Copy + Debug { let mut largest = list[0]; for &item i...
code_fim
hard
{ "lang": "rust", "repo": "honestold3/myrust", "path": "/generics_proj/src/syntax/generic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // group.add(LogPlugin::default()); group.add(CorePlugin::default()); group.add(TransformPlugin::default()); group.add(DiagnosticsPlugin::default()); group.add(InputPlugin::default()); group.add(WindowPlugin::default()); group.add(AssetPlugin::defaul...
code_fim
hard
{ "lang": "rust", "repo": "rezural/bevy-bug-non-default-plugins", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rezural/bevy-bug-non-default-plugins path: /src/main.rs use bevy::{ app::PluginGroupBuilder, asset::AssetPlugin, core::CorePlugin, diagnostic::DiagnosticsPlugin, input::InputPlugin, // log::LogPlugin, prelude::*, render::wireframe::{Wireframe, WireframeConfig, Wir...
code_fim
hard
{ "lang": "rust", "repo": "rezural/bevy-bug-non-default-plugins", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct TestDefaultPlugins; impl PluginGroup for TestDefaultPlugins { fn build(&mut self, group: &mut PluginGroupBuilder) { // group.add(LogPlugin::default()); group.add(CorePlugin::default()); group.add(TransformPlugin::default()); group.add(DiagnosticsPlugin::defa...
code_fim
hard
{ "lang": "rust", "repo": "rezural/bevy-bug-non-default-plugins", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod logging; pub use logging::*; pub mod types; pub use types::*; pub mod time { //! API in rcutils/time.h /// A single point in time, measured in nanoseconds since the Unix epoch. pub type rcutils_time_point_value_t = i64; /// A duration of time, measured in nanoseconds. pub ty...
code_fim
medium
{ "lang": "rust", "repo": "koukemo/rclrust", "path": "/rcl-sys/src/rcutils/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koukemo/rclrust path: /rcl-sys/src/rcutils/mod.rs //! Wrapper of [rcutils](https://github.com/ros2/rcutils) pub mod allocator; pub use allocator::*; pub mod error_handling; pub use error_handling::*; pub mod logging; pub use logging::*; <|fim_suffix|>pub mod time { //! API in rcutils/tim...
code_fim
medium
{ "lang": "rust", "repo": "koukemo/rclrust", "path": "/rcl-sys/src/rcutils/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benluelo/yaupl path: /parse/src/combinators.rs use crate::tokens::{comma, token::Token}; use super::{pointer::Pointer, ParseError}; pub(crate) fn optionally<'a, T>( i: &'a str, ptr: Pointer, f: &dyn Fn(&'a str, Pointer) -> Result<(&'a str, Pointer, T), ParseError>, ) -> (&'a str, P...
code_fim
hard
{ "lang": "rust", "repo": "benluelo/yaupl", "path": "/parse/src/combinators.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn one_or_more<'a, T: Token + Default + 'static>( i: &'a str, ptr: Pointer, f: &'a dyn Fn(&'a str, Pointer) -> Result<(&'a str, Pointer, T), ParseError>, ) -> Result<(&'a str, Pointer, Vec<T>), ParseError> { let mut i = i.clone(); let mut ptr = ptr.clone(); loop { ...
code_fim
hard
{ "lang": "rust", "repo": "benluelo/yaupl", "path": "/parse/src/combinators.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ldicocco/rsl10-pac path: /src/flash.rs pub type FLASH_MAIN_WRITE_UNLOCK = crate::Reg<u32, _FLASH_MAIN_WRITE_UNLOCK>; #[allow(missing_docs)] #[doc(hidden)] pub struct _FLASH_MAIN_WRITE_UNLOCK; #[doc = "`read()` method returns [flash_main_write_unlock::R](flash_main_write_unlock::R) reader struct...
code_fim
hard
{ "lang": "rust", "repo": "ldicocco/rsl10-pac", "path": "/src/flash.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ucture"] impl crate::Readable for FLASH_COPY_WORD_CNT {} #[doc = "`write(|w| ..)` method takes [flash_copy_word_cnt::W](flash_copy_word_cnt::W) writer structure"] impl crate::Writable for FLASH_COPY_WORD_CNT {} #[doc = "Flash-to-Memory Copier Word Count"] pub mod flash_copy_word_cnt; #[doc = "Flash ECC Co...
code_fim
hard
{ "lang": "rust", "repo": "ldicocco/rsl10-pac", "path": "/src/flash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ldicocco/rsl10-pac path: /src/flash.rs FLASH_MAIN_WRITE_UNLOCK {} #[doc = "`write(|w| ..)` method takes [flash_main_write_unlock::W](flash_main_write_unlock::W) writer structure"] impl crate::Writable for FLASH_MAIN_WRITE_UNLOCK {} #[doc = "Flash Main Write Unlock Register"] pub mod flash_main_w...
code_fim
hard
{ "lang": "rust", "repo": "ldicocco/rsl10-pac", "path": "/src/flash.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for Permissions { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, "GRPC: [read: {}, write: {}], REST: [read: {}, write: {}]", self.contains(Self::READ), self.contains(Self::WRITE), self.con...
code_fim
hard
{ "lang": "rust", "repo": "qoollo/bob", "path": "/bob-access/src/permissions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qoollo/bob path: /bob-access/src/permissions.rs use bitflags::bitflags; use std::fmt::Display; use crate::authenticator::User; bitflags! { pub struct Permissions: u8 { const READ = 0b00000001; const WRITE = 0b00000010; const READ_REST = 0b00000100; const WRI...
code_fim
medium
{ "lang": "rust", "repo": "qoollo/bob", "path": "/bob-access/src/permissions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut p = Self::empty(); if user.can_read() { p.set(Self::READ, true); } if user.can_write() { p.set(Self::WRITE, true); } if user.can_read_rest() { p.set(Self::READ_REST, true); } if user.can_write_rest(...
code_fim
hard
{ "lang": "rust", "repo": "qoollo/bob", "path": "/bob-access/src/permissions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let content = include_str!("files/document.md"); let options = ParserOptions { file_name: String::from("document.md"), line_offset: 0, byte_offset: 0, }; let mut parser = Parser::new(content, options); let doc = parser.parse()?; println!("{:#?}", doc); O...
code_fim
medium
{ "lang": "rust", "repo": "uwe-app/bracket", "path": "/examples/parser-document.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uwe-app/bracket path: /examples/parser-document.rs use bracket::{ parser::{Parser, ParserOptions}, Result, }; <|fim_suffix|> let content = include_str!("files/document.md"); let options = ParserOptions { file_name: String::from("document.md"), line_offset: 0, ...
code_fim
medium
{ "lang": "rust", "repo": "uwe-app/bracket", "path": "/examples/parser-document.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manpat/mesh-shader-fuckery path: /src/main.rs #![feature(type_ascription)] pub mod gl; pub mod mesh; pub mod perf; pub mod scene_view; pub mod particles; pub mod terrain; pub mod paint; use std::error::Error; use common::math::*; #[repr(C)] #[derive(Copy, Clone, Debug)] struct Uniforms { p...
code_fim
hard
{ "lang": "rust", "repo": "manpat/mesh-shader-fuckery", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Event::MouseMotion { xrel, yrel, x, y, .. } => { if left_down { yaw += xrel as f32 * 0.005; pitch = (pitch - yrel as f32 * 0.005).clamp(-PI, PI); } let (w, h) = window.drawable_size(); let mouse_x = x as f32 / w as f32 * 2.0 - 1.0; let mouse_y = -(y as f32 / h as...
code_fim
hard
{ "lang": "rust", "repo": "manpat/mesh-shader-fuckery", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marius851000/pmd3d_script_runner path: /src/render/pistonrenderer.rs extern crate piston_window; use crate::gamedata::Update; use crate::render::Camera; use crate::render::CharacterSprite; use crate::render::WanStore; use crate::Input; use crate::Logic; use piston_window::*; use pmd_cpack::CPack...
code_fim
hard
{ "lang": "rust", "repo": "marius851000/pmd3d_script_runner", "path": "/src/render/pistonrenderer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let scene_arc = logic.scene.clone(); self.window.draw_2d(&e, |c, g, _device| { let scene = scene_arc.lock().unwrap(); let viewport = c.viewport.as_ref().unwrap(); let screen_x = viewport.draw_size[0] as f64; let scree...
code_fim
hard
{ "lang": "rust", "repo": "marius851000/pmd3d_script_runner", "path": "/src/render/pistonrenderer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amazingefren/rust-notes path: /concepts/pattern-matching/src/main.rs #![allow(dead_code)] enum Coin { Penny, Nickel, Dime(UsState), Quarter, Dollar, } #[derive(Debug)] enum UsState { Alabama, Alaska, Colorado, California, } fn main() { println!("{}", val...
code_fim
hard
{ "lang": "rust", "repo": "amazingefren/rust-notes", "path": "/concepts/pattern-matching/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match x { None => None, // needs to handle None or compiler will fail Some(i) => Some(i + 1), } }<|fim_prefix|>// repo: amazingefren/rust-notes path: /concepts/pattern-matching/src/main.rs #![allow(dead_code)] enum Coin { Penny, Nickel, Dime(UsState), Quarter, ...
code_fim
medium
{ "lang": "rust", "repo": "amazingefren/rust-notes", "path": "/concepts/pattern-matching/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tekjar/cloudpubsub path: /tests/testsuite.rs extern crate cloudpubsub; use cloudpubsub::{MqttOptions, MqttClient, MqttCallback, Message}; #[macro_use] extern crate log; extern crate pretty_env_logger; use std::thread; use std::time::Duration; use std::sync::Arc; use std::sync::atomic::{Atomic...
code_fim
hard
{ "lang": "rust", "repo": "tekjar/cloudpubsub", "path": "/tests/testsuite.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let callback = MqttCallback::new().on_publish(cb); let mut client = MqttClient::start(client_options, Some(callback)).expect("Coudn't start"); for i in 0..1010 { let payload = format!("{}. hello rust", i); if i == 250 || i == 500 || i == 750 { let _ = client.disco...
code_fim
hard
{ "lang": "rust", "repo": "tekjar/cloudpubsub", "path": "/tests/testsuite.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/device/icon_nearby_error.rs pub struct IconNearbyError { props: crate::Props, } impl yew::Component for IconNearbyError { type Properties = crate::Props; type Message = (); fn create(props: Self::Properties, _: yew::pr...
code_fim
medium
{ "lang": "rust", "repo": "andoriyu/material-design-icons-rs", "path": "/src/materialiconsround/device/icon_nearby_error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SiegeEngine/siege-render path: /src/renderer/buffer.rs use crate::error::Error; use std::io::{Write, Read}; use dacite::core::{Buffer, Device, BufferUsageFlags, MemoryPropertyFlags, BufferCopy, OptionalDeviceSize, Format, BufferView, BufferViewCreateInfo}; ...
code_fim
hard
{ "lang": "rust", "repo": "SiegeEngine/siege-render", "path": "/src/renderer/buffer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Create the device buffer usage |= BufferUsageFlags::TRANSFER_DST; let device_buffer = Self::new::<T>(device, memory, data.len(), usage, lifetime, reason)?; // Write the data to the staging buffer staging_buffer.write_array::<T>(data, None)?; // Force a ...
code_fim
hard
{ "lang": "rust", "repo": "SiegeEngine/siege-render", "path": "/src/renderer/buffer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_example_1() { let input = "Disc #1 has 5 positions; at time=0, it is at position 4.\nDisc #2 has 2 positions; at time=0, it is at position 1."; let answer: usize = time_button_press(&input, 1); assert_eq!(answer, 5); } }<|fim_prefix|>// repo: jonasvander...
code_fim
hard
{ "lang": "rust", "repo": "jonasvandervennet/advent-of-code-2016", "path": "/src/day15.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonasvandervennet/advent-of-code-2016 path: /src/day15.rs use crate::util::{print_part_1, print_part_2}; use regex::Regex; use std::fs::read_to_string; use std::time::Instant; struct Disc { index: usize, num_positions: usize, starting_position: usize, } fn time_button_press(input: ...
code_fim
hard
{ "lang": "rust", "repo": "jonasvandervennet/advent-of-code-2016", "path": "/src/day15.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Point{ x: self.x - other.x, y: self.y - other.y } } } impl<T> Div<T> for Point<T> where T: Div<Output=T> + Copy { type Output = Point<T>; fn div(self, divisor: T) -> Point<T> { Point{ x: self.x / divisor, y: self.y / divisor } } } impl<T> Ord for Point<T> where T: Or...
code_fim
hard
{ "lang": "rust", "repo": "HarukiUchito/rust_cp", "path": "/src/bin/circle_and_points.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Sub<Point<T>> for Point<T> where T: Sub<Output=T> { type Output = Point<T>; fn sub(self, other: Point<T>) -> Point<T> { Point{ x: self.x - other.x, y: self.y - other.y } } } impl<T> Div<T> for Point<T> where T: Div<Output=T> + Copy { type Output = Point<T>; f...
code_fim
hard
{ "lang": "rust", "repo": "HarukiUchito/rust_cp", "path": "/src/bin/circle_and_points.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HarukiUchito/rust_cp path: /src/bin/circle_and_points.rs #![allow(unused_imports, unused_variables, dead_code)] use std::io::{stdin, Read, StdinLock}; use std::str::FromStr; use std::fmt::*; use std::str::*; use std::cmp::*; use std::collections::*; use std::ops::*; use std::num::*; // http://j...
code_fim
hard
{ "lang": "rust", "repo": "HarukiUchito/rust_cp", "path": "/src/bin/circle_and_points.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsITransfer.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsITransfer.idl // #[repr(C)] pub struct nsITransfer { vtable: *const nsITransferVTable, /// This field is a phantomdata to ensure that the VTable type and any /// s...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsITransfer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match ((*self.vtable).setSignatureInfo)(self as *const _, aSignatureInfo.map_or(::std::ptr::null(), |x| x as *const _)) { NS_OK => {}, e => return Err(e), } Ok(()) } /* void setRedirects (in nsIArray aRedirects); */ #[inline] pub unsafe fn s...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsITransfer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_10_digit_unix_timestamp() { let test_dt = "1620587968"; let result = date_parse(test_dt); let expected = Ok(Utc.timestamp(1620587968, 0).with_timezone(&Local)); assert_eq!(result, expected); } #[test] fn test_13_digit_unix_timestamp() { ...
code_fim
hard
{ "lang": "rust", "repo": "heepster/time-butler", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heepster/time-butler path: /src/lib.rs use chrono::prelude::*; use regex::Regex; use std::vec; pub fn replace_datetime_in_str(input: &str) -> Option<String> { let rgs = vec![ // Match strings that are like 2021-05-09T20:08:07-07:00 Regex::new(r"(\d{4}-\d{2}-\d{2}(?:T|\s+)\d{...
code_fim
hard
{ "lang": "rust", "repo": "heepster/time-butler", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // `Structure`はプリント可能です! println!("Now {} will print!", Structure(3)); // `derive`を用いることの問題は、結果がどのように見えるか // コントロールする方法がないことです。 // 出力を`7`だけにするためにはどうしたらよいでしょう? println!("Now {:?} will print!", Deep(Structure(7))); }<|fim_prefix|>// repo: rarewin/my-studies path: /rust/rust-by-exam...
code_fim
hard
{ "lang": "rust", "repo": "rarewin/my-studies", "path": "/rust/rust-by-example/hello/print_debug/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // `{:?}`によるプリントは `{}`に似ています。 println!("{:?} months in a year.", 12); println!("{1:?} {0:?} is the {actor:?} name.", "Slater", "Christian", actor = "actor's"); // `Structure`はプリント可能です! println!("Now {} will print!", Structure(3)); // `deriv...
code_fim
medium
{ "lang": "rust", "repo": "rarewin/my-studies", "path": "/rust/rust-by-example/hello/print_debug/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rarewin/my-studies path: /rust/rust-by-example/hello/print_debug/src/main.rs use std::fmt; // `Structure`という構造体のための`fmt::Debug`をderiveしています。 // `Structure`は単一の`i32`をメンバに持っています。 #[derive(Debug)] struct Structure(i32); <|fim_suffix|>fn main() { // `{:?}`によるプリントは `{}`に似ています。 println!("{:...
code_fim
hard
{ "lang": "rust", "repo": "rarewin/my-studies", "path": "/rust/rust-by-example/hello/print_debug/src/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ayrapetovai/myrust path: /src/lifetimes.rs /* The Rust compiler has a borrow checker that compares scopes to determine whether all borrows are valid. { let r; // ---------+-- 'a // | { // | ...
code_fim
hard
{ "lang": "rust", "repo": "ayrapetovai/myrust", "path": "/src/lifetimes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let another_smthn_late_init; { let s = "another some string".to_string(); another_smthn_late_init = Something{ text: &s }; // borrowed value does not live long enough } compilation_error!( println!("The structure {:?}", another_smthn_late...
code_fim
hard
{ "lang": "rust", "repo": "ayrapetovai/myrust", "path": "/src/lifetimes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: miam-miam100/Calculator path: /src/expression.rs use pest::iterators::{Pair, Pairs}; use pest::prec_climber::*; pub use pest::Parser; use crate::my_math::ten_to_the_power_of; use crate::number::{add, div, exp, mul, sub}; use crate::trig_number::{acos, asin, atan, cos, sin, tan}; use crate::type...
code_fim
hard
{ "lang": "rust", "repo": "miam-miam100/Calculator", "path": "/src/expression.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Rule::square => exp( eval(function.next().unwrap().into_inner())?, Token::Basic(BasicToken::Integer(2)), ), Rule::cube => exp( eval(function.next().unwrap().into_inner())?, Token::Basic(BasicToken::Integer(3)), ), Rule...
code_fim
hard
{ "lang": "rust", "repo": "miam-miam100/Calculator", "path": "/src/expression.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn fn_eval(mut function: Pairs<Rule>) -> Result<Token, MathError> { match function.next().unwrap().as_rule() { Rule::sqrt => exp( eval(function.next().unwrap().into_inner())?, Token::Basic(BasicToken::fraction(0, 1, 2)), ), Rule::cbrt => exp( ...
code_fim
hard
{ "lang": "rust", "repo": "miam-miam100/Calculator", "path": "/src/expression.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kpcyrd/sss-rs path: /tests/benchmarks.rs #[cfg(test)] #[cfg(feature = "benchmarks")] mod benchmarks { use sss_rs::*; use std::time::Instant; use std::path::Path; #[test] fn large_file_test() { env_logger::builder().is_test(true).try_init().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "kpcyrd/sss-rs", "path": "/tests/benchmarks.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //cleanup for path in generate_share_file_paths(dir, stem, 254) { std::fs::remove_file(path).ok(); } } pub fn generate_share_file_paths(dir: &str, stem: &str, num_files: u8) -> Vec<String> { let mut path_buf = Path::new(dir).to_path_buf(); let...
code_fim
hard
{ "lang": "rust", "repo": "kpcyrd/sss-rs", "path": "/tests/benchmarks.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitter-badger/exodus path: /netif/src/sys/macos.rs #![cfg(target_os = "macos")] use libc; use sys; use std::str; use std::io; use std::ffi::CStr; use std::ffi::CString; pub const RTF_LLDATA: libc::c_int = 0x400; pub const RTF_DEAD: libc::c_int = 0x20000000; pub const RTPRF_OURS: libc::c_int ...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/exodus", "path": "/netif/src/sys/macos.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn if_name_to_mtu(name: &str) -> Result<usize, io::Error> { #[repr(C)] #[derive(Debug)] struct ifreq { ifr_name: [sys::c_char; sys::IF_NAMESIZE], ifr_mtu: sys::c_int } let fd = unsafe { sys::socket(sys::AF_INET, sys::SOCK_DGRAM, 0) }; if fd == -1 { re...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/exodus", "path": "/netif/src/sys/macos.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> std::ops::Index<std::ops::Range<usize>> for UVec<T> { type Output = [T]; #[inline] fn index(&self, index: Range<usize>) -> &Self::Output { if cfg!(debug_assertions) { &self.0[index] } else { unsafe { self.0.get_unchecked(index) } } }...
code_fim
hard
{ "lang": "rust", "repo": "libreca/LibreCA", "path": "/common/src/u_vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libreca/LibreCA path: /common/src/u_vec.rs // Copyright 2021 A Veenstra. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the // MIT license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. This file may ...
code_fim
hard
{ "lang": "rust", "repo": "libreca/LibreCA", "path": "/common/src/u_vec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} impl<T> FromIterator<T> for UVec<T> { fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> Self { Self(Vec::from_iter(iter)) } } impl<T> From<Vec<T>> for UVec<T> { fn from(inner: Vec<T>) -> Self { Self(inner) } } impl<T: std::fmt::Debug> std::fmt::Debug for UVec<T> { fn fmt(&self, f: &mut st...
code_fim
hard
{ "lang": "rust", "repo": "libreca/LibreCA", "path": "/common/src/u_vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MovingtoMars/liams_4x path: /src/client/imgui_wrapper.rs // https://github.com/iolivia/imgui-ggez-starter/blob/master/src/imgui_wrapper.rs use ggez::event::{KeyCode, KeyMods, MouseButton}; use ggez::graphics; use ggez::Context; use gfx_core::{handle::RenderTargetView, memory::Typed}; use gfx_d...
code_fim
hard
{ "lang": "rust", "repo": "MovingtoMars/liams_4x", "path": "/src/client/imgui_wrapper.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn want_capture_mouse(&self) -> bool { self.imgui.io().want_capture_mouse } pub fn want_capture_keyboard(&self) -> bool { self.imgui.io().want_capture_keyboard } // return want capture pub fn handle_event(&mut self, event: &InputEvent) -> bool { match *event { ...
code_fim
hard
{ "lang": "rust", "repo": "MovingtoMars/liams_4x", "path": "/src/client/imgui_wrapper.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }