text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> /// Tests if two objects can be tested for mutual collision. pub fn is_proximity_allowed(objects: &UidRemap<CollisionObject<P, M, T>>, fk1: &FastKey, fk2: &FastKey) -> bool { let co1 = &objects[*fk1]; let co2 = &object...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/ncollide", "path": "/ncollide_pipeline/world/collision_objects_dispatcher.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steveklabnik/ncollide path: /ncollide_pipeline/world/collision_objects_dispatcher.rs use utils::data::hash_map::HashMap; use utils::data::pair::{Pair, PairTWHash}; use utils::data::uid_remap::{UidRemap, FastKey}; use queries::geometry::Contact; use narrow_phase::{CollisionDispatcher, CollisionAl...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/ncollide", "path": "/ncollide_pipeline/world/collision_objects_dispatcher.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: daniel5151/clicky path: /clicky-core/src/devices/platform/pp/flash.rs use crate::devices::prelude::*; use byteorder::{ByteOrder, LittleEndian}; #[derive(PartialEq, Clone, Copy)] enum CFIState { ReadArrayMode, CommandPreambleAA, CommandPreamble55, ReadSoftwareID, } /// Internal...
code_fim
hard
{ "lang": "rust", "repo": "daniel5151/clicky", "path": "/clicky-core/src/devices/platform/pp/flash.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if offset > 0xFFFFF { return Err(Unexpected); } if let Some(dump) = self.dump.as_ref() { let offset = offset as usize; let val = LittleEndian::read_u32(&dump[offset..offset + 4]); return Ok(val); } Self::hle_vals(off...
code_fim
hard
{ "lang": "rust", "repo": "daniel5151/clicky", "path": "/clicky-core/src/devices/platform/pp/flash.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) use crate::{error, fs}; pub(crate) use crate::{ content::Content, error::Error, frontmatter::Frontmatter, index::Index, item::Item, item_kind::ItemKind, markup::Markup, opt::Opt, post::Post, slug::Slug, tag::Tag, }; pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;<|fim_pr...
code_fim
hard
{ "lang": "rust", "repo": "imawhale/blog", "path": "/src/common.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) use crate::{ content::Content, error::Error, frontmatter::Frontmatter, index::Index, item::Item, item_kind::ItemKind, markup::Markup, opt::Opt, post::Post, slug::Slug, tag::Tag, }; pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;<|fim_prefix|>// repo: imawhale/blog path: ...
code_fim
hard
{ "lang": "rust", "repo": "imawhale/blog", "path": "/src/common.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imawhale/blog path: /src/common.rs pub(crate) use std::{ collections::HashMap, env, fs::File, io::{self, Read, Write}, iter::IntoIterator, path::{Path, PathBuf}, process::{self, Command, ExitStatus, Stdio}, }; pub(crate) use askama::Template; pub(crate) use chrono::{DateTime, Fixe...
code_fim
hard
{ "lang": "rust", "repo": "imawhale/blog", "path": "/src/common.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let from: H160 = log.topics[1].into(); let to: H160 = log.topics[2].into(); let message = json!({ "timestamp": 0, "symbol": symbol, "amount": amount, "from": from, "to": to, }); println!("{}", message); ...
code_fim
hard
{ "lang": "rust", "repo": "Temboya-NDougala/etherwhales", "path": "/src/eth.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Temboya-NDougala/etherwhales path: /src/eth.rs use serde_json::json; use tiny_keccak::{Hasher, Keccak}; use warp::ws::Message; use web3::futures::StreamExt; use web3::types::{Address, FilterBuilder, H160, H256, U256}; use crate::Users; /// Compute the Keccak-256 hash of input bytes. fn keccak2...
code_fim
hard
{ "lang": "rust", "repo": "Temboya-NDougala/etherwhales", "path": "/src/eth.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let sub = web3.eth_subscribe().subscribe_logs(filter).await?; println!("Got subscription id: {:?}", sub.id()); // Ok(Log { address: 0xc00e94cb662c3520282e6f5717214004a7f26888, topics: [0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x0000000000000000000000003f5ce5fbfe3e9a...
code_fim
hard
{ "lang": "rust", "repo": "Temboya-NDougala/etherwhales", "path": "/src/eth.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fielda/martin path: /src/db.rs use std::io; use std::str::FromStr; use log::{error, info}; use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; use postgres_openssl::MakeTlsConnector; use r2d2::PooledConnection; use r2d2_postgres::PostgresConnectionManager; use semver::Version; use semve...
code_fim
hard
{ "lang": "rust", "repo": "fielda/martin", "path": "/src/db.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let version = Version::parse(postgis_version.as_str()) .map_err(|e| prettify_error!(e, "Can't parse database PostGIS version"))?; let matches = req.matches(&version); if !matches { error!("Martin requires PostGIS {required_postgis_version}, current version is {postgis_version...
code_fim
hard
{ "lang": "rust", "repo": "fielda/martin", "path": "/src/db.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let req = VersionReq::parse(required_postgis_version) .map_err(|e| prettify_error!(e, "Can't parse required PostGIS version"))?; let version = Version::parse(postgis_version.as_str()) .map_err(|e| prettify_error!(e, "Can't parse database PostGIS version"))?; let matches = req...
code_fim
hard
{ "lang": "rust", "repo": "fielda/martin", "path": "/src/db.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Progdrasil/sea-query path: /src/backend/sqlite/query.rs use super::*; impl QueryBuilder for SqliteQueryBuilder { fn char_length_function(&self) -> &str { "LENGTH" } <|fim_suffix|> &self, _select_lock: &LockType, _sql: &mut SqlWriter, _collector: &...
code_fim
easy
{ "lang": "rust", "repo": "Progdrasil/sea-query", "path": "/src/backend/sqlite/query.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &self, _select_lock: &LockType, _sql: &mut SqlWriter, _collector: &mut dyn FnMut(Value), ) { // SQLite doesn't supports row locking } }<|fim_prefix|>// repo: Progdrasil/sea-query path: /src/backend/sqlite/query.rs use super::*; impl QueryBuilder for Sqlite...
code_fim
easy
{ "lang": "rust", "repo": "Progdrasil/sea-query", "path": "/src/backend/sqlite/query.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ((*self as u8) << 1) | (RW::R as u8) } fn w_addr(&self) -> u8 { ((*self as u8) << 1) | (RW::W as u8) } fn as_u8(self) -> u8 { self as u8 } }<|fim_prefix|>// repo: kaisawind/raspberrypi path: /rust/pi_rfid/src/mfrc522/test.rs use crate::mfrc522::address::{Addres...
code_fim
medium
{ "lang": "rust", "repo": "kaisawind/raspberrypi", "path": "/rust/pi_rfid/src/mfrc522/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaisawind/raspberrypi path: /rust/pi_rfid/src/mfrc522/test.rs use crate::mfrc522::address::{Address, RW}; /// 测试 #[derive(Debug, Clone, Copy)] pub enum Test { RFU30 = 0x30, // 保留为将来之用 TestSel1Reg = 0x31, // 常用测试信号的配置 TestSel2Reg = 0x32, // 常用测试信号的配置和 PRBS 控制 Te...
code_fim
medium
{ "lang": "rust", "repo": "kaisawind/raspberrypi", "path": "/rust/pi_rfid/src/mfrc522/test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ctx_type = match function.sig.inputs.first() { Some(syn::FnArg::Typed(syn::PatType { ty, .. })) => &**ty, _ => { return Err(syn::Error::new(function.sig.span(), "expected a Context parameter").into()) } }; // Extract the command descriptionss from the f...
code_fim
hard
{ "lang": "rust", "repo": "Steelbirdy/poise", "path": "/macros/src/command/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Steelbirdy/poise path: /macros/src/command/mod.rs mod prefix; mod slash; use proc_macro::TokenStream; use syn::spanned::Spanned as _; // ngl this is ugly // transforms a type of form `OuterType<T>` into `T` fn extract_type_parameter<'a>(outer_type: &str, t: &'a syn::Type) -> Option<&'a syn::Ty...
code_fim
hard
{ "lang": "rust", "repo": "Steelbirdy/poise", "path": "/macros/src/command/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> doc_lines += literal; doc_lines += "\n"; } } } } // Apply newline escapes let doc_lines = doc_lines.trim().replace("\\\n", ""); if doc_lines.is_empty() { return (None, None); } let mut paragraphs...
code_fim
hard
{ "lang": "rust", "repo": "Steelbirdy/poise", "path": "/macros/src/command/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result_node } Dir::Right => { let result_node = (pos.0 + 1, pos.1); result_blocks[node_to_block(result_node.0) - 1] [node_to_block(result_node.1)] = Block::Air; ...
code_fim
hard
{ "lang": "rust", "repo": "lenscas/heaven_and_hell", "path": "/src/maze_gen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lenscas/heaven_and_hell path: /src/maze_gen.rs #![allow(dead_code)] use rand::Rng; use rand::seq::SliceRandom; use crate::Block; fn node_to_block(value: usize) -> usize { value * 2 + 1 } enum Dir { Down, Up, Left, Right, } /// resulting size is (X * 2 + 1, Y * 2 + 1) pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "lenscas/heaven_and_hell", "path": "/src/maze_gen.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let node = { match choices.choose(&mut rnd).unwrap() { Dir::Down => { let result_node = (pos.0, pos.1 - 1); result_blocks[node_to_block(result_node.0)] [node_to_block(result_node.1) + 1] = ...
code_fim
hard
{ "lang": "rust", "repo": "lenscas/heaven_and_hell", "path": "/src/maze_gen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jedisct1/supercop path: /crypto_aead/aes128gcmv1/rust_crypto/src/lib.rs #![allow(clippy::many_single_char_names)] use crypto::aead::AeadEncryptor; use crypto::aead::AeadDecryptor; use crypto::aes_gcm::AesGcm; use crypto::aes::KeySize::KeySize128; <|fim_suffix|>pub fn crypto_aead_decrypt( m:&...
code_fim
hard
{ "lang": "rust", "repo": "jedisct1/supercop", "path": "/crypto_aead/aes128gcmv1/rust_crypto/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: primitiv/primitiv-rust path: /examples/ptb/utils.rs use std::collections::HashMap; use std::fs::File; use std::io; use std::io::{BufRead, BufReader}; use std::path::Path; // Common utility functions for PTB examples. // Gathers the set of words from space-separated corpus. pub fn make_vocab<P:...
code_fim
hard
{ "lang": "rust", "repo": "primitiv/primitiv-rust", "path": "/examples/ptb/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// Extracts a minibatch from loaded corpus pub fn make_batch<Corpus, Sentence>( corpus: Corpus, sent_ids: &[usize], eos_id: u32, ) -> Vec<Vec<u32>> where Corpus: AsRef<[Sentence]>, Sentence: AsRef<[u32]>, { let corpus = corpus.as_ref(); let batch_size = sent_ids.len(); let ...
code_fim
hard
{ "lang": "rust", "repo": "primitiv/primitiv-rust", "path": "/examples/ptb/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ryan1729/llle path: /libs/platform_layer/libs/opengl/src/opengl.rs only need 3.3 for GL_TIME_ELAPSED. Otherwise we could use 3.2. .with_gl(GlRequest::Specific(Api::OpenGl, (3, 3))) .with_srgb(true) .build_windowed( glutin::WindowBuilder::new() ...
code_fim
hard
{ "lang": "rust", "repo": "Ryan1729/llle", "path": "/libs/platform_layer/libs/opengl/src/opengl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // If we got here, we assume that we've sent a Quit input to the editor thread so it will stop. join_handle.join().expect("Could not join editor thread!"); perf_viz::output!(); gl_layer::cleanup(gl_state) } pub fn render_buffer_view<A: Clone>( glyph_brush: &mut GlyphBrush<A>, vi...
code_fim
hard
{ "lang": "rust", "repo": "Ryan1729/llle", "path": "/libs/platform_layer/libs/opengl/src/opengl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //if we don't reset the cache like this then we render a stretched //version of the text on windoe resize. let (t_w, t_h) = glyph_brush.texture_dimensions(); glyph_brush.resize_texture(t_w, t_h)...
code_fim
hard
{ "lang": "rust", "repo": "Ryan1729/llle", "path": "/libs/platform_layer/libs/opengl/src/opengl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::CVTSI2SS, operand1: Some(Direct(XMM2)), operand2: Some(IndirectScaledIndexed(RCX, RDX, Four, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[24...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/cvtsi2ss.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn cvtsi2ss_5() { run_test(&Instruction { mnemonic: Mnemonic::CVTSI2SS, operand1: Some(Direct(XMM7)), operand2: Some(Direct(RBX)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[243, 72, 15, 42, 251], OperandSize::Qword)...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/cvtsi2ss.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/cvtsi2ss.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn cvtsi2ss_1() { run_tes...
code_fim
medium
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/cvtsi2ss.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rxRust/rxRust path: /src/observable/fake_timer.rs use crate::{ observer::Observer, rc::{MutRc, RcDeref, RcDerefMut}, subscriber::{Publisher, Subscriber}, }; use std::{ collections::VecDeque, convert::Infallible, time::{Duration, Instant}, }; use super::{Observable, ObservableExt}; ...
code_fim
hard
{ "lang": "rust", "repo": "rxRust/rxRust", "path": "/src/observable/fake_timer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn order_insert(tasks: &mut VecDeque<TimerObserver>, task: TimerObserver) { let at = task.at(); let position = tasks .make_contiguous() .binary_search_by(|t| t.at().cmp(&at)); let position = match position { Ok(p) => p, Err(p) => p, }; tasks.insert(position, task); } impl Defaul...
code_fim
hard
{ "lang": "rust", "repo": "rxRust/rxRust", "path": "/src/observable/fake_timer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>; pub use indent_level::*; pub use width::*;<|fim_prefix|>// repo: liketechnik/docx-rs path: /docx-core/src/reader/attributes/mod.rs mod bool_value; mod indent; mod indent_leve<|fim_middle|>l; mod width; mod border; pub use bool_value::*; pub use indent::*; pub use border::*
code_fim
medium
{ "lang": "rust", "repo": "liketechnik/docx-rs", "path": "/docx-core/src/reader/attributes/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liketechnik/docx-rs path: /docx-core/src/reader/attributes/mod.rs mod bool_value; mod indent; mod indent_leve<|fim_suffix|>; pub use indent_level::*; pub use width::*;<|fim_middle|>l; mod width; mod border; pub use bool_value::*; pub use indent::*; pub use border::*
code_fim
medium
{ "lang": "rust", "repo": "liketechnik/docx-rs", "path": "/docx-core/src/reader/attributes/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ihrwein/actiondb path: /tests/matcher/mod.rs extern crate actiondb; use actiondb::matcher::PatternLoader; use actiondb::matcher::trie::factory::TrieMatcherFactory; #[test] fn test_given_json_file_when_its_syntax_is_ok_then_matcher_can_be_built_from_it() { let pattern_file_path = "tests/mat...
code_fim
hard
{ "lang": "rust", "repo": "ihrwein/actiondb", "path": "/tests/matcher/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_given_json_file_when_an_expected_value_is_not_found_then_we_fail() { let pattern_file_path = "tests/matcher/ssh_when_an_expected_value_is_not_found_we_fail.json"; let matcher = PatternLoader::from_file::<TrieMatcherFactory>(pattern_file_path); println!("matcher: {:?}", &matcher...
code_fim
hard
{ "lang": "rust", "repo": "ihrwein/actiondb", "path": "/tests/matcher/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pierrechevalier83/unicode_types path: /src/generated/sinhala.rs /// An enum to represent all characters in the Sinhala block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum Sinhala { /// \u{d82}: 'ං' SignAnusvaraya, /// \u{d83}: 'ඃ' SignVisargaya, /// \u{d85}: '...
code_fim
hard
{ "lang": "rust", "repo": "pierrechevalier83/unicode_types", "path": "/src/generated/sinhala.rs", "mode": "psm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_suffix|>impl std::convert::TryFrom<char> for Sinhala { type Error = (); fn try_from(c: char) -> Result<Self, Self::Error> { match c { 'ං' => Ok(Sinhala::SignAnusvaraya), 'ඃ' => Ok(Sinhala::SignVisargaya), 'අ' => Ok(Sinhala::LetterAyanna), 'ආ' => Ok(S...
code_fim
hard
{ "lang": "rust", "repo": "pierrechevalier83/unicode_types", "path": "/src/generated/sinhala.rs", "mode": "spm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_suffix|> return res } func getValue(M [][]int, r, c int) int { value, count := 0, 0 for i := r - 1; i < r+2; i++ { for j := c - 1; j < c+2; j++ { if 0 <= i && i < len(M) && 0 <= j && j < len(M[0]) { value += M[i][j] count++ } } } return value / count }<|fim_prefix|>// repo: frankegoesdown/L...
code_fim
medium
{ "lang": "rust", "repo": "frankegoesdown/LeetCode-in-Go", "path": "/Algorithms/0661.image-smoother/image-smoother.go", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frankegoesdown/LeetCode-in-Go path: /Algorithms/0661.image-smoother/image-smoother.go package problem0661 func imageSmoother(M [][]int) [][]int { res := make([][]int, len(M)) for i := range res { res[i] = make([]int, len(M[0])) for j := range res[i] { res[i][j] = getValue(M, i, j) } ...
code_fim
easy
{ "lang": "rust", "repo": "frankegoesdown/LeetCode-in-Go", "path": "/Algorithms/0661.image-smoother/image-smoother.go", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // 1. First, you need to implement some basic command-line argument handling // so you can make your program do different things. Here's a little bit // to get you started doing manual parsing. // // Challenge: If you're feeling really ambitious, you could delete this code // and ...
code_fim
hard
{ "lang": "rust", "repo": "alexsaker/rust-crash-course", "path": "/exercise/z_final_project/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexsaker/rust-crash-course path: /exercise/z_final_project/src/main.rs // FINAL PROJECT // // Create an image processing application. Exactly what it does and how it does // it is up to you, though I've stubbed a good amount of suggestions for you. // Look for comments labeled **OPTION** below...
code_fim
hard
{ "lang": "rust", "repo": "alexsaker/rust-crash-course", "path": "/exercise/z_final_project/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DusterTheFirst/pinout path: /src/codegen/c.rs use anyhow::Context; use chrono::Local; use indoc::writedoc; use regex::Regex; use std::io::{self, ErrorKind, Write}; use crate::netlist::{AssociatedComponent, Net, Sheet}; pub fn generate<'t>( w: &mut dyn Write, sheet: &Sheet<'t>, comp...
code_fim
hard
{ "lang": "rust", "repo": "DusterTheFirst/pinout", "path": "/src/codegen/c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Raspberry Pi Pico Internal ADC channel /// /// This is the ADC channel to select the pin PIN_V_BAT_SENSE /// /// @see PIN_V_SYS static const unsigned int ADC_V_SYS = 3; /// Raspberry Pi Pico Internal ADC channel ...
code_fim
hard
{ "lang": "rust", "repo": "DusterTheFirst/pinout", "path": "/src/codegen/c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ; mod rich ; pub use rich : : * ; pub use super : : coff : : { SectionTable SymbolTable } ;<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/object/src/read/pe/mod.rs mod file ; pub use file : : * ; mod section ; pub use section : : * ; mod data_directory ; ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/object/src/read/pe/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>rt : : * ; mod relocation ; pub use relocation : : * ; mod resource ; pub use resource : : * ; mod rich ; pub use rich : : * ; pub use super : : coff : : { SectionTable SymbolTable } ;<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/object/src/read/pe/mod.rs...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/object/src/read/pe/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/object/src/read/pe/mod.rs mod file ; pub use file : : * ; mod section ; pub use section : : * ; mod data_directory ; <|fim_suffix|>rt : : * ; mod relocation ; pub use relocation : : * ; mod resource ; pub use resource : : *...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/object/src/read/pe/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>// #[macro_export] #[proc_macro_attribute] pub fn show_streams(attr: TokenStream, item: TokenStream) -> TokenStream { println!("attr: \"{}\"", attr.to_string()); println!("item: \"{}\"", item.to_string()); item } #[proc_macro] pub fn make_answer(_item: TokenStream) -> TokenStream { "fn an...
code_fim
medium
{ "lang": "rust", "repo": "stallboy/rusttest", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stallboy/rusttest path: /src/lib.rs mod closures; mod iterators; mod boxes; mod rcs; mod threads; mod traits; mod advanced_traits; mod box_size; struct Guess { value: i32, } use proc_macro::TokenStream; // #[macro_export] #[proc_macro_attribute] pub fn show_streams(attr: TokenStream, it...
code_fim
medium
{ "lang": "rust", "repo": "stallboy/rusttest", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Object<T> { pub value: T, pub hitbox: Hitbox, } impl<T> Object<T> { pub fn new(value: T, hitbox: Hitbox) -> Self { Object { value, hitbox } } pub fn collides(&self, hitbox: &Hitbox) -> bool { self.hitbox.collides(hitbox) } } pub enum Hitbox { Circle...
code_fim
hard
{ "lang": "rust", "repo": "VoxWave/dungenon-rs", "path": "/src/level/unaligned_level.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub enum Hitbox { Circle(Vector<f32>, f32), ///First vector denotes the center of the AABB and the second vector denotes the dimensions(width, height) of the AABB Aabb(Vector<f32>, Vector<f32>), } impl Hitbox { pub fn collides(&self, hitbox: &Hitbox) -> bool { use self::Hitbox::*; ...
code_fim
hard
{ "lang": "rust", "repo": "VoxWave/dungenon-rs", "path": "/src/level/unaligned_level.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VoxWave/dungenon-rs path: /src/level/unaligned_level.rs use {Point, Vector}; use na::zero; use rayon::iter::ParallelIterator; use rayon::prelude::*; pub struct UnalignedLevel<T> { objects: Vec<Object<T>>, } impl<T> UnalignedLevel<T> { pub fn new() -> UnalignedLevel<T> { Unali...
code_fim
hard
{ "lang": "rust", "repo": "VoxWave/dungenon-rs", "path": "/src/level/unaligned_level.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marony/rust3d path: /src/util/vector3.rs use std::ops::{Add, Sub, Mul, Div}; use util::point3::Point3; #[derive(Debug, Copy, Clone)] pub struct Vector3 { pub x: f64, pub y: f64, pub z: f64, pub w: f64 } impl Vector3 { // TODO: wがないバージョンを定義したい pub fn new(x: f64, y: f64, ...
code_fim
hard
{ "lang": "rust", "repo": "marony/rust3d", "path": "/src/util/vector3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Vector3::new(self.x / rhs, self.y / rhs, self.z / rhs, 1.0f64) } } impl<'a> Mul<&'a Vector3> for &'a Vector3 { type Output = Vector3; // 外積 fn mul<'b>(self, rhs: &'b Vector3) -> Vector3 { Vector3::new( self.y * rhs.z - self.z * rhs.y, self.z * rhs....
code_fim
hard
{ "lang": "rust", "repo": "marony/rust3d", "path": "/src/util/vector3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { /* import numpy as np >>> v2 = np.array([6, 7, 8]) >>> v1 = np.array([3, 4, 5]) >>> np.cross(v1, v2) // np.outer(v1, v2)は直積 array([-3, 6, -3]) >>> np.outer(v1, v2) array([[18, 21, 24], [24, 28, 32], [30, 35, 40]]) */ // 外積 let a = Vector3::new(3f32, 4f32, 5...
code_fim
hard
{ "lang": "rust", "repo": "marony/rust3d", "path": "/src/util/vector3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let key_base = "helloworld"; let salt = "test salt"; let dkp = DerivedKeyParams::default(); let encryptor = AesGcmEncryptor::new(key_base, salt, dkp).unwrap(); let mut message = String::new(); match io::stdin().read_to_string(&mut message) { Err(_) => panic!("Read failed...
code_fim
medium
{ "lang": "rust", "repo": "mjc-gh/message_verifier", "path": "/examples/aead_decrypt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mjc-gh/message_verifier path: /examples/aead_decrypt.rs extern crate message_verifier; use message_verifier::{Encryptor, AesGcmEncryptor, DerivedKeyParams}; use std::io; use std::io::Read; use std::str; <|fim_suffix|> let dkp = DerivedKeyParams::default(); let encryptor = AesGcmEncryp...
code_fim
medium
{ "lang": "rust", "repo": "mjc-gh/message_verifier", "path": "/examples/aead_decrypt.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn add_as_partition_key_header_serialized( partition_key_serialized: &str, builder: Builder, ) -> Builder { builder.header( headers::HEADER_DOCUMENTDB_PARTITIONKEY, partition_key_serialized, ) }<|fim_prefix|>// repo: Displayr/azure-sdk-for-rust path: /sdk/cosmos...
code_fim
hard
{ "lang": "rust", "repo": "Displayr/azure-sdk-for-rust", "path": "/sdk/cosmos/src/cosmos_entity.rs", "mode": "spm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Displayr/azure-sdk-for-rust path: /sdk/cosmos/src/cosmos_entity.rs use crate::headers; use http::request::Builder; use serde::Serialize; /// CosmosDB partition key. Every CosmosDB entity must implement it. pub trait CosmosEntity<'a> { /// Returned type. type Entity: Serialize + 'a; ...
code_fim
hard
{ "lang": "rust", "repo": "Displayr/azure-sdk-for-rust", "path": "/sdk/cosmos/src/cosmos_entity.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|> let mut record: LocalAckRecord = Default::default(); record.enqueue(0, &Vec::new()); record.enqueue(40, &Vec::new()); let dropped = record.ack(40, 0); assert_eq!(dropped, vec![(0, Vec::new().into_boxed_slice())]); assert!(record.is_empty()); } #[tes...
code_fim
hard
{ "lang": "rust", "repo": "CosineGaming/laminar", "path": "/src/infrastructure/local_ack.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn drops_old_packets() { let mut record: LocalAckRecord = Default::default(); record.enqueue(0, &Vec::new()); record.enqueue(40, &Vec::new()); let dropped = record.ack(40, 0); assert_eq!(dropped, vec![(0, Vec::new().into_boxed_slice())]); ass...
code_fim
hard
{ "lang": "rust", "repo": "CosineGaming/laminar", "path": "/src/infrastructure/local_ack.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CosineGaming/laminar path: /src/infrastructure/local_ack.rs use std::collections::HashMap; /// Packets waiting for an ack /// /// Holds up to 32 packets waiting for ack /// /// Additionally, holds packets "forward" of the current ack packet #[derive(Debug, Default)] pub struct LocalAckRecord { ...
code_fim
hard
{ "lang": "rust", "repo": "CosineGaming/laminar", "path": "/src/infrastructure/local_ack.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wdiviner/geektime-rust path: /14_sys_traits/src/sized.rs #[allow(dead_code)] struct Data<T> { inner: T, } fn process_data<T: Sized>(_data: Data<T>) { todo!(); } #[allow(dead_code)] struct UnsizedData<T: ?Sized> { inner: T, } <|fim_suffix|> let v = Data { inner: 0 }; process...
code_fim
medium
{ "lang": "rust", "repo": "Wdiviner/geektime-rust", "path": "/14_sys_traits/src/sized.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let v = Data { inner: 0 }; process_data(v); let v = UnsizedData { inner: 0 }; // process_unsized_data(v); }<|fim_prefix|>// repo: Wdiviner/geektime-rust path: /14_sys_traits/src/sized.rs #[allow(dead_code)] struct Data<T> { inner: T, } fn process_data<T: Sized>(_data: Data<T>) { <|fi...
code_fim
hard
{ "lang": "rust", "repo": "Wdiviner/geektime-rust", "path": "/14_sys_traits/src/sized.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(unused_variables)] fn main() { let v = Data { inner: 0 }; process_data(v); let v = UnsizedData { inner: 0 }; // process_unsized_data(v); }<|fim_prefix|>// repo: Wdiviner/geektime-rust path: /14_sys_traits/src/sized.rs #[allow(dead_code)] struct Data<T> { inner: T, } <|fim_mid...
code_fim
hard
{ "lang": "rust", "repo": "Wdiviner/geektime-rust", "path": "/14_sys_traits/src/sized.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fbecart/rust-cql path: /tests/test_cql/mod.rs extern crate std; use std::borrow::IntoCow; use std::io::Write; use cql; #[test] fn test() { println!("Connecting ...!"); let mut client = try_test!(cql::connect("127.0.0.1", 9042, None), "Error connecting to server at 127.0.0.1:9042"); ...
code_fim
hard
{ "lang": "rust", "repo": "fbecart/rust-cql", "path": "/tests/test_cql/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> q = "select * from rust.test"; println!("cql::Query: {}", q); response = try_test!(client.exec_query(q, cql::Consistency::One), "Error selecting from table test"); assert_response!(response); println!("Result: {:?} \n", response); q = "create table rust.test2 (id text primary key,...
code_fim
hard
{ "lang": "rust", "repo": "fbecart/rust-cql", "path": "/tests/test_cql/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconstwotone/social/icon_co2.rs pub struct IconCo2 { props: crate::Props, } impl yew::Component for IconCo2 { type Properties = crate::Props; type Message = (); fn create(props: Self::Properties, _: yew::prelude::ComponentLink<Se...
code_fim
hard
{ "lang": "rust", "repo": "andoriyu/material-design-icons-rs", "path": "/src/materialiconstwotone/social/icon_co2.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use euler::fib; fn even(n: i64) -> bool { n % 2 == 0 } fn fibsum() -> i64 { let mut sum: i64 = 0; let mut f: i64 = 0; let mut i: i32 = 1; while f < 4000000 { if even(f) { sum += f; } f = fib(i); i += 1; } sum } fn main() { prin...
code_fim
medium
{ "lang": "rust", "repo": "mwcz/euler", "path": "/rs/src/bin/p2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut sum: i64 = 0; let mut f: i64 = 0; let mut i: i32 = 1; while f < 4000000 { if even(f) { sum += f; } f = fib(i); i += 1; } sum } fn main() { println!("{}", fibsum()); }<|fim_prefix|>// repo: mwcz/euler path: /rs/src/bin/p2.rs ...
code_fim
medium
{ "lang": "rust", "repo": "mwcz/euler", "path": "/rs/src/bin/p2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mwcz/euler path: /rs/src/bin/p2.rs // Problem 2 // // Each new term in the Fibonacci sequence is generated by adding the previous two terms. By // starting with 1 and 2, the first 10 terms will be: // // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... // // By considering the terms in the Fibonacci seque...
code_fim
medium
{ "lang": "rust", "repo": "mwcz/euler", "path": "/rs/src/bin/p2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lislis/talk-fp-rust path: /rust/examples/08-display-fixed.rs //! implement Display trait use std::fmt; <|fim_suffix|>impl fmt::Display for Point { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "({}, {})", self.x, self.y) } } fn main() { let p = Point { x...
code_fim
easy
{ "lang": "rust", "repo": "lislis/talk-fp-rust", "path": "/rust/examples/08-display-fixed.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let p = Point { x: 12, y: 13 }; println!("{}", p); }<|fim_prefix|>// repo: lislis/talk-fp-rust path: /rust/examples/08-display-fixed.rs //! implement Display trait use std::fmt; struct Point { x: i32, y: i32 } <|fim_middle|>impl fmt::Display for Point { fn fmt(&self, f: &mut fmt::F...
code_fim
medium
{ "lang": "rust", "repo": "lislis/talk-fp-rust", "path": "/rust/examples/08-display-fixed.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let p = Point { x: 12, y: 13 }; println!("{}", p); }<|fim_prefix|>// repo: lislis/talk-fp-rust path: /rust/examples/08-display-fixed.rs //! implement Display trait use std::fmt; struct Point { x: i32, y: i32 } <|fim_middle|>impl fmt::Display for Point { fn fmt(&self, f:...
code_fim
medium
{ "lang": "rust", "repo": "lislis/talk-fp-rust", "path": "/rust/examples/08-display-fixed.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let args = App::new("Starlog") .version("0.1.0") .author("Guillaume Pasquet") .about("Write your daily update") .arg( Arg::with_name("tomorrow") .short("t") .long("tomorrow") .takes_value(false) ...
code_fim
hard
{ "lang": "rust", "repo": "Etenil/slack-starlog", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let stdin = io::stdin(); let slack = SlackHook::new(); if args.is_present("tomorrow") { println!("Enter what you did today, end with empty line"); let done = read_stdin(&stdin).unwrap(); println!("Enter what you'll do tomorrow, end with empty line"); let todo =...
code_fim
hard
{ "lang": "rust", "repo": "Etenil/slack-starlog", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Etenil/slack-starlog path: /src/main.rs use clap::{App, Arg}; use slack_hook2::{PayloadBuilder, Slack}; use std::env; use std::io; use std::time::{SystemTime, UNIX_EPOCH}; use tokio::runtime::Runtime; fn read_stdin(stdin: &io::Stdin) -> Result<Vec<String>, ()> { let mut buffer = String::new...
code_fim
hard
{ "lang": "rust", "repo": "Etenil/slack-starlog", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[actix_web::main] async fn main() -> Result<()> { dotenv().ok(); env_logger::init(); // Connect Database // let pool = PgPoolOptions::new() // .max_connections(5) // .connect(&env::var("DATABASE_URL")?).await?; let pool = db::get_db_pool().await; // Variable Host dan Port ...
code_fim
medium
{ "lang": "rust", "repo": "goodhel/rust-graphql", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goodhel/rust-graphql path: /src/main.rs use actix_web::{App, HttpServer, middleware::Logger}; // use sqlx::postgres::PgPoolOptions; use dotenv::dotenv; use std::env; use anyhow::Result; <|fim_suffix|>#[actix_web::main] async fn main() -> Result<()> { dotenv().ok(); env_logger::init(); ...
code_fim
medium
{ "lang": "rust", "repo": "goodhel/rust-graphql", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pryvkin10x/rust-bio path: /src/stats/mod.rs // Copyright 2014-2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. <|fim_suffix|> pub mod combinatorics; pub mod p...
code_fim
easy
{ "lang": "rust", "repo": "pryvkin10x/rust-bio", "path": "/src/stats/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use stats::probs::{Prob, LogProb, PHREDProb};<|fim_prefix|>// repo: pryvkin10x/rust-bio path: /src/stats/mod.rs // Copyright 2014-2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according t...
code_fim
easy
{ "lang": "rust", "repo": "pryvkin10x/rust-bio", "path": "/src/stats/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Korvox/qml-rust path: /examples/properties.rs extern crate qml; use qml::*; fn main() { let mut qqae = QmlEngine::new(); let qvar: QVariant = 10.into(); <|fim_suffix|>", &qvar); qqae.set_property("qVar4", &qvar); let vec: Vec<QVariant> = vec![42.into(), 43.into()]; qqae.se...
code_fim
medium
{ "lang": "rust", "repo": "Korvox/qml-rust", "path": "/examples/properties.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>t_and_store_property("values", vec); qqae.load_file("examples/properties.qml"); qqae.exec(); qqae.quit(); }<|fim_prefix|>// repo: Korvox/qml-rust path: /examples/properties.rs extern crate qml; use qml::*; fn main() { let mut qqae = QmlEngine::new(); let qvar: QVariant = 10.into(); ...
code_fim
medium
{ "lang": "rust", "repo": "Korvox/qml-rust", "path": "/examples/properties.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let co = ray.origin() - self.center; // center to origin let a_of_equation = ray.direction().dot(ray.direction()); let b_of_equation = 2.0 * ray.direction().dot(&co); let c_of_equation = co.dot(&co) - self.radius * self.radius; let discriminant = b_of_equation * b_o...
code_fim
hard
{ "lang": "rust", "repo": "eranfu/ray_tracing", "path": "/src/sphere.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eranfu/ray_tracing path: /src/sphere.rs use std::sync::Arc; use crate::*; pub struct Sphere { center: Vector3, radius: f32, material: Arc<dyn Material>, } impl Sphere { pub fn new<T: Material + 'static, U: Into<Arc<T>>>( center: &Vector3, radius: f32, m...
code_fim
hard
{ "lang": "rust", "repo": "eranfu/ray_tracing", "path": "/src/sphere.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match t { Some(t) => { let position = ray.point_at(t); let normal = &(position - self.center) / self.radius; let (u, v) = common::get_sphere_uv(&normal); Some(HitRecord { t, position...
code_fim
hard
{ "lang": "rust", "repo": "eranfu/ray_tracing", "path": "/src/sphere.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'p> Provide<'p, 'static, (), IdxProvideNil> for ProvideNil { fn provide(&'p self) -> () { () } }<|fim_prefix|>// repo: RGafiyatullin/tfsi path: /src/providers/provide_nil.rs use crate::provide::Provide; /// A `Provide` that can only provide a unit (`()`). /// /// Used as a `Require:...
code_fim
easy
{ "lang": "rust", "repo": "RGafiyatullin/tfsi", "path": "/src/providers/provide_nil.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RGafiyatullin/tfsi path: /src/providers/provide_nil.rs use crate::provide::Provide; /// A `Provide` that can only provide a unit (`()`). /// /// Used as a `Require::Provider` for `RequireNil`. #[derive(Debug, Clone, Copy)] pub struct ProvideNil; <|fim_suffix|>impl<'p> Provide<'p, 'static, (), ...
code_fim
easy
{ "lang": "rust", "repo": "RGafiyatullin/tfsi", "path": "/src/providers/provide_nil.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IDragnev/myos path: /src/memory/boot_info_frame_allocator.rs use x86_64::{ PhysAddr, structures::{ paging::{ PhysFrame, FrameAllocator, Size4KiB, }, }, }; use bootloader::{ bootinfo::{ MemoryMap, MemoryRegionType...
code_fim
medium
{ "lang": "rust", "repo": "IDragnev/myos", "path": "/src/memory/boot_info_frame_allocator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator { fn allocate_frame(&mut self) -> Option<PhysFrame> { let frame = self.usable_frames().nth(self.next); self.next += 1; frame } }<|fim_prefix|>// repo: IDragnev/myos path: /src/memory/boot_info_frame_allocator...
code_fim
hard
{ "lang": "rust", "repo": "IDragnev/myos", "path": "/src/memory/boot_info_frame_allocator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whatisaphone/war-is-here path: /crates/aether/src/darksiders1/code/vigil/gfc/base/autoref.rs use crate::darksiders1::{Heap, Lift, Lower}; use darksiders1_sys::target; use pdbindgen_runtime::StaticCast; use std::{ mem, ops::Deref, sync::atomic::{AtomicI32, Ordering}, }; struct_wrappe...
code_fim
hard
{ "lang": "rust", "repo": "whatisaphone/war-is-here", "path": "/crates/aether/src/darksiders1/code/vigil/gfc/base/autoref.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.ptr() } fn ptr(&self) -> *mut $target { self.p.cast() } } }; (@lift => $autoref:ty, $target:path) => { unsafe impl Lift for $autoref { type Target = AutoRef<<$target as Lift>::Target>; ...
code_fim
hard
{ "lang": "rust", "repo": "whatisaphone/war-is-here", "path": "/crates/aether/src/darksiders1/code/vigil/gfc/base/autoref.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_index_stride(&self, prim: &gltf2::MeshPrimitive) -> Option<i32> { Some(self.gltf.accessors[prim.indices? as usize].stride()) } fn get_material_color_texture(&self, material: &gltf2::Material) -> Option<Rc<Texture>> { if let Some(texture_index) = material ...
code_fim
hard
{ "lang": "rust", "repo": "ousttrue/frame_factory", "path": "/scene/src/loader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ousttrue/frame_factory path: /scene/src/loader.rs use core::panic; use std::{cell::Cell, fs::File, io::Read, rc::Rc, u32, usize}; use cgmath::{One, Quaternion, Vector3, Zero}; use crate::*; struct BytesReader<'a> { pos: Cell<usize>, buf: &'a [u8], } impl<'a> BytesReader<'...
code_fim
hard
{ "lang": "rust", "repo": "ousttrue/frame_factory", "path": "/scene/src/loader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> loader.load()?; return Ok(loader); } } Err(Error::NotImpl) } pub struct Loader { gltf: gltf2::glTF, bin: Vec<u8>, pub images: Vec<Rc<Image>>, pub textures: Vec<Rc<Texture>>, pub materials: Vec<Rc<Material>>, pub meshes: Vec<...
code_fim
hard
{ "lang": "rust", "repo": "ousttrue/frame_factory", "path": "/scene/src/loader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matklad/tokio path: /tokio/src/executor/thread_pool/worker.rs F, R>(f: F) -> R where F: FnOnce() -> R, { // Make the current worker give away its Worker to another thread so that we can safely block // this one without preventing progress on other futures the worker owns. ON_BLOC...
code_fim
hard
{ "lang": "rust", "repo": "matklad/tokio", "path": "/tokio/src/executor/thread_pool/worker.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matklad/tokio path: /tokio/src/executor/thread_pool/worker.rs , launch_worker, gone: Cell::new(false), } } pub(super) fn run(mut self) where P: Park<Unpark = Box<dyn Unpark>>, { let pool = Arc::clone(&self.entry.pool); let ...
code_fim
hard
{ "lang": "rust", "repo": "matklad/tokio", "path": "/tokio/src/executor/thread_pool/worker.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(task) = task { self.run_task(task, gone)?; } else { return Ok(true); } } } fn steal_work(&mut self) -> Option<Task<Shared<P>>> { let num_workers = self.pool.len(); let start = self.owned().rand...
code_fim
hard
{ "lang": "rust", "repo": "matklad/tokio", "path": "/tokio/src/executor/thread_pool/worker.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }