text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /node/src/components/gossiper/tests.rs ann) } Event::DeployAcceptorAnnouncement(ann) => { write!(formatter, "deploy-acceptor announcement: {}", ann) } Event::DeployGossiperAnnouncement(ann) =...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/node/src/components/gossiper/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Give the deploy to nodes 0 and 1 to be gossiped. for node_id in node_ids.iter().take(2) { network .process_injected_effect_on(node_id, announce_deploy_received(deploy.clone(), None)) .await; } // Run node 0 until it has sent the gossip request then remov...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/node/src/components/gossiper/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn maybe_exit(&self) -> Option<crate::reactor::ReactorExit> { unimplemented!() } } impl NetworkedReactor for Reactor { type NodeId = NodeId; fn node_id(&self) -> NodeId { self.network.node_id() } } fn announce_deploy_received( deploy: Box<Deploy>, responder: ...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/node/src/components/gossiper/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// type ElectricPotential = ElectricPotential<SI<V>, V> = Quantity<Dimension, SI<V>, V> // type ElectricPotential<U, V> = Quantity<Dimension, U, V>; // type Dimension = ISQ<P2, P1, N3, N1, Z0, Z0, Z0, dyn Kind>; // pub struct Quantity<D: ?Sized, U: ?Sized, V> // where // D: Dimension, // U: Units...
code_fim
hard
{ "lang": "rust", "repo": "baliuzeger/calculator", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: baliuzeger/calculator path: /src/main.rs use uom::si::f64::Time; use uom::si::time::millisecond; use uom::si::time::second; use uom::si::f64::ElectricalResistance as Resistance; use uom::si::electrical_resistance::megaohm; use uom::si::f64::ElectricCurrent as Current; use uom::si::electric_curre...
code_fim
hard
{ "lang": "rust", "repo": "baliuzeger/calculator", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ava57r/npchk-rs path: /src/http.rs // get from https://github.com/Nercury/confluence-rs //! HTTP helpers. use std::io::Read; use reqwest::{Client, StatusCode}; use hyper::header::ContentType; use hyper::mime; header! { (SoapAction, "SOAPAction") => [String] } /// Simplified HTTP response re...
code_fim
hard
{ "lang": "rust", "repo": "ava57r/npchk-rs", "path": "/src/http.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } } pub enum DropEnum { Test1(TestStuct1), Test2(TestStuct2) }<|fim_prefix|>// repo: coruscateor/enums_drop_test path: /src/test_structs.rs use std::ops::Drop; pub struct TestStuct1; impl Drop for TestStuct1 { fn drop(&mut self) { println!("Dropping TestStuct1!"); } ...
code_fim
medium
{ "lang": "rust", "repo": "coruscateor/enums_drop_test", "path": "/src/test_structs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coruscateor/enums_drop_test path: /src/test_structs.rs use std::ops::Drop; pub struct TestStuct1; impl Drop for TestStuct1 { fn drop(&mut self) { <|fim_suffix|> fn drop(&mut self) { println!("Dropping TestStuct2!"); } } pub enum DropEnum { Test1(TestStuct1), T...
code_fim
medium
{ "lang": "rust", "repo": "coruscateor/enums_drop_test", "path": "/src/test_structs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn drop(&mut self) { println!("Dropping TestStuct2!"); } } pub enum DropEnum { Test1(TestStuct1), Test2(TestStuct2) }<|fim_prefix|>// repo: coruscateor/enums_drop_test path: /src/test_structs.rs use std::ops::Drop; pub struct TestStuct1; impl Drop for TestStuct1 { <|fim_m...
code_fim
medium
{ "lang": "rust", "repo": "coruscateor/enums_drop_test", "path": "/src/test_structs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Atmelfan/uom path: /src/si/catalytic_activity.rs //! Catalytic activity (base unit katal, mol · s⁻¹). quantity! { /// Catalytic activity (base unit katal, mol · s⁻¹). quantity: CatalyticActivity; "catalytic activity"; /// Dimension of catalytic activity, T⁻¹N (base unit katal, mol ·...
code_fim
hard
{ "lang": "rust", "repo": "Atmelfan/uom", "path": "/src/si/catalytic_activity.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { storage_types! { use crate::num::One; use crate::si::amount_of_substance as aos; use crate::si::catalytic_activity as ca; use crate::si::quantities::*; use crate::si::time as t; use crate::tests::Test; #[test] fn...
code_fim
hard
{ "lang": "rust", "repo": "Atmelfan/uom", "path": "/src/si/catalytic_activity.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tglanz/rust-learn path: /snake/engine/src/level.rs use std::vec::Vec; use terrain::{TerrainSize, TerrainIndex, TerrainLocation, location_to_index}; pub struct Level { terrain_size: TerrainSize, occupied_indices: Vec<TerrainIndex> } impl Level { pub fn get_terrain_size(&self) -> &T...
code_fim
medium
{ "lang": "rust", "repo": "tglanz/rust-learn", "path": "/snake/engine/src/level.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Can make it constructive but ... for row in 0..rows { for column in 0..columns { if row == 0 || row == rows - 1 || column == 0 || column == columns - 1 { let terrain_location = TerrainLocation::new(row, column); let terrain_index = location_to...
code_fim
medium
{ "lang": "rust", "repo": "tglanz/rust-learn", "path": "/snake/engine/src/level.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut map = serializer.serialize_map(Some(m.len()))?; for (k, v) in m { map.serialize_entry(k, v)?; } map.end() } } } }<|fim_prefix|>// repo: defvar/toy path: /shared/toy-pack-json/src/jvalue/ser.r...
code_fim
hard
{ "lang": "rust", "repo": "defvar/toy", "path": "/shared/toy-pack-json/src/jvalue/ser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: defvar/toy path: /shared/toy-pack-json/src/jvalue/ser.rs use crate::jvalue::JValue; use serde::{Serialize, Serializer}; impl Serialize for JValue { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match *self { <|fim_suffix|...
code_fim
hard
{ "lang": "rust", "repo": "defvar/toy", "path": "/shared/toy-pack-json/src/jvalue/ser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jo12bar/weekend-tracer-rs path: /src/pdf/cosine_pdf.rs //! A cosine density PDF. use crate::{onb::ONB, vec3::Vec3}; use rand::prelude::*; <|fim_suffix|>impl CosinePDF { /// Create a new cosine density PDF. pub fn new(w: Vec3) -> Self { Self { uvw: ONB::build_from_w(...
code_fim
medium
{ "lang": "rust", "repo": "jo12bar/weekend-tracer-rs", "path": "/src/pdf/cosine_pdf.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> pub fn value(&self, direction: &Vec3) -> f32 { let cosine = direction.unit_vector().dot(&self.uvw.w); if cosine <= 0.0 { 0.0 } else { cosine / std::f32::consts::PI } } pub fn generate<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec3 { ...
code_fim
hard
{ "lang": "rust", "repo": "jo12bar/weekend-tracer-rs", "path": "/src/pdf/cosine_pdf.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>#[doc(inline)] pub use domains::{Domain, DomainType}; #[doc(inline)] pub use goal::project::{assert_1, assert_2, map_1, map_2, project_1, project_2}; #[doc(inline)] pub use goal::{both, custom, either, lazy, unify, Goal}; #[doc(inline)] pub use query::Query; #[doc(inline)] pub use state::{Fork, IterResolv...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/canrun_rs", "path": "/core/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/canrun_rs path: /core/src/lib.rs #![warn(missing_docs)] //! Canrun is a [logic //! programming](https://en.wikipedia.org/wiki/Logic_programming) library //! inspired by the [\*Kanren](http://minikanren.org/) family of language DSLs. //! //! ## Status: Exploratory and Highly Experimental ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/canrun_rs", "path": "/core/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seanchen1991/vecdraw path: /src/layer.rs use std::cell::RefCell; use wgpu::{ BindGroup, BindGroupLayout, CommandEncoder, Device, RenderPass, SwapChainDescriptor, }; pub struct DrawContext<'a> { pub device: &'a Device, pub sc_desc: &'a SwapChainDescriptor, pub transform_layout: &...
code_fim
medium
{ "lang": "rust", "repo": "seanchen1991/vecdraw", "path": "/src/layer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct UpdateState<'a> { pub encoder: &'a RefCell<CommandEncoder>, pub device: &'a Device, } pub trait Drawable { fn update(&self, _update_state: &UpdateState) {} fn draw<'a>(&'a self, draw_state: &DrawState<'a>); }<|fim_prefix|>// repo: seanchen1991/vecdraw path: /src/layer.rs use ...
code_fim
hard
{ "lang": "rust", "repo": "seanchen1991/vecdraw", "path": "/src/layer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} pub struct DrawState<'a> { pub render_pass: RefCell<RenderPass<'a>>, pub bind_group: &'a BindGroup, } pub struct UpdateState<'a> { pub encoder: &'a RefCell<CommandEncoder>, pub device: &'a Device, } pub trait Drawable { fn update(&self, _update_state: &UpdateState) {} fn draw...
code_fim
medium
{ "lang": "rust", "repo": "seanchen1991/vecdraw", "path": "/src/layer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: howl111/ton-eth-bridge-relay path: /relay-ton/src/contracts/mod.rs pub use bridge::*; pub use contract::*; pub use errors::*; pub use eth_event::*; pub use eth_event_configuration::*; pub use models::*; pub use relay_contract::*; pub use ton_event::*; pub use ton_event_configuration::*; pub use ...
code_fim
medium
{ "lang": "rust", "repo": "howl111/ton-eth-bridge-relay", "path": "/relay-ton/src/contracts/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod contract; pub mod errors; pub mod message_builder; pub mod models; mod prelude;<|fim_prefix|>// repo: howl111/ton-eth-bridge-relay path: /relay-ton/src/contracts/mod.rs pub use bridge::*; pub use contract::*; pub use errors::*; pub use eth_event::*; pub use eth_event_configuration::*; pub use models:...
code_fim
medium
{ "lang": "rust", "repo": "howl111/ton-eth-bridge-relay", "path": "/relay-ton/src/contracts/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CenterDevice/ceres-lambda path: /aws-scaletower/src/events/mod.rs use crate::{config::FunctionConfig, error::AwsScaleTowerError}; use aws::AwsClientConfig; use bosun::{Bosun, Datum, Tags}; use failure::{Error, Fail}; use lambda_runtime::Context; use log::debug; use serde_derive::{Deserialize, Se...
code_fim
hard
{ "lang": "rust", "repo": "CenterDevice/ceres-lambda", "path": "/aws-scaletower/src/events/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn handle_event<T: Bosun>( aws_client_config: &AwsClientConfig, event: Event, ctx: &Context, config: &FunctionConfig, bosun: &T, ) -> Result<HandleResult, Error> { match event { Event::Cron(_) => cron::handle(aws_client_config, ctx, config, bosun), Event::Ping(ping)...
code_fim
hard
{ "lang": "rust", "repo": "CenterDevice/ceres-lambda", "path": "/aws-scaletower/src/events/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Id405/sea.0 path: /src/server/server.rs use std::fs::File; use std::io::Read; use std::path::Path; use futures::prelude::*; use irc::client::Client; use irc::proto::Command; use std::default::Default; use std::env; use crate::protocol::common::Message; use crate::protocol::common::MessageType;...
code_fim
hard
{ "lang": "rust", "repo": "Id405/sea.0", "path": "/src/server/server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", absolute_path.to_str().unwrap()); if absolute_path.is_file() { let mut file = File::open(absolute_path).unwrap(); let mut ...
code_fim
hard
{ "lang": "rust", "repo": "Id405/sea.0", "path": "/src/server/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> mut W, } impl<'a> EXTMEM_ICACHE_SYNC_SIZE_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u32) -> &'a mut W { self.w.bits = (self.w.bits & !0x007f_ffff) | ((value as u32) & 0x007f_ffff); self.w } } impl R { #[doc = "Bi...
code_fim
hard
{ "lang": "rust", "repo": "ForsakenHarmony/esp32c3-pac", "path": "/src/extmem/extmem_icache_sync_size.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/extmem/extmem_icache_sync_size.rs #[doc = "Reader of register EXTMEM_ICACHE_SYNC_SIZE"] pub type R = crate::R<u32, super::EXTMEM_ICACHE_SYNC_SIZE>; #[doc = "Writer for register EXTMEM_ICACHE_SYNC_SIZE"] pub type W = crate::W<u32, super::EXTMEM_ICACHE_SYNC_S...
code_fim
hard
{ "lang": "rust", "repo": "ForsakenHarmony/esp32c3-pac", "path": "/src/extmem/extmem_icache_sync_size.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ne0ndrag0n/MauveWeasel path: /src/mauveweasel/mod.rs pub mod server; pub mod options; pub mod utility; pub mod router; pub mod compon<|fim_suffix|>mod helpers; pub mod tools; pub mod fdo;<|fim_middle|>ents; pub mod http; pub mod cookie; pub
code_fim
easy
{ "lang": "rust", "repo": "ne0ndrag0n/MauveWeasel", "path": "/src/mauveweasel/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod helpers; pub mod tools; pub mod fdo;<|fim_prefix|>// repo: ne0ndrag0n/MauveWeasel path: /src/mauveweasel/mod.rs pub mod server; pub mod options; pub mod<|fim_middle|> utility; pub mod router; pub mod components; pub mod http; pub mod cookie; pub
code_fim
medium
{ "lang": "rust", "repo": "ne0ndrag0n/MauveWeasel", "path": "/src/mauveweasel/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ents; pub mod http; pub mod cookie; pub mod helpers; pub mod tools; pub mod fdo;<|fim_prefix|>// repo: ne0ndrag0n/MauveWeasel path: /src/mauveweasel/mod.rs pub mod server; pub mod options; pub mod<|fim_middle|> utility; pub mod router; pub mod compon
code_fim
easy
{ "lang": "rust", "repo": "ne0ndrag0n/MauveWeasel", "path": "/src/mauveweasel/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(target_os = "linux")] pub fn open(url: &Url) { let _ = std::process::Command::new("xdg-open").arg(url.to_string()).output(); }<|fim_prefix|>// repo: overdrivenpotato/url_open path: /src/lib.rs //! # url_open //! A simple crate to open URLs in the default web browser. //! //! ### Usage //! //! `...
code_fim
hard
{ "lang": "rust", "repo": "overdrivenpotato/url_open", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: overdrivenpotato/url_open path: /src/lib.rs //! # url_open //! A simple crate to open URLs in the default web browser. //! //! ### Usage //! //! ```no_run //! extern crate url; //! extern crate url_open; //! //! use url::Url; //! use url_open::UrlOpen; //! //! fn main() { //! Url::parse("htt...
code_fim
hard
{ "lang": "rust", "repo": "overdrivenpotato/url_open", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: omikuji/libunftp path: /src/lib.rs #![deny(missing_docs)] //! FTP server library for Rust //! //! The libunftp library is a safe, fast and extensible FTP server implementation in Rust. //! //! Because of its plugable authentication and storage backends (e.g. local filesystem, Google //! Buckets)...
code_fim
hard
{ "lang": "rust", "repo": "omikuji/libunftp", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Contains the `add...metric` functions that are used for gathering metrics. pub mod metrics; #[cfg(any(feature = "rest", feature = "pam"))] #[macro_use] extern crate log;<|fim_prefix|>// repo: omikuji/libunftp path: /src/lib.rs #![deny(missing_docs)] //! FTP server library for Rust //! //! The libunf...
code_fim
hard
{ "lang": "rust", "repo": "omikuji/libunftp", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kdy1/cosmos_client path: /src/models/base_req.rs /* * Gaia-Lite for Cosmos * * A REST interface for state queries, transaction generation and broadcasting. * * OpenAPI spec version: 3.0 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ #[allow(unused_imports)] u...
code_fim
hard
{ "lang": "rust", "repo": "kdy1/cosmos_client", "path": "/src/models/base_req.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn gas_adjustment(&self) -> Option<&String> { self.gas_adjustment.as_ref() } pub fn reset_gas_adjustment(&mut self) { self.gas_adjustment = None; } pub fn set_fees(&mut self, fees: Vec<::models::Coin>) { self.fees = Some(fees); } pub fn with_fees(mut self, fees: Vec<::mode...
code_fim
hard
{ "lang": "rust", "repo": "kdy1/cosmos_client", "path": "/src/models/base_req.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coffeenotfound/rsfunge path: /src/interpreter/funge_dimension.rs use typenum; pub trait FungeDimension { type Dimension: typenum::Unsigned; } <|fim_suffix|>// Two dimensional pub struct FungeDim2; impl FungeDimension for FungeDim2 { type Dimension = typenum::U1; } // Three dimensional pub s...
code_fim
medium
{ "lang": "rust", "repo": "coffeenotfound/rsfunge", "path": "/src/interpreter/funge_dimension.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// Two dimensional pub struct FungeDim2; impl FungeDimension for FungeDim2 { type Dimension = typenum::U1; } // Three dimensional pub struct FungeDim3; impl FungeDimension for FungeDim3 { type Dimension = typenum::U1; }<|fim_prefix|>// repo: coffeenotfound/rsfunge path: /src/interpreter/funge_dimensio...
code_fim
medium
{ "lang": "rust", "repo": "coffeenotfound/rsfunge", "path": "/src/interpreter/funge_dimension.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_truncate_middle_length_2() { assert_eq!(truncate_middle("a", 5), Cow::from("a")); } #[test] fn test_truncate_middle_length_5() { assert_eq!(truncate_middle("abcde", 5), Cow::from("abcde")); } #[test] fn test_truncate_middle_length_6() { ...
code_fim
medium
{ "lang": "rust", "repo": "It4innovations/hyperqueue", "path": "/crates/hyperqueue/src/common/utils/str.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: It4innovations/hyperqueue path: /crates/hyperqueue/src/common/utils/str.rs use std::borrow::Cow; /// Return the input string with an added "s" at the end if `count` is larger than one and non-zero. pub fn pluralize(value: &str, count: usize) -> Cow<str> { if count == 1 { Cow::Borrow...
code_fim
medium
{ "lang": "rust", "repo": "It4innovations/hyperqueue", "path": "/crates/hyperqueue/src/common/utils/str.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_truncate_middle_length_5() { assert_eq!(truncate_middle("abcde", 5), Cow::from("abcde")); } #[test] fn test_truncate_middle_length_6() { assert_eq!(truncate_middle("abcdef", 5), Cow::from("a...f")); } }<|fim_prefix|>// repo: It4innovations/hyperqueu...
code_fim
medium
{ "lang": "rust", "repo": "It4innovations/hyperqueue", "path": "/crates/hyperqueue/src/common/utils/str.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: czyczk/LeetCode path: /rust/lc-447/src/solution.rs pub struct Solution {} impl Solution { pub fn number_of_boomerangs(points: Vec<Vec<i32>>) -> i32 { let mut ret = 0; for<|fim_suffix|>= 1; } for (_, v) in dist_cnt_map { ret += v * (v ...
code_fim
hard
{ "lang": "rust", "repo": "czyczk/LeetCode", "path": "/rust/lc-447/src/solution.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>= 1; } for (_, v) in dist_cnt_map { ret += v * (v - 1); } } ret } }<|fim_prefix|>// repo: czyczk/LeetCode path: /rust/lc-447/src/solution.rs pub struct Solution {} impl Solution { pub fn number_of_boomerangs(points: Vec<Vec<i3...
code_fim
hard
{ "lang": "rust", "repo": "czyczk/LeetCode", "path": "/rust/lc-447/src/solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>&$lhs, &$rhs) { (lhs, rhs) => { if !(*lhs == *rhs) { $crate::disappoint( Box::new(format!( r#"expectation disappointed: `(left == right)` left: `{:?}`, right: `{:?}`: {}"#, &*...
code_fim
hard
{ "lang": "rust", "repo": "ubnt-intrepid/expected", "path": "/src/macros.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>s, rhs) => { if !(*lhs == *rhs) { $crate::disappoint( Box::new(format!( r#"expectation disappointed: `(left == right)` left: `{:?}`, right: `{:?}`"#, &*lhs, &*rhs ...
code_fim
hard
{ "lang": "rust", "repo": "ubnt-intrepid/expected", "path": "/src/macros.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ubnt-intrepid/expected path: /src/macros.rs /// Declare an expectation that the specified conditional expression is true. /// /// Unlike `assert!` in the standard library, this macro does not panic /// when the condition is not satisfied. Instead, it will store the information /// that the expec...
code_fim
hard
{ "lang": "rust", "repo": "ubnt-intrepid/expected", "path": "/src/macros.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marcogmaia/rustrl path: /src/map.rs mod glyphs; use std::{ cmp::{max, min}, usize, }; use bracket_lib::prelude::{to_cp437, BTerm, RandomNumberGenerator, Rect, RGBA}; // use super::Rect; #[derive(PartialEq, Copy, Clone)] pub enum TileType { Wall, Floor, } pub struct Map { ...
code_fim
hard
{ "lang": "rust", "repo": "marcogmaia/rustrl", "path": "/src/map.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const MAX_ROOMS: i32 = 30; const MIN_SIZE: i32 = 6; const MAX_SIZE: i32 = 10; let mut rng = RandomNumberGenerator::new(); for _i in 0..MAX_ROOMS { let rw = rng.range(MIN_SIZE, MAX_SIZE); let rh = rng.range(MIN_SIZE, MAX_SIZE); l...
code_fim
hard
{ "lang": "rust", "repo": "marcogmaia/rustrl", "path": "/src/map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _i in 0..MAX_ROOMS { let rw = rng.range(MIN_SIZE, MAX_SIZE); let rh = rng.range(MIN_SIZE, MAX_SIZE); let x = rng.range(1, w - rw - 1); let y = rng.range(1, h - rh - 1); let new_room = Rect::with_size(x, y, rw, rh); let mut...
code_fim
hard
{ "lang": "rust", "repo": "marcogmaia/rustrl", "path": "/src/map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if buf.len() as u64 != self.sector_size() { return Err(io::Error::from(io::ErrorKind::InvalidInput)); } let mut cache = self.cache.borrow_mut(); let cache_entry = cache.cache_entry(n, &self.source)?; buf.copy_from_slice(&cache_entry.data); Ok(())...
code_fim
hard
{ "lang": "rust", "repo": "Disasm/rpi-os-fs", "path": "/fat32/src/cache.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Disasm/rpi-os-fs path: /fat32/src/cache.rs use traits::BlockDevice; use std::io; use std::collections::HashMap; use std::cell::RefCell; #[derive(Debug)] struct CacheEntry { data: Vec<u8>, is_dirty: bool } struct Cache(HashMap<u64, CacheEntry>); impl Cache { fn cache_entry<T: Bloc...
code_fim
hard
{ "lang": "rust", "repo": "Disasm/rpi-os-fs", "path": "/fat32/src/cache.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>n the LICENSE file. pub mod brw_stats_parser; pub mod job_stats; pub mod ldlm_parser; pub mod obdfilter_parser; pub mod oss_parser;<|fim_prefix|>// repo: greyspectrum/lustre-collector path: /src/oss/mod.rs // Copyright (c) 2018 DDN. All rights reserved. // Use of this sou<|fim_middle|>rce code is govern...
code_fim
medium
{ "lang": "rust", "repo": "greyspectrum/lustre-collector", "path": "/src/oss/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: greyspectrum/lustre-collector path: /src/oss/mod.rs // Copyright (c) 2018 DDN. All rights reserved. // Use of this sou<|fim_suffix|>n the LICENSE file. pub mod brw_stats_parser; pub mod job_stats; pub mod ldlm_parser; pub mod obdfilter_parser; pub mod oss_parser;<|fim_middle|>rce code is govern...
code_fim
medium
{ "lang": "rust", "repo": "greyspectrum/lustre-collector", "path": "/src/oss/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Set return value of syscall pub fn set_syscall_ret(&mut self, ret: usize) { self.general.rax = ret; } /// Get syscall args pub fn get_syscall_args(&self) -> [usize; 6] { [ self.general.rdi, self.general.rsi, self.general.rdx, ...
code_fim
hard
{ "lang": "rust", "repo": "wying8349/trapframe-rs", "path": "/src/arch/x86_64/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wying8349/trapframe-rs path: /src/arch/x86_64/mod.rs #[cfg(any(target_os = "linux", target_os = "macos"))] mod fncall; #[cfg(any(target_os = "none", target_os = "uefi"))] mod gdt; #[cfg(any(target_os = "none", target_os = "uefi"))] mod idt; #[cfg(feature = "ioport_bitmap")] #[cfg(any(target_os =...
code_fim
hard
{ "lang": "rust", "repo": "wying8349/trapframe-rs", "path": "/src/arch/x86_64/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/necsim-rust path: /rust-cuda/rust-cuda-derive/src/rust_to_cuda/impl.rs use proc_macro2::TokenStream; use quote::quote; pub fn cuda_struct_declaration( struct_attrs_cuda: &[syn::Attribute], struct_vis_cuda: &syn::Visibility, struct_name_cuda: &syn::Ident, struct_generics...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/necsim-rust", "path": "/rust-cuda/rust-cuda-derive/src/rust_to_cuda/impl.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let (impl_generics, ty_generics, where_clause) = &struct_generics_cuda.split_for_impl(); quote! { unsafe impl #impl_generics rust_cuda::common::CudaAsRust for #struct_name_cuda #ty_generics #where_clause { type RustRepresentation = #struct_name #ty_generics...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/necsim-rust", "path": "/rust-cuda/rust-cuda-derive/src/rust_to_cuda/impl.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>pub fn cuda_as_rust_trait( struct_name: &syn::Ident, struct_name_cuda: &syn::Ident, struct_generics_cuda: &syn::Generics, struct_fields_cuda: &syn::Fields, c2r_field_initialisations: &[TokenStream], ) -> TokenStream { let cuda_as_rust_struct_construction = match struct_fields_cuda ...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/necsim-rust", "path": "/rust-cuda/rust-cuda-derive/src/rust_to_cuda/impl.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>fn part_2(chunk: &str) -> usize { chunk .split("\n\n") .map(|group| { group .split("\n") .map(|s| s.chars().collect::<HashSet<_>>()) .fold_first(|x, y| x.intersection(&y).cloned().collect()) .map(|xs| xs.len())...
code_fim
hard
{ "lang": "rust", "repo": "nulladdict/aoc-2020", "path": "/packages/day-06/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nulladdict/aoc-2020 path: /packages/day-06/src/main.rs #![feature(iterator_fold_self)] use std::collections::HashSet; use std::io::Read; fn main() -> Result<(), Box<dyn std::error::Error>> { let mut buffer = String::new(); std::io::stdin().read_to_string(&mut buffer)?; println!("{:?...
code_fim
hard
{ "lang": "rust", "repo": "nulladdict/aoc-2020", "path": "/packages/day-06/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: will-zegers/rust-raytracer path: /src/hittable/bvh.rs // TODO: unit tests #![allow(dead_code)] use std::cmp::Ordering; use std::rc::Rc; use rand::Rng; use super::Ray; use crate::hittable::{HitRecord, Hittable, AABB}; pub struct BVHNode { left: Rc<dyn Hittable>, right: Rc<dyn Hittabl...
code_fim
hard
{ "lang": "rust", "repo": "will-zegers/rust-raytracer", "path": "/src/hittable/bvh.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !self.bbox.hit(ray, t_min, t_max) { return None; } match self.left.hit(ray, t_min, t_max) { Some(lrec) => match self.right.hit(ray, t_min, lrec.t) { Some(rrec) => return Some(rrec), None => return Some(lrec), }...
code_fim
hard
{ "lang": "rust", "repo": "will-zegers/rust-raytracer", "path": "/src/hittable/bvh.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn box_compare(a: &Rc<dyn Hittable>, b: &Rc<dyn Hittable>, axis: usize) -> Ordering { let box_a = a .bounding_box() .expect("No bounding box in BVHNode constructor"); let box_b = b .bounding_box() .expect("No bounding box in BVHNode const...
code_fim
hard
{ "lang": "rust", "repo": "will-zegers/rust-raytracer", "path": "/src/hittable/bvh.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mgill25/delta-rs path: /rust/tests/checkpoint_writer_test.rs use std::collections::{HashMap, HashSet}; use std::fs; use std::iter::FromIterator; use std::path::{Path, PathBuf}; use chrono::Utc; use maplit::hashmap; use uuid::Uuid; use deltalake::action::*; use deltalake::*; mod fs_common; //...
code_fim
hard
{ "lang": "rust", "repo": "mgill25/delta-rs", "path": "/rust/tests/checkpoint_writer_test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // r2 has extended_file_metadata=false, then every tombstone should be so, even r1 assert_ne!(actions, vec![r1.clone(), r2.clone()]); assert!(!schema.contains("size")); assert!(!schema.contains("partitionValues")); assert!(!schema.contains("tags")); let r1_u...
code_fim
hard
{ "lang": "rust", "repo": "mgill25/delta-rs", "path": "/rust/tests/checkpoint_writer_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solana-labs/example-messagefeed path: /bpf-rust-programs/prediction-poll/wasm_bindings/src/lib.rs #![no_std] #[macro_use] extern crate alloc; extern crate arrayref; extern crate console_error_panic_hook; <|fim_suffix|>pub use clock::*; pub use collection::*; pub use init_poll::*; pub use poll:...
code_fim
medium
{ "lang": "rust", "repo": "solana-labs/example-messagefeed", "path": "/bpf-rust-programs/prediction-poll/wasm_bindings/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use clock::*; pub use collection::*; pub use init_poll::*; pub use poll::*; pub use tally::*;<|fim_prefix|>// repo: solana-labs/example-messagefeed path: /bpf-rust-programs/prediction-poll/wasm_bindings/src/lib.rs #![no_std] #[macro_use] extern crate alloc; extern crate arrayref; extern crate consol...
code_fim
medium
{ "lang": "rust", "repo": "solana-labs/example-messagefeed", "path": "/bpf-rust-programs/prediction-poll/wasm_bindings/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brndnmtthws/cracking-the-coding-interview-rust path: /src/bin/c04p08.rs use std::cell::RefCell; use std::fmt::Display; use std::rc::Rc; type VertexRef<T> = Rc<RefCell<Vertex<T>>>; struct Graph<T> { head: Vec<VertexRef<T>>, } struct Vertex<T> { data: T, edges: Vec<VertexRef<T>>, } ...
code_fim
hard
{ "lang": "rust", "repo": "brndnmtthws/cracking-the-coding-interview-rust", "path": "/src/bin/c04p08.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> where F: FnMut(&VertexRef<T>), { for head in self.head.iter() { self.dfs_from(&mut f, head.clone()); } } fn common_ancestor_from<F>( &self, f: &mut F, vertex: VertexRef<T>, left_vertex: &VertexRef<T>, right_vertex...
code_fim
hard
{ "lang": "rust", "repo": "brndnmtthws/cracking-the-coding-interview-rust", "path": "/src/bin/c04p08.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bqqbarbhg/adventofcode path: /2022/21/part2.rs mod common; use common::{to_name, Name, Value, Expr}; use std::collections::HashMap; fn main() { let monkeys: HashMap<_, _> = std::io::stdin().lines() .flat_map(|l| l.ok()) .filter(|l| !l.trim().is_empty()) .map(|l| { ...
code_fim
hard
{ "lang": "rust", "repo": "bqqbarbhg/adventofcode", "path": "/2022/21/part2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Evaluate the 'root' monkey let mut stack = vec![root]; let mut values: HashMap<Name, Value> = HashMap::new(); while let Some(name) = stack.pop() { let expr = monkeys.get(&name).unwrap(); if let Some(value) = expr.eval(&values) { values.insert(name, value); ...
code_fim
hard
{ "lang": "rust", "repo": "bqqbarbhg/adventofcode", "path": "/2022/21/part2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: memorysafety/sudo-rs path: /src/exec/no_pty.rs use std::{ ffi::c_int, io::{self, Read, Write}, os::unix::{net::UnixStream, process::CommandExt}, process::Command, }; use super::{ event::PollEvent, event::{EventRegistry, Process, StopReason}, io_util::was_interrupted,...
code_fim
hard
{ "lang": "rust", "repo": "memorysafety/sudo-rs", "path": "/src/exec/no_pty.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(tty) = opt_tty.as_ref() { if let Ok(saved_pgrp) = tty.tcgetpgrp() { // Save the terminal's foreground process group so we can restore it after resuming // if needed. opt_pgrp = Some(saved_pgrp); } else { ...
code_fim
hard
{ "lang": "rust", "repo": "memorysafety/sudo-rs", "path": "/src/exec/no_pty.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> io::stdin().read_line(&mut n) .expect("Failed to read n."); let n: i32 = match n.trim().parse() { Ok(num) => num, Err(_) => { println!("The selected n wasn't a number!"); return; } }; let fibonnaci = (GOLDEN_RATIO.powi(n) - (1. - GO...
code_fim
hard
{ "lang": "rust", "repo": "Gustash/rust-terminal-app", "path": "/src/fibonacci.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gustash/rust-terminal-app path: /src/fibonacci.rs use std::io; const GOLDEN_RATIO: f64 = 1.618034; pub fn fibonacci_program() { println!("Fionacci Sequence"); println!("\nWhat nth number do you want?"); let mut n = String::new(); io::stdin().read_line(&mut n) .expect(...
code_fim
hard
{ "lang": "rust", "repo": "Gustash/rust-terminal-app", "path": "/src/fibonacci.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KristonCosta/verbose-adventure path: /console_backend/src/render_gl/viewport.rs use gl; use glutin::{dpi::{LogicalSize, PhysicalSize}, window::Window}; pub struct Viewport { pub x: i32, pub y: i32, pub w: i32, pub h: i32, } impl Viewport { pub fn for_window(size: LogicalSiz...
code_fim
medium
{ "lang": "rust", "repo": "KristonCosta/verbose-adventure", "path": "/console_backend/src/render_gl/viewport.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>fn get_physical_size(size: LogicalSize, window: &Window) -> PhysicalSize { size.to_physical(window.hidpi_factor()) }<|fim_prefix|>// repo: KristonCosta/verbose-adventure path: /console_backend/src/render_gl/viewport.rs use gl; use glutin::{dpi::{LogicalSize, PhysicalSize}, window::Window}; pub struc...
code_fim
hard
{ "lang": "rust", "repo": "KristonCosta/verbose-adventure", "path": "/console_backend/src/render_gl/viewport.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_all(files: &HashMap<RelativePathBuf, String>, config: ParseConfig) -> Result<HashMap<ModPath, ParseResultAndContent>, ParseErrorWithPosAndFile> { let mut all_parsed_files: HashMap<ModPath, ParseResultAndContent> = HashMap::new(); // parse for (rel_path, content) in files { i...
code_fim
hard
{ "lang": "rust", "repo": "Nercury/ppc", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nercury/ppc path: /src/main.rs use walkdir::WalkDir; use gumdrop::Options; use std::path::{PathBuf}; pub mod error; pub mod parsing; pub mod tst; pub mod relt; pub mod runtime; #[macro_use] extern crate log; use std::collections::HashMap; use relative_path::{RelativePathBuf}; use crate::tst::...
code_fim
hard
{ "lang": "rust", "repo": "Nercury/ppc", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HalfVoxel/graphica path: /src/catmull_rom.rs use crate::{geometry_utilities::types::CanvasPoint, path::PathData}; pub fn catmull_rom_smooth(points: &[CanvasPoint]) -> PathData { let mut result = PathData::default(); match points.len() { 0 | 1 => { // emit nothing ...
code_fim
hard
{ "lang": "rust", "repo": "HalfVoxel/graphica", "path": "/src/catmull_rom.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ath.point_mut(vertex) .prev_mut() .unwrap() .set_control_after(c1.to_point()); path.point_mut(vertex).set_control_before(c2.to_point()); }; // count >= 3 let count = points.l...
code_fim
hard
{ "lang": "rust", "repo": "HalfVoxel/graphica", "path": "/src/catmull_rom.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>oints[0], points[0], points[1], points[2]); for i in 0..count - 3 { catmull_rom_to(&mut result, points[i], points[i + 1], points[i + 2], points[i + 3]); } // Draw last curve catmull_rom_to( &mut result, points[...
code_fim
hard
{ "lang": "rust", "repo": "HalfVoxel/graphica", "path": "/src/catmull_rom.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saward/soloud-rs path: /soloud/src/filter/lofi.rs use super::ParamType; use crate::prelude::*; /// Lofi filter attributes #[repr(u32)] #[derive(FilterAttr, Copy, Clone, Debug, PartialOrd, PartialEq)] pub enum LofiFilterAttr { /// Wet attribute Wet = 0, /// Samplerate attribute S...
code_fim
medium
{ "lang": "rust", "repo": "saward/soloud-rs", "path": "/soloud/src/filter/lofi.rs", "mode": "psm", "license": "LicenseRef-scancode-other-permissive", "source": "the-stack-v2" }
<|fim_suffix|>impl LofiFilter { /// Set filter params pub fn set_params(&mut self, samplerate: f32, bit_depth: f32) -> Result<(), SoloudError> { ffi_call!(soloud_sys::soloud::LofiFilter_setParams( self._inner, samplerate, bit_depth )) } }<|fim_prefix|>// r...
code_fim
medium
{ "lang": "rust", "repo": "saward/soloud-rs", "path": "/soloud/src/filter/lofi.rs", "mode": "spm", "license": "LicenseRef-scancode-other-permissive", "source": "the-stack-v2" }
<|fim_suffix|> if !(transitions == 1 || transitions == 2) { continue; } if phase_one { if transitions == 1 { if (p2 == Edge::Empty || p4 == Edge::Empty || p6 == Edge::Empty) ...
code_fim
hard
{ "lang": "rust", "repo": "VariousForks/skeletonize", "path": "/src/thinning.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VariousForks/skeletonize path: /src/thinning.rs //! Functions for performing image thinning. use image::GenericImage; use crate::error::{LumaConversionErrorKind, SkeletonizeError}; use crate::neighbors::get_neighbor_info; use crate::{Edge, ForegroundColor, MarkingMethod}; /// Perform image th...
code_fim
hard
{ "lang": "rust", "repo": "VariousForks/skeletonize", "path": "/src/thinning.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Database { #[cold] pub fn new(uri: &str) -> BotResult<Self> { let pool = PgPoolOptions::new().connect_lazy(uri)?; Ok(Self { pool }) } }<|fim_prefix|>// repo: JoshiDhima/Bathbot path: /src/database/mod.rs mod impls; mod models; mod util; use sqlx::postgres::{PgPool, PgPo...
code_fim
medium
{ "lang": "rust", "repo": "JoshiDhima/Bathbot", "path": "/src/database/mod.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoshiDhima/Bathbot path: /src/database/mod.rs mod impls; mod models; mod util; use sqlx::postgres::{PgPool, PgPoolOptions}; <|fim_suffix|>pub struct Database { pool: PgPool, } impl Database { #[cold] pub fn new(uri: &str) -> BotResult<Self> { let pool = PgPoolOptions::new(...
code_fim
hard
{ "lang": "rust", "repo": "JoshiDhima/Bathbot", "path": "/src/database/mod.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>// # define v_lookup(table, index, shift) \ // _mm_shuffle_epi8((table), \ // v_and(_mm_srli_epi16((index), (shift)), v_set1(0x0F))) #[inline(always)] pub(crate) unsafe fn v_lookup_4(table: __m128i, inde...
code_fim
hard
{ "lang": "rust", "repo": "simd-lite/faster-utf8-validator-rs", "path": "/src/sse.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simd-lite/faster-utf8-validator-rs path: /src/sse.rs #[cfg(target_arch = "x86")] use std::arch::x86::*; #[cfg(target_arch = "x86_64")] use std::arch::x86_64::*; // // SSE definitions. We require at least SSE4.1 for _mm_test_all_zeros() // # define z_validate_utf8 z_validate_utf8_sse4 // # ...
code_fim
hard
{ "lang": "rust", "repo": "simd-lite/faster-utf8-validator-rs", "path": "/src/sse.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[inline(always)] pub(crate) unsafe fn v_lookup_0(table: __m128i, index: __m128i) -> __m128i { _mm_shuffle_epi8(table, v_and(_mm_srli_epi16(index, 0), v_set1(0x0F))) } // # define V_TABLE_16(...) _mm_setr_epi8(__VA_ARGS__) #[inline(always)] pub(crate) unsafe fn v_table_16( v0: i8, v1: i8, ...
code_fim
hard
{ "lang": "rust", "repo": "simd-lite/faster-utf8-validator-rs", "path": "/src/sse.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FlyingRatBull/heron path: /build.rs fn main() { let mut files = skeptic:<|fim_suffix|>); files.push("README.md".into()); skeptic::generate_doc_tests(&files); }<|fim_middle|>:markdown_files_of_directory("guide/src"
code_fim
easy
{ "lang": "rust", "repo": "FlyingRatBull/heron", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> skeptic::generate_doc_tests(&files); }<|fim_prefix|>// repo: FlyingRatBull/heron path: /build.rs fn main() { let mut files = skeptic:<|fim_middle|>:markdown_files_of_directory("guide/src"); files.push("README.md".into());
code_fim
medium
{ "lang": "rust", "repo": "FlyingRatBull/heron", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>); files.push("README.md".into()); skeptic::generate_doc_tests(&files); }<|fim_prefix|>// repo: FlyingRatBull/heron path: /build.rs fn main() { let mut files = skeptic:<|fim_middle|>:markdown_files_of_directory("guide/src"
code_fim
easy
{ "lang": "rust", "repo": "FlyingRatBull/heron", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Heaps cannot be used for CPU coherent resources if self.private_caps.resource_heaps && storage != MTLStorageMode::Shared { let descriptor = MTLHeapDescriptor::new(); descriptor.set_storage_mode(storage); descriptor.set_cpu_cache_mode(cache); ...
code_fim
hard
{ "lang": "rust", "repo": "msiglreith/gfx", "path": "/src/backend/metalll/src/factory.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: msiglreith/gfx path: /src/backend/metalll/src/factory.rs ayouts().object_at(i); mtl_buffer_desc.set_stride(vertex_buffer.stride as u64); match vertex_buffer.rate { 0 => { // FIXME: should this use MTLVert...
code_fim
hard
{ "lang": "rust", "repo": "msiglreith/gfx", "path": "/src/backend/metalll/src/factory.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(feature = "argument_buffer")] fn update_descriptor_sets(&mut self, writes: &[f::DescriptorSetWrite<Resources>]) { use core::factory::DescriptorWrite::*; let mut mtl_samplers = Vec::new(); let mut mtl_textures = Vec::new(); for write in writes { w...
code_fim
hard
{ "lang": "rust", "repo": "msiglreith/gfx", "path": "/src/backend/metalll/src/factory.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }