text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: snf/synthir path: /src/utils.rs use num::bigint::{ToBigUint, BigUint}; use num::traits::{One, ToPrimitive}; use std::num::ParseIntError; use std::mem; pub trait Max { fn max(width: u32) -> Self; } impl Max for BigUint { fn max(width: u32) -> BigUint { (BigUint::one() << width a...
code_fim
hard
{ "lang": "rust", "repo": "snf/synthir", "path": "/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let full_64_u64 = 0xffFF_ffFF_ffFF_ffFFu64; assert_eq!(full_64_u64.hamming_weight(), 64); let full_64_bu = 0xffFF_ffFF_ffFF_ffFFu64.to_biguint().unwrap(); assert_eq!(full_64_bu.hamming_weight(), 64); } #[test] fn test_biguint() { assert_eq!(0xaabbccddu...
code_fim
hard
{ "lang": "rust", "repo": "snf/synthir", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { let widget::UpdateArgs { id, state, rect, ui, style, .. } = args; widget::BorderedRectangle::new([20.0, 20.0]) .border(2.0) .border_rgb(1.0, 0.0, 0.0) .rgb(0.0, 1.0, 0...
code_fim
hard
{ "lang": "rust", "repo": "AndreasOlofsson/raytracer", "path": "/src/_ui/debug_box/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndreasOlofsson/raytracer path: /src/_ui/debug_box/mod.rs use conrod_core::{ self, widget_ids, widget, Widget, Borderable, Colorable, Positionable, position, position::Position, position::Place, position::Dimension, }; #[derive(WidgetCommon)] pub stru...
code_fim
hard
{ "lang": "rust", "repo": "AndreasOlofsson/raytracer", "path": "/src/_ui/debug_box/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunng87/handlebars-iron path: /examples/watch_server.rs #![allow(dead_code, unused_imports)] extern crate handlebars_iron as hbs; extern crate iron; extern crate serde; #[macro_use] extern crate serde_json; #[macro_use] extern crate serde_derive; extern crate env_logger; #[cfg(feature = "watch"...
code_fim
hard
{ "lang": "rust", "repo": "sunng87/handlebars-iron", "path": "/examples/watch_server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "watch")] fn main() { use data::*; env_logger::init().unwrap(); let mut chain = Chain::new(hello_world); let mut hbse = HandlebarsEngine::new(); let source = Box::new(DirectorySource::new("./examples/templates/", ".hbs")); hbse.add(source); if let Err(r) = hbs...
code_fim
hard
{ "lang": "rust", "repo": "sunng87/handlebars-iron", "path": "/examples/watch_server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ndirangug/mpesa_api_rust path: /src/api_products/lipa_na_mpesa_online_payment_request/mod.rs //! Represenattion of lipa na mpesa online paymentrequest api //! //! Lipa na M-Pesa Online Payment API is used to initiate a M-Pesa transaction on behalf of a customer using STK //! Push. This is the s...
code_fim
hard
{ "lang": "rust", "repo": "Ndirangug/mpesa_api_rust", "path": "/src/api_products/lipa_na_mpesa_online_payment_request/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Represenattion ofresponses expected form a lipn ana mpesa online mpesa api call #[derive(Debug)] pub enum LipaNaMpesaOnlinePaymentResponse { /// Merchant Request ID MerchantRequestID, /// Check out Request ID CheckoutRequestID, /// Response Code ResponseCode, /// Result Des...
code_fim
hard
{ "lang": "rust", "repo": "Ndirangug/mpesa_api_rust", "path": "/src/api_products/lipa_na_mpesa_online_payment_request/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /bt/nsICertTree.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsICertTree.idl // {static D: &'static [Interface] = &[ Interface { name: "nsICertTreeItem", base: Some("nsISupports"), methods: Some...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/bt/nsICertTree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Interface { name: "nsICertTree", base: Some("nsITreeView"), methods: Some(&[ /* void loadCerts (in unsigned long type); */ Method { name: "loadCerts", abi: "C", ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/bt/nsICertTree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> point: Vector3, normal: Vector3) -> Box<Iterator<Item = &'a &Light> + 'a> { return Box::new(self.lights.iter().filter(move |l| { let ray_to_light = l.position - point; if ray_to_light.dot(normal) < 0.0 { ...
code_fim
hard
{ "lang": "rust", "repo": "Ben-Ramchandani/rust_tracer", "path": "/src/trace.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ben-Ramchandani/rust_tracer path: /src/trace.rs use vec3::Vector3; use super::Ray; use shape::Shape; use shape::Light; use screen; use super::color; use super::color::Color; use super::pnm; use super::shape::{ORIGIN, Sphere, Torus}; use std::io::stdout; struct World<'a> { shapes: Vec<&'a Sh...
code_fim
hard
{ "lang": "rust", "repo": "Ben-Ramchandani/rust_tracer", "path": "/src/trace.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/ripgrep path: /tests/binary.rs use crate::util::{Dir, TestCommand}; // This file contains a smattering of tests specifically for checking ripgrep's // handling of binary files. There's quite a bit of discussion on this in this // bug report: https://github.com/BurntSushi/ripgrep/issu...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/ripgrep", "path": "/tests/binary.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Like after_match1_implicit, but enables -a/--text, so no binary // detection should be performed. rgtest!(after_match1_implicit_text, |dir: Dir, mut cmd: TestCommand| { dir.create_bytes("hay", HAY); cmd.args(&[ "--no-mmap", "-n", "--text", "Project Gutenberg EBoo...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/ripgrep", "path": "/tests/binary.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/cloud9/src/model.rs Data Redacted ***"); formatter.finish() } } /// See [`Tag`](crate::model::Tag) pub mod tag { /// A builder for [`Tag`](crate::model::Tag) #[non_exhaustive] #[derive(std::default::Default, std::clone::Clone, std::cmp::Par...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/cloud9/src/model.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut formatter = f.debug_struct("EnvironmentLifecycle"); formatter.field("status", &self.status); formatter.field("reason", &self.reason); formatter.field("failure_resource", &self.failure_resource); formatter.finish() } } /// See [`EnvironmentLifecycle`](cra...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/cloud9/src/model.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/cloud9/src/model.rs MemberPermissions::Unknown(other.to_owned()), } } } impl std::str::FromStr for MemberPermissions { type Err = std::convert::Infallible; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { Ok(MemberPermissi...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/cloud9/src/model.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> friends } } pub fn request_user_information(&self, user: SteamId, name_only: bool) { unsafe { sys::SteamAPI_ISteamFriends_RequestUserInformation(self.friends, user.0, name_only as u8); } } // I don't know why this is part of friends either ...
code_fim
hard
{ "lang": "rust", "repo": "Scetch/steamworks-rs", "path": "/src/friends.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Scetch/steamworks-rs path: /src/friends.rs use super::*; bitflags! { #[repr(C)] pub struct FriendFlags: u16 { const NONE = 0x0000; const BLOCKED = 0x0001; const FRIENDSHIP_REQUESTED = 0x0002; const IMMEDIATE = ...
code_fim
hard
{ "lang": "rust", "repo": "Scetch/steamworks-rs", "path": "/src/friends.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn state(&self) -> FriendState { unsafe { let state = sys::SteamAPI_ISteamFriends_GetFriendPersonaState(self.friends, self.id.0); match state { sys::PersonaState::Offline => FriendState::Offline, sys::PersonaState::Online => FriendSta...
code_fim
hard
{ "lang": "rust", "repo": "Scetch/steamworks-rs", "path": "/src/friends.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: radicle-dev/bitcoins-rs path: /provider/src/lib.rs //! Pluggable standardized Bitcoin backend #![forbid(unsafe_code)] #![warn(missing_docs)] #![warn(unused_extern_crates)] #[doc(hidden)] #[macro_use] pub mod macros; /// Bitcoin Provider trait pub mod provider; /// Pending Transaction pub mod...
code_fim
medium
{ "lang": "rust", "repo": "radicle-dev/bitcoins-rs", "path": "/provider/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// The default poll interval, set to 300 seconds (5 minutes) pub const DEFAULT_POLL_INTERVAL: std::time::Duration = std::time::Duration::from_millis(180 * 1000); /// The default number of cache items to keep in a caching provider pub const DEFAULT_CACHE_SIZE: usize = 300; // Alias the default encoder t...
code_fim
hard
{ "lang": "rust", "repo": "radicle-dev/bitcoins-rs", "path": "/provider/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Utils pub mod utils; /// EsploraProvider #[cfg(feature = "esplora")] pub mod esplora; /// Local (or remote) node RPC #[cfg(feature = "rpc")] pub mod rpc; /// Common usage pub mod prelude; /// Minimal Types pub mod types; /// The default poll interval, set to 300 seconds (5 minutes) pub const DEFA...
code_fim
medium
{ "lang": "rust", "repo": "radicle-dev/bitcoins-rs", "path": "/provider/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Convert [`ArrayRef`] columns into [`Rows`] /// /// See [`Row`] for information on when [`Row`] can be compared /// /// # Panics /// /// Panics if the schema of `columns` does not match that provided to [`RowConverter::new`] pub fn convert_columns(&mut self, columns: &[A...
code_fim
hard
{ "lang": "rust", "repo": "andygrove/arrow-rs", "path": "/arrow-row/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let len = self.len(); (len, Some(len)) } } impl<'a> ExactSizeIterator for RowsIter<'a> { fn len(&self) -> usize { self.end - self.start } } impl<'a> DoubleEndedIterator for RowsIter<'a> { fn next_back(&mut self) -> Option<Self::Item> { if self.end == self....
code_fim
hard
{ "lang": "rust", "repo": "andygrove/arrow-rs", "path": "/arrow-row/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andygrove/arrow-rs path: /arrow-row/src/lib.rs se arrow_row::{RowConverter, SortField}; //! # use arrow_array::{ArrayRef, Int32Array, StringArray}; //! # use arrow_array::cast::{AsArray, as_string_array}; //! # use arrow_array::types::Int32Type; //! # use arrow_schema::DataType; //! //! let a1 =...
code_fim
hard
{ "lang": "rust", "repo": "andygrove/arrow-rs", "path": "/arrow-row/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `I2C0RST` reader - I2C0RST"] pub type I2C0RST_R = crate::BitReader; #[doc = "Field `I2C0RST` writer - I2C0RST"] pub type I2C0RST_W<'a, const O: u8> = crate::BitWriter<'a, APBPRSTR1_SPEC, O>; #[doc = "Field `I2C1RST` reader - I2C1RST"] pub type I2C1RST_R = crate::Bi...
code_fim
hard
{ "lang": "rust", "repo": "ht32-rs/ht32-rs-nightlies", "path": "/ht32f5xxxx/src/ht32f52331_41/rstcu/apbprstr1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ht32-rs/ht32-rs-nightlies path: /ht32f5xxxx/src/ht32f52331_41/rstcu/apbprstr1.rs #[doc = "Register `APBPRSTR1` reader"] pub struct R(crate::R<APBPRSTR1_SPEC>); impl core::ops::Deref for R { type Target = crate::R<APBPRSTR1_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { ...
code_fim
hard
{ "lang": "rust", "repo": "ht32-rs/ht32-rs-nightlies", "path": "/ht32f5xxxx/src/ht32f52331_41/rstcu/apbprstr1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ray-kast/bot-george path: /src/bot-george/config.rs use crate::error::Result; use anyhow::Context; use log::info; use serde::Deserialize; use std::{env, env::VarError, fs::File, io::prelude::*}; <|fim_suffix|> let mut vec = vec![]; File::open(&path) .context("failed to open conf...
code_fim
hard
{ "lang": "rust", "repo": "ray-kast/bot-george", "path": "/src/bot-george/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Debug)] pub struct GeneralConfig { pub command_prefix: String, } #[derive(Deserialize, Debug)] pub struct AuthConfig { pub token: String, pub superuser: u64, } pub fn read() -> Result<Config> { let path = match env::var("BOT_GEORGE_CONFIG") { Ok(s) => s, ...
code_fim
medium
{ "lang": "rust", "repo": "ray-kast/bot-george", "path": "/src/bot-george/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>tect Enable"] #[inline(always)] pub fn oscctrl_(&self) -> OSCCTRL__R { OSCCTRL__R::new(((self.bits >> 4) & 0x01) != 0) } #[doc = "Bit 5 - OSC32KCTRL APB Protect Enable"] #[inline(always)] pub fn osc32kctrl_(&self) -> OSC32KCTRL__R { OSC32KCTRL__R::new(((self.bits >>...
code_fim
hard
{ "lang": "rust", "repo": "wgwoods/atsamd", "path": "/pac/atsame54p20a/src/pac/statusa.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>0 - EIC APB Protect Enable"] #[inline(always)] pub fn eic_(&self) -> EIC__R { EIC__R::new(((self.bits >> 10) & 0x01) != 0) } #[doc = "Bit 11 - FREQM APB Protect Enable"] #[inline(always)] pub fn freqm_(&self) -> FREQM__R { FREQM__R::new(((self.bits >> 11) & 0x01) !=...
code_fim
hard
{ "lang": "rust", "repo": "wgwoods/atsamd", "path": "/pac/atsame54p20a/src/pac/statusa.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wgwoods/atsamd path: /pac/atsame54p20a/src/pac/statusa.rs #[doc = "Reader of register STATUSA"] pub type R = crate::R<u32, super::STATUSA>; #[doc = "Reader of field `PAC_`"] pub type PAC__R = crate::R<bool, bool>; #[doc = "Reader of field `PM_`"] pub type PM__R = crate::R<bool, bool>; #[doc = "R...
code_fim
hard
{ "lang": "rust", "repo": "wgwoods/atsamd", "path": "/pac/atsame54p20a/src/pac/statusa.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Creates a reference to a [`Waker`](::std::task::Waker) /// from a local [`ArcWake`]. /// /// The resulting [`Waker`](::std::task::Waker) will call /// [`ArcWake.wake()`](ArcWake::wake) if awoken. #[inline] pub fn waker_ref<W>(wake: &Arc<W>) -> WakerRef<'_> where W: Wake { // This uses the same...
code_fim
hard
{ "lang": "rust", "repo": "tokio-rs/async", "path": "/arc-waker/src/waker_ref.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tokio-rs/async path: /arc-waker/src/waker_ref.rs use crate::Wake; use crate::waker::{clone, wake_by_ref}; use std::marker::PhantomData; use std::ops::Deref; use std::sync::Arc; use std::task::{Waker, RawWaker, RawWakerVTable}; #[derive(Debug)] pub struct WakerRef<'a> { waker: Waker, _m...
code_fim
medium
{ "lang": "rust", "repo": "tokio-rs/async", "path": "/arc-waker/src/waker_ref.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mangolang/compiler path: /src/lexing/tests.rs use crate::io::source::SourceFile; use crate::lexeme::collect::for_test::builder; use crate::lexing::lexer::CodeLexer; use crate::lexing::reader::source_reader::SourceReader; use super::lex; // use ::indoc::indoc; /// Create a set of source, reade...
code_fim
hard
{ "lang": "rust", "repo": "mangolang/compiler", "path": "/src/lexing/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let input = " let mut seq = [1, 4, 5, 2, 3,] let mut changed = true while changed: changed = false for i in seq.indices().skip_last(): if seq[i] > seq[i+1]: seq[i], seq[i+1] = seq[i+1], seq[i] changed = true assert seq == [1, 2, 3, 4, 5] "; let src = SourceF...
code_fim
hard
{ "lang": "rust", "repo": "mangolang/compiler", "path": "/src/lexing/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Terkwood/toppa_drill path: /src/resources/ingame/game_world/planet.rs use std::{ collections::{hash_map, BTreeMap, HashMap}, fs, path::*, }; use ron; use serde::Serializer; use amethyst::{ core::{nalgebra::Vector3, transform::components::Transform}, ecs::{prelude::*, world:...
code_fim
hard
{ "lang": "rust", "repo": "Terkwood/toppa_drill", "path": "/src/resources/ingame/game_world/planet.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tiles: BTreeMap<TileIndex, TileTypes> = match ron::de::from_reader(&file) { Ok(tiles) => tiles, Err(e) => { error!( "| Error deserializing {:?}: {:?}.", chunk_file_path.clone(), e ...
code_fim
hard
{ "lang": "rust", "repo": "Terkwood/toppa_drill", "path": "/src/resources/ingame/game_world/planet.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let rack_id = x + 10; let power_level = rack_id * y; let power_level = power_level + SERIAL; let power_level = power_level * rack_id; let power_level = (power_level / 100) % 10; power_level - 5 }<|fim_prefix|>// repo: brucelevis/aoc2018 path: /src/bin/day11.rs use std::collections...
code_fim
hard
{ "lang": "rust", "repo": "brucelevis/aoc2018", "path": "/src/bin/day11.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 2..300 { for y in 0..(300-i) { for x in 0..(300-i) { let mut p = powers.get(&(x, y, i-1)).unwrap() + grid[y+i-1][x+i-1]; for j in 0..(i-1) { p += grid[y+j][x+i-1]; p += grid[y+i-1][x+j]; ...
code_fim
hard
{ "lang": "rust", "repo": "brucelevis/aoc2018", "path": "/src/bin/day11.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brucelevis/aoc2018 path: /src/bin/day11.rs use std::collections::HashMap; const SERIAL: i32 = 2694; fn main() { let mut grid = vec![vec![0;300];300]; for y in 0..300 { for x in 0..300 { grid[y][x] = power_level(x as i32, y as i32); } } let mut best...
code_fim
hard
{ "lang": "rust", "repo": "brucelevis/aoc2018", "path": "/src/bin/day11.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JackLiar/rust-dpdk path: /rte/src/ether.rs use std::error; use std::fmt; use std::mem; use std::ops::{Deref, DerefMut}; use std::ptr; use std::result; use std::str; use anyhow::Result; use rand::{thread_rng, Rng}; use ffi; use mbuf; use utils::AsRaw; pub use ffi::{ RTE_ETHER_ADDR_FMT_SIZ...
code_fim
hard
{ "lang": "rust", "repo": "JackLiar/rust-dpdk", "path": "/rte/src/ether.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use super::*; #[test] fn test_macaddr() { let addr = EtherAddr::new(0x18, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f); assert_eq!(addr.octets(), &[0x18, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f]); assert_eq!(addr.to_string(), "18:2b:3c:4d:5e:6f"); assert_eq!(addr, EtherAddr::from([0x1...
code_fim
hard
{ "lang": "rust", "repo": "JackLiar/rust-dpdk", "path": "/rte/src/ether.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> EtherAddr(addr) } /// Check if an Ethernet address is filled with zeros. #[inline] pub fn is_zero(&self) -> bool { self.0 == Self::zeroed().0 } /// Check if an Ethernet address is a unicast address. #[inline] pub fn is_unicast(&self) -> bool { (sel...
code_fim
hard
{ "lang": "rust", "repo": "JackLiar/rust-dpdk", "path": "/rte/src/ether.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>::new(((self.bits >> 5) & 0x01) != 0) } #[doc = "Bits 8:9 - N/A"] #[inline(always)] pub fn lead(&self) -> LEAD_R { LEAD_R::new(((self.bits >> 8) & 0x03) as u8) } #[doc = "Bits 10:11 - N/A"] #[inline(always)] pub fn lag(&self) -> LAG_R { LAG_R::new(((self.bit...
code_fim
hard
{ "lang": "rust", "repo": "mvertescher/psoc6-pac", "path": "/src/ble/rcb/ctrl.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvertescher/psoc6-pac path: /src/ble/rcb/ctrl.rs #[doc = "Reader of register CTRL"] pub type R = crate::R<u32, super::CTRL>; #[doc = "Writer for register CTRL"] pub type W = crate::W<u32, super::CTRL>; #[doc = "Register CTRL `reset()`'s with value 0x00f8_0000"] impl crate::ResetValue for super::...
code_fim
hard
{ "lang": "rust", "repo": "mvertescher/psoc6-pac", "path": "/src/ble/rcb/ctrl.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lachlansneff/forge path: /src/cli.rs use std::env; use cargo::Subcommand; pub struct Args { all: Vec<String>, subcommand: Option<Subcommand> } impl Args { pub fn all(&self) -> &[String] { &self.all } <|fim_suffix|> pub fn version(&self) -> bool { ...
code_fim
hard
{ "lang": "rust", "repo": "lachlansneff/forge", "path": "/src/cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn subcommand(&self) -> Option<Subcommand> { self.subcommand } pub fn verbose(&self) -> bool { self.all .iter() .any(|a| a == "--verbose" || a == "-v" || a == "-vv") } pub fn version(&self) -> bool { self.all ...
code_fim
medium
{ "lang": "rust", "repo": "lachlansneff/forge", "path": "/src/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut rng = SmallRng::from_entropy(); bench.iter(|| { let v = rng.gen::<u32>(); for _ in 0..1000 { black_box(oct32::decode(black_box(v))); } }); } //---- benchmark_group!( benches, unsigned32_encode_1000_values, unsigned32_decode_1000_values,...
code_fim
hard
{ "lang": "rust", "repo": "cessen/psychopath", "path": "/sub_crates/compact/benches/bench.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cessen/psychopath path: /sub_crates/compact/benches/bench.rs use bencher::{benchmark_group, benchmark_main, black_box, Bencher}; use compact::{ fluv::fluv32, shared_exp::{signed48, unsigned32, unsigned40}, unit_vec::oct32, }; use rand::{rngs::SmallRng, FromEntropy, Rng}; //---- fn ...
code_fim
hard
{ "lang": "rust", "repo": "cessen/psychopath", "path": "/sub_crates/compact/benches/bench.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>//---- benchmark_group!( benches, unsigned32_encode_1000_values, unsigned32_decode_1000_values, unsigned40_encode_1000_values, unsigned40_decode_1000_values, signed48_encode_1000_values, signed48_decode_1000_values, fluv32_encode_1000_values, fluv32_decode_1000_values,...
code_fim
hard
{ "lang": "rust", "repo": "cessen/psychopath", "path": "/sub_crates/compact/benches/bench.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yoshuawuyts/fd-lock path: /src/read_guard.rs use std::ops; use crate::sys; /// RAII structure used to release the shared read access of a lock when /// dropped. /// /// This structure is created by the [`read`] and [`try_read`] methods on /// [`RwLock`]. /// /// [`read`]: crate::RwLock::read /...
code_fim
medium
{ "lang": "rust", "repo": "yoshuawuyts/fd-lock", "path": "/src/read_guard.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn deref(&self) -> &Self::Target { self.guard.deref() } } /// Release the lock. impl<T: sys::AsOpenFile> Drop for RwLockReadGuard<'_, T> { #[inline] fn drop(&mut self) {} }<|fim_prefix|>// repo: yoshuawuyts/fd-lock path: /src/read_guard.rs use std::ops; use crate::...
code_fim
medium
{ "lang": "rust", "repo": "yoshuawuyts/fd-lock", "path": "/src/read_guard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>isible_tiles = field_of_view_set(*pos, fov.radius, map);// (4) fov.is_dirty = false;// (5) } ); }<|fim_prefix|>// repo: chyyuu/HandsOnRust path: /Loot/loot_tables/src/systems/fov.rs use crate::prelude::*; #[system] #[read_component(Point)] #[write_component(FieldOfView)] pub fn f...
code_fim
hard
{ "lang": "rust", "repo": "chyyuu/HandsOnRust", "path": "/Loot/loot_tables/src/systems/fov.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chyyuu/HandsOnRust path: /Loot/loot_tables/src/systems/fov.rs use crate::prelude::*; #[system] #[read_component(Point)] #[write_component(FieldOfView)] pub fn fov( ecs: &mut SubW<|fim_suffix|>isible_tiles = field_of_view_set(*pos, fov.radius, map);// (4) fov.is_dirty = false;// ...
code_fim
hard
{ "lang": "rust", "repo": "chyyuu/HandsOnRust", "path": "/Loot/loot_tables/src/systems/fov.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> c.bench_function("prove/checkpoints", |b| { b.iter(|| { proof_of_time.create( black_box(seed), black_box(key), black_box(slot_number), black_box(injected_block_hash), ); }) }); let proof = ...
code_fim
hard
{ "lang": "rust", "repo": "subspace/subspace", "path": "/crates/subspace-proof-of-time/benches/pot.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: subspace/subspace path: /crates/subspace-proof-of-time/benches/pot.rs use core::num::{NonZeroU32, NonZeroU8}; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use rand::{thread_rng, Rng}; use subspace_core_primitives::{BlockHash, PotKey, PotSeed}; use subspace_proof_of_tim...
code_fim
medium
{ "lang": "rust", "repo": "subspace/subspace", "path": "/crates/subspace-proof-of-time/benches/pot.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ExternalReality/cider-rust path: /teamcity_apis/src/models/issue.rs /* * TeamCity REST API * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 2018.1 * * Generated by: https://openapi-gene...
code_fim
hard
{ "lang": "rust", "repo": "ExternalReality/cider-rust", "path": "/teamcity_apis/src/models/issue.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Issue { pub fn new() -> Issue { Issue { url: None, id: None, } } }<|fim_prefix|>// repo: ExternalReality/cider-rust path: /teamcity_apis/src/models/issue.rs /* * TeamCity REST API * * No description provided (generated by Openapi Generator https://g...
code_fim
hard
{ "lang": "rust", "repo": "ExternalReality/cider-rust", "path": "/teamcity_apis/src/models/issue.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `FC0_SRC` writer - "] pub struct FC0_SRC_W<'a> { w: &'a mut W, } impl<'a> FC0_SRC_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: FC0_SRC_A) -> &'a mut W { unsafe { self.bits(variant.into()) } ...
code_fim
hard
{ "lang": "rust", "repo": "mgottschlag/rp2040-pac", "path": "/src/clocks/fc0_src.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mgottschlag/rp2040-pac path: /src/clocks/fc0_src.rs #[doc = "Register `FC0_SRC` reader"] pub struct R(crate::R<FC0_SRC_SPEC>); impl core::ops::Deref for R { type Target = crate::R<FC0_SRC_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<cr...
code_fim
hard
{ "lang": "rust", "repo": "mgottschlag/rp2040-pac", "path": "/src/clocks/fc0_src.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leogtzr/the_rust_programming_language_code_snippets path: /error1/src/main.rs use std::fs::File; fn main() { // panic!("crash and burn"); //let v = vec![1, 2, 3, 4, 5]; //v[99]; <|fim_suffix|> let f = match f { Ok(file) => file, Err(err) => { ...
code_fim
easy
{ "lang": "rust", "repo": "leogtzr/the_rust_programming_language_code_snippets", "path": "/error1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let f = match f { Ok(file) => file, Err(err) => { panic!("There was a problem opening the file: {:?}", err) }, }; }<|fim_prefix|>// repo: leogtzr/the_rust_programming_language_code_snippets path: /error1/src/main.rs use std::fs::File; fn main() { // ...
code_fim
easy
{ "lang": "rust", "repo": "leogtzr/the_rust_programming_language_code_snippets", "path": "/error1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sink = a.block_on(fut).unwrap(); let buf = sink.into_inner().into_inner().unwrap().into_inner(); let s = String::from_utf8(buf).unwrap(); assert_eq!(s, "Content-Length: 15\r\n\r\n{\"key\":\"value\"}"); } }<|fim_prefix|>// repo: Xanewok/lsp-client path: /src/lib.r...
code_fim
hard
{ "lang": "rust", "repo": "Xanewok/lsp-client", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xanewok/lsp-client path: /src/lib.rs pub use crate::proto::{LspDecoder, LspEncoder}; pub mod proto; #[derive(Debug)] pub enum Error { Io(std::io::Error), Serde(serde_json::Error), Header(crate::proto::HeaderError), } impl From<std::io::Error> for Error { fn from(io: std::io::E...
code_fim
hard
{ "lang": "rust", "repo": "Xanewok/lsp-client", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let obj = json!({ "key": "value" }); let mut a = Runtime::new().unwrap(); let fut = writer.send(obj); let sink = a.block_on(fut).unwrap(); let buf = sink.into_inner().into_inner().unwrap().into_inner(); let s = String::from_utf8(buf).u...
code_fim
hard
{ "lang": "rust", "repo": "Xanewok/lsp-client", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let message_header = ExternalInboundMessageHeader { dst: self.dest.clone(), ..Default::default() }; let mut msg = Message::with_ext_in_header(message_header); if let Some(body) = self.body { msg.set_body(body); } msg ...
code_fim
hard
{ "lang": "rust", "repo": "howl111/ton-eth-bridge-relay", "path": "/relay-ton/src/transport/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: howl111/ton-eth-bridge-relay path: /relay-ton/src/transport/utils.rs use ton_abi::Function; use ton_block::{ CommonMsgInfo, Deserializable, ExternalInboundMessageHeader, Message, Transaction, }; use super::errors::*; use crate::models::*; use crate::prelude::*; pub struct PendingMessage<T>...
code_fim
hard
{ "lang": "rust", "repo": "howl111/ton-eth-bridge-relay", "path": "/relay-ton/src/transport/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stefan-k/kraxn path: /server/src/errors.rs // Copyright 2018 Stefan Kroboth // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may ...
code_fim
medium
{ "lang": "rust", "repo": "stefan-k/kraxn", "path": "/server/src/errors.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use std; use diesel; error_chain!{ foreign_links { IoError(std::io::Error); AddrParseError(std::net::AddrParseError); VarError(std::env::VarError); ConnectionError(diesel::ConnectionError); DieselError(diesel::result::Error); TimeError(std::time::System...
code_fim
medium
{ "lang": "rust", "repo": "stefan-k/kraxn", "path": "/server/src/errors.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>error_chain!{ foreign_links { IoError(std::io::Error); AddrParseError(std::net::AddrParseError); VarError(std::env::VarError); ConnectionError(diesel::ConnectionError); DieselError(diesel::result::Error); TimeError(std::time::SystemTimeError); } }<|f...
code_fim
medium
{ "lang": "rust", "repo": "stefan-k/kraxn", "path": "/server/src/errors.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Enemy bullets bounce when they hit the end of the screen fn enemy_mov(&mut self, args: &UpdateArgs, width: f64, height: f64) { // make sure bullet doesnt leave the screen // check x position if self.pos.x < 0.0 || self.pos.x > width { self.vel.x *= -1.0; ...
code_fim
hard
{ "lang": "rust", "repo": "lhernandezcruz/hit_n_run", "path": "/src/weapons/bullet.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // create transform matrix let transform = c.transform .trans(self.pos.x, self.pos.y) .rot_rad(self.rotation) .trans(-SIDELENGTH / 2.0, -SIDELENGTH / 2.0); // Draw a box rotating around the middle of the screen. rectangle(color, square, ...
code_fim
hard
{ "lang": "rust", "repo": "lhernandezcruz/hit_n_run", "path": "/src/weapons/bullet.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lhernandezcruz/hit_n_run path: /src/weapons/bullet.rs extern crate piston; extern crate graphics; extern crate glutin_window; extern crate opengl_graphics; use opengl_graphics::GlGraphics; use piston::input::*; use std::f64; use vector::Vector; use constants::bullet_constants::*; use constants:...
code_fim
hard
{ "lang": "rust", "repo": "lhernandezcruz/hit_n_run", "path": "/src/weapons/bullet.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tristramg/rust_proj_mystery path: /src/main.rs use serde::Deserialize; #[derive(Deserialize, Debug)] struct Point { lon: f64, category: String, } <|fim_suffix|> let file = std::fs::File::open("POINTXXXXX.TMI").expect("The file is missing…"); let mut rdr = csv::ReaderBuilder::ne...
code_fim
medium
{ "lang": "rust", "repo": "Tristramg/rust_proj_mystery", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let file = std::fs::File::open("POINTXXXXX.TMI").expect("The file is missing…"); let mut rdr = csv::ReaderBuilder::new() .delimiter(b';') .trim(csv::Trim::All) .from_reader(file); let from = "EPSG:28992"; let to = "EPSG:4326"; let amersfoort_to_wgs84 = proj::Pr...
code_fim
medium
{ "lang": "rust", "repo": "Tristramg/rust_proj_mystery", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn reset_staging_timestamps( connectors: &Connectors, group_type: GroupType, ) -> Result<bool, Error> { let mut connection = connectors.local.pool.get()?; diesel::update(dsl::group_metadata.filter(dsl::group_type.eq(group_type))) .set(&MetadataTimestamps { staging_f...
code_fim
hard
{ "lang": "rust", "repo": "Creatiwity/siren", "path": "/src/models/group_metadata/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Creatiwity/siren path: /src/models/group_metadata/mod.rs pub mod common; pub mod error; use super::schema::group_metadata::dsl; use crate::connectors::Connectors; use chrono::{DateTime, Utc}; use common::{GroupType, Metadata, MetadataTimestamps}; use diesel::prelude::*; use error::Error; pub f...
code_fim
hard
{ "lang": "rust", "repo": "Creatiwity/siren", "path": "/src/models/group_metadata/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn set_last_insee_synced_timestamp( connectors: &Connectors, group_type: GroupType, timestamp: DateTime<Utc>, ) -> Result<bool, Error> { let mut connection = connectors.local.pool.get()?; diesel::update(dsl::group_metadata.filter(dsl::group_type.eq(group_type))) .set(dsl::l...
code_fim
hard
{ "lang": "rust", "repo": "Creatiwity/siren", "path": "/src/models/group_metadata/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ParagonPawns/term-inquiry path: /src/list.rs pub struct List<T> { message: String, selection_list: Vec<(String, T)>, term_data: TermData, } impl<T> List<T> { pub fn new(message: String) -> Self { Self { message, selection_list: Vec::new(), ...
code_fim
hard
{ "lang": "rust", "repo": "ParagonPawns/term-inquiry", "path": "/src/list.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match key { Keys::Up => if selected_index > 0 { selected_index -= 1 }, Keys::Down => if selected_index < self.selection_list.len() - 1 { selected_index += 1; }, Keys::Enter => { let (name, v...
code_fim
hard
{ "lang": "rust", "repo": "ParagonPawns/term-inquiry", "path": "/src/list.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { if self.start < self.end { let frame = self.start.clone(); self.start += 1; Some(frame) } else { None } } } impl<S: PageSize> fmt::Debug for PhysFrameRange<S> { fn fmt(&self, f: ...
code_fim
hard
{ "lang": "rust", "repo": "kamirr/x86_64", "path": "/src/structures/paging/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kamirr/x86_64 path: /src/structures/paging/mod.rs //! Abstractions for page tables and other paging related structures. //! //! Page tables translate virtual memory “pages” to physical memory “frames”. pub use self::frame_alloc::*; pub use self::page_table::*; #[cfg(target_arch = "x86_64")] pub...
code_fim
hard
{ "lang": "rust", "repo": "kamirr/x86_64", "path": "/src/structures/paging/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn calculate_probability(message: &str) -> f64 { message .to_lowercase() .chars() .fold(0.0, |acc, x| acc + LETTER_FREQUENCY.get(&x).unwrap_or(&0.0)) } fn decode_single_message_with_probability(byte: u8, s: &str) -> Option<MessageBundle> { match one_char_xor(byte, s) { ...
code_fim
hard
{ "lang": "rust", "repo": "chibby0ne/cryptopals", "path": "/set1/src/challenge3/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chibby0ne/cryptopals path: /set1/src/challenge3/mod.rs /* The hex encoded string: 1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736 ... has been XOR'd against a single character. Find the key, decrypt the message. You can do this by hand. But don't: write code to do it for ...
code_fim
hard
{ "lang": "rust", "repo": "chibby0ne/cryptopals", "path": "/set1/src/challenge3/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let data_len = ((data.len() + 1 as usize) as u32).to_be_bytes().to_vec(); let mut i = 0; for b in data_len.iter() { data.insert(i, *b); i += 1; } data.insert(i, padding as u8); } pub fn make_session_id( &mut self, ...
code_fim
hard
{ "lang": "rust", "repo": "diogoaj/RustSSH-Client", "path": "/src/session.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diogoaj/RustSSH-Client path: /src/session.rs use std::{cell::Cell, net::{SocketAddr, TcpStream, IpAddr}}; use std::io::{BufReader, BufWriter, Result, prelude::*}; use ring::digest; use rand::rngs::OsRng; use crate::{constants, crypto}; pub struct Session { reader: Cell<BufReader<TcpStream>...
code_fim
hard
{ "lang": "rust", "repo": "diogoaj/RustSSH-Client", "path": "/src/session.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut packet = Vec::new(); packet.push(received_data); return packet; } else if result.is_ok() && self.encrypted == true { self.server_sequence_number += 1; let mut received_data = buf[..result.unwrap()].to_vec(); let mut ...
code_fim
hard
{ "lang": "rust", "repo": "diogoaj/RustSSH-Client", "path": "/src/session.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EmbarkStudios/rust-gpu path: /tests/ui/lang/f32/signum.rs // Test that `signum` works. // build-pass <|fim_suffix|>#[spirv(fragment)] pub fn main(i: f32, o: &mut f32) { *o = i.signum(); }<|fim_middle|>use spirv_std::num_traits::Float; use spirv_std::spirv;
code_fim
easy
{ "lang": "rust", "repo": "EmbarkStudios/rust-gpu", "path": "/tests/ui/lang/f32/signum.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[spirv(fragment)] pub fn main(i: f32, o: &mut f32) { *o = i.signum(); }<|fim_prefix|>// repo: EmbarkStudios/rust-gpu path: /tests/ui/lang/f32/signum.rs // Test that `signum` works. // build-pass <|fim_middle|>use spirv_std::num_traits::Float; use spirv_std::spirv;
code_fim
easy
{ "lang": "rust", "repo": "EmbarkStudios/rust-gpu", "path": "/tests/ui/lang/f32/signum.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn color_buffer(&mut self) -> &mut [Self::Color] { &mut self.color } fn depth_buffer(&mut self) -> &mut [f32] { &mut self.depth } }<|fim_prefix|>// repo: Epsylon42/termishade path: /termishade/src/color_depth_renderer.rs use crate::base_renderer::BaseRenderer; pub struct...
code_fim
medium
{ "lang": "rust", "repo": "Epsylon42/termishade", "path": "/termishade/src/color_depth_renderer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Epsylon42/termishade path: /termishade/src/color_depth_renderer.rs use crate::base_renderer::BaseRenderer; pub struct ColorDepthRenderer { width: usize, height: usize, color: Vec<na::Vector4<f32>>, depth: Vec<f32>, } impl ColorDepthRenderer { pub fn new(width: usize, height...
code_fim
medium
{ "lang": "rust", "repo": "Epsylon42/termishade", "path": "/termishade/src/color_depth_renderer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn size(&self) -> [usize; 2] { [self.width, self.height] } fn color_buffer(&mut self) -> &mut [Self::Color] { &mut self.color } fn depth_buffer(&mut self) -> &mut [f32] { &mut self.depth } }<|fim_prefix|>// repo: Epsylon42/termishade path: /termishade/src...
code_fim
medium
{ "lang": "rust", "repo": "Epsylon42/termishade", "path": "/termishade/src/color_depth_renderer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kylewlacy/glitter path: /src/context/program_context.rs &mut program)); Ok(program) } } /// Create and link the program object with the provided shaders, /// or panic. /// /// # Panics /// This function will panic if there was an error linking ///...
code_fim
hard
{ "lang": "rust", "repo": "kylewlacy/glitter", "path": "/src/context/program_context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if success { Ok(()) } else { let msg = match self.get_program_info_log(&program) { Some(s) => { s }, None => { String::from("[Unknown program error]") } }; Err(GLError::Message(msg)) } } ...
code_fim
hard
{ "lang": "rust", "repo": "kylewlacy/glitter", "path": "/src/context/program_context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kylewlacy/glitter path: /src/context/program_context.rs there was an error linking /// the program object or if an OpenGL error was generated with debug /// assertions enabled. pub fn unwrap(self) -> Program { self.try_unwrap().unwrap() } } /// The extension trait that ...
code_fim
hard
{ "lang": "rust", "repo": "kylewlacy/glitter", "path": "/src/context/program_context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_key(&self) -> &[u8] { &self.key } // bytes value = 2; pub fn clear_value(&mut self) { self.value.clear(); } // Param is passed by value, moved pub fn set_value(&mut self, v: ::std::vec::Vec<u8>) { self.value = v; } // Mutable point...
code_fim
hard
{ "lang": "rust", "repo": "Xavier1994/kvproto", "path": "/src/raft_cmdpb.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> static mut instance: ::protobuf::lazy::Lazy<RegionLeaderRequest> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const RegionLeaderRequest, }; unsafe { instance.get(RegionLeaderRequest::new) } } } impl ::prot...
code_fim
hard
{ "lang": "rust", "repo": "Xavier1994/kvproto", "path": "/src/raft_cmdpb.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xavier1994/kvproto path: /src/raft_cmdpb.rs self.unknown_fields.clear(); } } impl ::std::fmt::Debug for DeleteRequest { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufVal...
code_fim
hard
{ "lang": "rust", "repo": "Xavier1994/kvproto", "path": "/src/raft_cmdpb.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }