text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> #[inline]
pub fn set_sp(&mut self, val: u16) {
self.sp = val;
}
#[inline]
pub fn get_pc(&self) -> u16 {
self.pc
}
#[inline]
pub fn set_pc(&mut self, val: u16) {
self.pc = val;
}
flag_funcs!(get_f, set_f
; flag_c, set_flag_c, 0x01
... | code_fim | hard | {
"lang": "rust",
"repo": "moonheart08/emutk",
"path": "/emutk-z80/src/cpu/regfile.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A GPOS [SequenceContext](super::layout::SequenceContext)
pub type PositionSequenceContext<'a> = super::layout::SequenceContext<'a>;
/// A GPOS [ChainedSequenceContext](super::layout::ChainedSequenceContext)
pub type PositionChainContext<'a> = super::layout::ChainedSequenceContext<'a>;<|fim_prefix|>//... | code_fim | medium | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/read_fonts/v0_10/crate/src/tables/gpos.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/read_fonts/v0_10/crate/src/tables/gpos.rs
//! the [GPOS] table
//!
//! [GPOS]: https://docs.microsoft.com/en-us/typography/opentype/spec/gpos
#[path = "./value_record.rs"]
mod value_record;
use crate::array::ComputedArray;
<|fim_suffix|>/// A GPOS [Se... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/read_fonts/v0_10/crate/src/tables/gpos.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sorrowed/Advent-2019 path: /src/day8/mod.rs
112222220222222222222202212222212222010221222222222222222222022222202022212222220222012222202222022222222212021222222222222222020222222222222122222222111202222222222222222222222202222222202220222222222222222222202222222220202222200222112222222222122222... | code_fim | hard | {
"lang": "rust",
"repo": "sorrowed/Advent-2019",
"path": "/src/day8/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>020202222212020212221010212021200002212222121022122222011201211222221220220201222222202202002221222211122222212122011221202221212220210220101222212222020002222202020212220101222122022212222222122022202202200211220222222202220220222212122211220220122202222222222022201222222120012221201220121212222222221112... | code_fim | hard | {
"lang": "rust",
"repo": "sorrowed/Advent-2019",
"path": "/src/day8/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Layer {
pub fn pixel(&self, x: usize, y: usize) -> u8 {
self.pixels[y * self.width + x]
}
pub fn count_pixel_color(&self, color: u8) -> usize {
self.pixels.iter().filter(|&&p| p == color).count()
}
}
struct Bitmap {
pub width: usize,
pub height: usize,
pub... | code_fim | medium | {
"lang": "rust",
"repo": "sorrowed/Advent-2019",
"path": "/src/day8/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/detective/src/error.rs
isplay
// as implemented by std::Error to generate a message in that case.
pub fn message(&self) -> Option<&str> {
self.meta.message()
}
pub fn meta(&self) -> &smithy_types::Error {
&self.meta
}
pub f... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/detective/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[non_exhaustive]
#[derive(std::fmt::Debug)]
pub struct DeleteMembersError {
pub kind: DeleteMembersErrorKind,
pub(crate) meta: smithy_types::Error,
}
#[non_exhaustive]
#[derive(std::fmt::Debug)]
pub enum DeleteMembersErrorKind {
ConflictException(crate::error::ConflictException),
Internal... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/detective/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Self::Stats(error) => write!(f, "Ndarray Stats Error: {}", error),
}
}
}
impl From<MinMaxError> for BayesError {
fn from(error: MinMaxError) -> Self {
Self::Stats(error)
}
}
impl std::error::Error for BayesError {}<|fim_prefix|>// repo: Vasant... | code_fim | medium | {
"lang": "rust",
"repo": "VasanthakumarV/linfa",
"path": "/linfa-bayes/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VasanthakumarV/linfa path: /linfa-bayes/src/error.rs
use std::fmt;
use ndarray_stats::errors::MinMaxError;
pub type Result<T> = std::result::Result<T, BayesError>;
#[derive(Debug)]
pub enum BayesError {
/// Error when performing Max operation on data
Stats(MinMaxError),
}
<|fim_suffi... | code_fim | medium | {
"lang": "rust",
"repo": "VasanthakumarV/linfa",
"path": "/linfa-bayes/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32g0/src/stm32g041/dma/isr.rs
#[doc = "Reader of register ISR"]
pub type R = crate::R<u32, super::ISR>;
#[doc = "Reader of field `GIF0`"]
pub type GIF0_R = crate::R<bool, bool>;
#[doc = "Reader of field `TCIF1`"]
pub type TCIF1_R = crate::R<bool, bool>;... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32g0/src/stm32g041/dma/isr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>) & 0x01) != 0)
}
#[doc = "Bit 18 - Channel half transfer flag"]
#[inline(always)]
pub fn htif18(&self) -> HTIF18_R {
HTIF18_R::new(((self.bits >> 18) & 0x01) != 0)
}
#[doc = "Bit 19 - Channel transfer error flag"]
#[inline(always)]
pub fn teif19(&self) -> TEIF19_R ... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32g0/src/stm32g041/dma/isr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn varint_decode_u64<R: Reader>(read: &mut R, endian: Endian) -> Result<u64, DecodeError> {
if let Some(bytes) = read.peek_read(9) {
let (discriminant, bytes) = bytes.split_at(1);
let (out, used) = match discriminant[0] {
byte @ 0..=SINGLE_BYTE_MAX => (byte as u64, 1),
... | code_fim | hard | {
"lang": "rust",
"repo": "mswdwk/bincode",
"path": "/src/varint/decode_unsigned.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (slice, expected) in errors {
let mut reader = crate::de::read::SliceReader::new(slice);
let found = varint_decode_u32(&mut reader, Endian::Little).unwrap_err();
assert_eq!(std::format!("{:?}", expected), std::format!("{:?}", found));
}
}
#[test]
fn test_decode_u64() {... | code_fim | hard | {
"lang": "rust",
"repo": "mswdwk/bincode",
"path": "/src/varint/decode_unsigned.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mswdwk/bincode path: /src/varint/decode_unsigned.rs
=> u16::from_le_bytes(bytes) as u32,
})
}
U32_BYTE => {
let mut bytes = [0u8; 4];
read.read(&mut bytes)?;
Ok(match endian {
Endian::Big => u32::from_be_bytes(bytes... | code_fim | hard | {
"lang": "rust",
"repo": "mswdwk/bincode",
"path": "/src/varint/decode_unsigned.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for received in rx {
println!("[MAIN] Message received: {:?}", received);
}
println!("[MAIN] Channel terminated");
}<|fim_prefix|>// repo: huwb/learningrust path: /src/threads_msg_passing.rs
use std::thread;
use std::sync::mpsc;
use std::time;
pub fn run() {
let (tx, rx) = mpsc:... | code_fim | hard | {
"lang": "rust",
"repo": "huwb/learningrust",
"path": "/src/threads_msg_passing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: huwb/learningrust path: /src/threads_msg_passing.rs
use std::thread;
use std::sync::mpsc;
use std::time;
pub fn run() {
let (tx, rx) = mpsc::channel();
<|fim_suffix|> for received in rx {
println!("[MAIN] Message received: {:?}", received);
}
println!("[MAIN] Channel te... | code_fim | hard | {
"lang": "rust",
"repo": "huwb/learningrust",
"path": "/src/threads_msg_passing.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let exports = lua.create_table()?;
exports.set("hello", lua.create_function(hello)?)?;
Ok(exports)
}<|fim_prefix|>// repo: Jackzmc/rs-lua-dll-example path: /src/lib.rs
use mlua::prelude::*;
fn hello(_: &Lua, name: String) -> LuaResult<()> {
println!("hello, {}!", name);
Ok(())
}
<|f... | code_fim | medium | {
"lang": "rust",
"repo": "Jackzmc/rs-lua-dll-example",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jackzmc/rs-lua-dll-example path: /src/lib.rs
use mlua::prelude::*;
fn hello(_: &Lua, name: String) -> LuaResult<()> {
<|fim_suffix|>#[mlua::lua_module]
fn my_module(lua: &Lua) -> LuaResult<LuaTable> {
let exports = lua.create_table()?;
exports.set("hello", lua.create_function(hello)?)?;... | code_fim | easy | {
"lang": "rust",
"repo": "Jackzmc/rs-lua-dll-example",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>: String,
pub send_at: u64,
pub expired_at: u64
}<|fim_prefix|>// repo: Pabsysop/PAB_Dfinity path: /src/boards/workshop/src/message.rs
use candid::CandidType;
use serde::{Serialize, Deseriali<|fim_middle|>ze};
#[derive(Debug, Deserialize, Serialize, CandidType)]
pub struct Message {
pub user... | code_fim | medium | {
"lang": "rust",
"repo": "Pabsysop/PAB_Dfinity",
"path": "/src/boards/workshop/src/message.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pabsysop/PAB_Dfinity path: /src/boards/workshop/src/message.rs
use candid::CandidType;
use serde::{Serialize, Deseriali<|fim_suffix|>: String,
pub send_at: u64,
pub expired_at: u64
}<|fim_middle|>ze};
#[derive(Debug, Deserialize, Serialize, CandidType)]
pub struct Message {
pub user... | code_fim | medium | {
"lang": "rust",
"repo": "Pabsysop/PAB_Dfinity",
"path": "/src/boards/workshop/src/message.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jon-zu/aoc19 path: /src/days/day01.rs
#![allow(dead_code)]
use crate::*;
fn load_masses() -> AocResult<Vec<u64>> {
let v: ParseLineVec<u64> = parse_file(FileType::Input, 1, 1)?;
Ok(v.0)
}
fn calc_fuel(mass: u64) -> i64 {
let f = ((mass as f64) / 3.).floor() as i64;
f - 2
}
fn... | code_fim | hard | {
"lang": "rust",
"repo": "jon-zu/aoc19",
"path": "/src/days/day01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s: u64 = m.iter().map(|&m| calc_total_fuel(m)).sum();
assert_eq!(s, 4_943_969);
Ok(())
}
}<|fim_prefix|>// repo: jon-zu/aoc19 path: /src/days/day01.rs
#![allow(dead_code)]
use crate::*;
fn load_masses() -> AocResult<Vec<u64>> {
let v: ParseLineVec<u64> = parse_file(... | code_fim | hard | {
"lang": "rust",
"repo": "jon-zu/aoc19",
"path": "/src/days/day01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nikhilkalige/adventofcode path: /src/aoc2019/day08/src/main.rs
use std::{
collections::HashMap,
fmt,
io::{self},
};
fn main() -> io::Result<()> {
let input = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/input/input.txt"));
let image = SpaceImage::new(&input, 25, 6);
... | code_fim | hard | {
"lang": "rust",
"repo": "nikhilkalige/adventofcode",
"path": "/src/aoc2019/day08/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn flatten(&self) -> Vec<Color> {
let num_pixels = self.layers[0].len();
(0..num_pixels)
.into_iter()
.map(|index| {
self.layers
.iter()
.map(|layer| layer[index])
.skip_while(|&color| c... | code_fim | hard | {
"lang": "rust",
"repo": "nikhilkalige/adventofcode",
"path": "/src/aoc2019/day08/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/Smith path: /src/data/select/mod.rs
use super::{CharIter, Editable, LineIter, Modifiable, Movement, Named, Saveable, Undoable};
use delegate_attr::delegate;
use std::io::Result;
pub type Selection = (usize, usize);
pub trait Selectable {
fn sel(&self) -> &Option<Selection>;
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/Smith",
"path": "/src/data/select/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn delete_forward(&mut self) -> Option<char>;
fn pos(&self) -> usize;
fn line(&self) -> usize;
fn col(&self) -> usize;
fn line_count(&self) -> usize;
fn len(&self) -> usize;
fn iter(&self) -> CharIter;
fn lines(&self) -> LineIter;
fn iter_line(&self, line: usize) -> Cha... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/Smith",
"path": "/src/data/select/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[delegate(self.content)]
impl<T> Undoable for Select<T>
where
T: Editable + Undoable,
{
fn undo(&mut self) -> ();
fn redo(&mut self) -> ();
fn history_len(&self) -> usize;
}
#[delegate(self.content)]
impl<T> Modifiable for Select<T>
where
T: Editable + Modifiable,
{
fn was_modifi... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/Smith",
"path": "/src/data/select/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsoutlined/action/icon_wifi_protected_setup.rs
pub struct IconWifiProtectedSetup {
props: crate::Props,
}
impl yew::Component for IconWifiProtectedSetup {
type Properties = crate::Props;
type Message = ();
fn create(props: Sel... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsoutlined/action/icon_wifi_protected_setup.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JoelCourtney/dnd-notes-gui path: /src/view/mod.rs
use rustbox::{Color, RustBox, Style, OutputMode};
pub struct View {
rustbox: RustBox
}
impl View {
pub fn new() -> Self {
let mut rustbox = match RustBox::init(Default::default()) {
Result::Ok(v) => v,
Re... | code_fim | hard | {
"lang": "rust",
"repo": "JoelCourtney/dnd-notes-gui",
"path": "/src/view/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn show(&self, text: Vec<Vec<Text>>) {
self.rustbox.clear();
let mut x: usize = 0;
let mut y: usize = 0;
let mut style = rustbox::RB_NORMAL;
let mut fg = Color::White;
let mut bg = Color::Black;
for r in &text {
for t in r {
... | code_fim | hard | {
"lang": "rust",
"repo": "JoelCourtney/dnd-notes-gui",
"path": "/src/view/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> true
}
fn score_graph(&self, graph: &'a Graph<'a, T, U, D>) -> ClusterScores<'a, T, U, D> {
graph
.ordered_clusters()
.iter()
.map(|&c| (c, graph.unchecked_vertex_degree(c) as f64))
.collect()
}
}
pub struct ParentCardinality<'a... | code_fim | hard | {
"lang": "rust",
"repo": "URI-ABD/clam",
"path": "/abd-clam/src/chaoda/graph_scorers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: URI-ABD/clam path: /abd-clam/src/chaoda/graph_scorers.rs
use std::collections::HashMap;
use std::hash::Hash;
use crate::core::cluster::Cluster;
use crate::core::dataset::Dataset;
use crate::core::graph::Graph;
use crate::core::number::Number;
use crate::utils::helpers;
pub type ClusterScores<'... | code_fim | hard | {
"lang": "rust",
"repo": "URI-ABD/clam",
"path": "/abd-clam/src/chaoda/graph_scorers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct GraphNeighborhood {
eccentricity_fraction: f64,
}
impl GraphNeighborhood {
pub fn new(eccentricity_fraction: f64) -> Self {
Self { eccentricity_fraction }
}
fn num_steps<'a, T: Number, U: Number, D: Dataset<T, U>>(
&self,
graph: &'a Graph<'a, T, U, D>,
... | code_fim | hard | {
"lang": "rust",
"repo": "URI-ABD/clam",
"path": "/abd-clam/src/chaoda/graph_scorers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> macro_rules! def_block {
($($name: ident),*)=> {
$(
let $name = self.create_block();
/* self.append_block_param($name,types::I64); // op
self.append_block_param($name,types::I64); // frame
... | code_fim | hard | {
"lang": "rust",
"repo": "RDambrosio016/starlight",
"path": "/crates/fusion/src/compiler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RDambrosio016/starlight path: /crates/fusion/src/compiler.rs
ue, property name, object. Sets the given
/// property of a given object to a given value, pushes value back onto the
/// stack.
///
///
/// `( a b c -- a[b]=c )`
OP_SET,
/// Takes 1 value from the stack an... | code_fim | hard | {
"lang": "rust",
"repo": "RDambrosio016/starlight",
"path": "/crates/fusion/src/compiler.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_number(&mut self, val: Value) -> Value {
let x = self.builder.ins().band_imm(val, NUMBER_TAG as i64);
self.builder.ins().icmp_imm(IntCC::NotEqual, x, 0)
}
pub fn as_double(&mut self, val: Value) -> Value {
let x = self
.builder
.ins()
... | code_fim | hard | {
"lang": "rust",
"repo": "RDambrosio016/starlight",
"path": "/crates/fusion/src/compiler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn parsing() {
assert_eq!("value 5 goes to bot 2".parse(), Ok(Instruction::ValueToBot(5, 2)));
assert_eq!("bot 2 gives low to bot 1 and high to bot 0".parse(), Ok(Instruction::BotToTarget(2, Target::Bot(1), Target::Bot(0))));
assert_eq!("bot 1 gives low to output 1 ... | code_fim | hard | {
"lang": "rust",
"repo": "zargony/advent-of-code-2016",
"path": "/src/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zargony/advent-of-code-2016 path: /src/day10.rs
#[macro_use]
extern crate nom;
use std::cmp;
use std::cell::RefCell;
use std::collections::HashMap;
use std::str::FromStr;
/// Target of a bot can be either another bot or an output box
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Target {
... | code_fim | hard | {
"lang": "rust",
"repo": "zargony/advent-of-code-2016",
"path": "/src/day10.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromStr for Factory {
type Err = nom::ErrorKind;
fn from_str(s: &str) -> Result<Factory, nom::ErrorKind> {
Instruction::parse(s).map(|instructions|
Factory::from(instructions)
)
}
}
impl<T: AsRef<[Instruction]>> From<T> for Factory {
fn from(instructions:... | code_fim | hard | {
"lang": "rust",
"repo": "zargony/advent-of-code-2016",
"path": "/src/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// This function losslessly optimizes jpegs.
// Based on the jpegtran.c example program in libjpeg.
unsafe fn optimize_jpeg(bytes: &[u8]) -> std::thread::Result<&mut [u8]> {
std::panic::catch_unwind(|| {
let mut info = JPEGOptimizer::new();
let mut err = create_error_handler();
info.srcinfo.... | code_fim | hard | {
"lang": "rust",
"repo": "parcel-bundler/parcel",
"path": "/packages/optimizers/image/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parcel-bundler/parcel path: /packages/optimizers/image/src/lib.rs
use mozjpeg_sys::*;
use napi::bindgen_prelude::*;
use napi::{Env, Error, JsBuffer, Result};
use napi_derive::napi;
use oxipng::{optimize_from_memory, Headers, Options};
use std::mem;
use std::ptr;
use std::slice;
#[napi]
pub fn o... | code_fim | hard | {
"lang": "rust",
"repo": "parcel-bundler/parcel",
"path": "/packages/optimizers/image/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arkadijs/opengl-rust path: /src/draw.rs
use std::cmp;
extern crate vecmath;
use self::vecmath::{
mat4_inv, mat4_transposed, row_mat4_mul, vec3_cross, vec3_dot, vec3_mul, vec3_scale, Matrix3,
Matrix3x2, Matrix4, Vector2, Vector3,
};
extern crate image as pimage;
use self::pimage::{Rgb, ... | code_fim | hard | {
"lang": "rust",
"repo": "arkadijs/opengl-rust",
"path": "/src/draw.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let viewport: Matrix4<f32> = make_viewport(w / 8, h / 8, w * 3 / 4, h * 3 / 4, u16::MAX as u32);
let projection: Matrix4<f32> = make_projection(camera, center);
let modelview: Matrix4<f32> = make_modelview(camera, center, [0., 1., 0.]);
let modelviewprojection = row_mat4_mul(projection, mo... | code_fim | hard | {
"lang": "rust",
"repo": "arkadijs/opengl-rust",
"path": "/src/draw.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wy2684/Practice path: /eagle/leetcode/palindromic.rs
fn is_palindrome(x:i32)->bool{
if x == 0 {
return true;
}
if x < 0 || (x % 10 == 0){
return false;
}
let mut ori = x;
let mut rev = 0;
while rev < ori {
rev = rev * 10 + ori % 10;
... | code_fim | medium | {
"lang": "rust",
"repo": "wy2684/Practice",
"path": "/eagle/leetcode/palindromic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", is_palindrome(0));
println!("{}", is_palindrome(10));
println!("{}", is_palindrome(121));
println!("{}", is_palindrome(1221));
println!("{}", is_palindrome(1231));
}<|fim_prefix|>// repo: wy2684/Practice path: /eagle/leetcode/palindromic.rs
fn is_palindrome(x:i32)->bool... | code_fim | medium | {
"lang": "rust",
"repo": "wy2684/Practice",
"path": "/eagle/leetcode/palindromic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(test)]
pub(crate) fn equivalent(&self, other: &Triangle) -> bool {
use std::collections::HashSet;
use std::iter::FromIterator;
// checks if two triangles are indexing the same three points, but not necessarily in the same order
let t0 =
HashSet::<... | code_fim | medium | {
"lang": "rust",
"repo": "Andreas-Edling/triangulator",
"path": "/src/triangle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// terser than derived Debug
impl core::fmt::Debug for Triangle {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "({} {} {})", self.index0, self.index1, self.index2)
}
}<|fim_prefix|>// repo: Andreas-Edling/triangulator path: /src/triangle.rs
use crate::typ... | code_fim | hard | {
"lang": "rust",
"repo": "Andreas-Edling/triangulator",
"path": "/src/triangle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Andreas-Edling/triangulator path: /src/triangle.rs
use crate::types::PointIdx;
#[derive(PartialEq, Eq, Clone)]
pub struct Triangle {
pub index0: PointIdx,
pub index1: PointIdx,
pub index2: PointIdx,
}
<|fim_suffix|> // checks if two triangles are indexing the same three poin... | code_fim | hard | {
"lang": "rust",
"repo": "Andreas-Edling/triangulator",
"path": "/src/triangle.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alesgenova/pitch-detection path: /src/float/mod.rs
//! Generic [Float] type which acts as a stand-in for `f32` or `f64`.
use rustfft::num_traits::float::FloatCore as NumFloatCore;
use rustfft::FftNum;
use std::fmt::{Debug, Display};
<|fim_suffix|>impl Float for f64 {}
impl Float for f32 {}<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "alesgenova/pitch-detection",
"path": "/src/float/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Float for f64 {}
impl Float for f32 {}<|fim_prefix|>// repo: alesgenova/pitch-detection path: /src/float/mod.rs
//! Generic [Float] type which acts as a stand-in for `f32` or `f64`.
use rustfft::num_traits::float::FloatCore as NumFloatCore;
use rustfft::FftNum;
use std::fmt::{Debug, Display};
<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "alesgenova/pitch-detection",
"path": "/src/float/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match statement {
Statement::LogicalDisjunction(ref lst, ref rst) => Some(RuleDeriveResult {
statements: vec![*lst.clone(), *rst.clone()],
whatdo: ApplyRuleWhatdo::AsNewBranches,
}),
_ => panic!("attempt to apply wrong rule to sta... | code_fim | hard | {
"lang": "rust",
"repo": "ndrsllwngr/logic-rs",
"path": "/src/validity/algorithm/rules.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rule_derive_result = truth_tree_method
.apply_rule(
Rule::NegationOfConjunction,
&Statement::LogicalNegation(Box::new(Statement::LogicalConjunction(
Box::new(Statement::Simple(SimpleStatementLetter(
'B',
... | code_fim | hard | {
"lang": "rust",
"repo": "ndrsllwngr/logic-rs",
"path": "/src/validity/algorithm/rules.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ndrsllwngr/logic-rs path: /src/validity/algorithm/rules.rs
nt.clone()))
}
Statement::LogicalConjunction(ref lst, ref rst) => Formula::Conjunction(
Box::new(self.instantiation_replace_in_formula(
&Formula::Statement(lst.c... | code_fim | hard | {
"lang": "rust",
"repo": "ndrsllwngr/logic-rs",
"path": "/src/validity/algorithm/rules.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> n * (n + 1) / 2
}
fn sumd(mut n: u128) -> u128 {
let mut r = 0;
while n > 0 {
r += n % 10;
n /= 10;
}
r
}
fn muld(mut n: u128) -> u128 {
if n == 0 {
return 0;
}
let mut r = 1;
while n > 0 {
r *= n % 10;
n /= 10;
}
r
}<|... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/codegolf/the-add-multiply-add-sequence.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let tab = [3, 6, 0, 5, 2, 7, 9, 2, 7, 9, 1, 9, 0, 0, 9, 6, 7, 0, 0, 6];
let mut i = 2;
for v in tab {
assert_eq!(amas(i), v);
i += 1;
}
assert_eq!(amas(1234), 9);
assert_eq!(amas(3005), 3);
assert_eq!(amas(5007), 5);
assert_eq!(amas(9854), 8);
... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/codegolf/the-add-multiply-add-sequence.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qeedquan/challenges path: /codegolf/the-add-multiply-add-sequence.rs
/*
Given an integer n > 1,
1) Construct the range of numbers n, n-1, n-2, ... 3, 2, 1 and calculate the sum
2) Take the individual digits of that number and calculate the product
3) Take the individual digits of that number an... | code_fim | medium | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/codegolf/the-add-multiply-add-sequence.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn connect_tee_app(&mut self, app_id: &str, connection: Transport) {
let id = connection.id.clone();
match spawn_tee_app(app_id, connection) {
Ok(s) => {
self.state.borrow_mut().running_apps.insert(id, s).unwrap();
}
Err(e) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "manduSry/platform2",
"path": "/sirenia/src/trichechus.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(EventsFromDugong {
transport: match bind_addr {
TransportType::IpConnection(url) => {
Box::new(IPServerTransport::new(&url).map_err(Error::NewTransport)?)
}
TransportType::VsockConnection(url) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "manduSry/platform2",
"path": "/sirenia/src/trichechus.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.graph
}
}
impl<'a> WharfQuery for WharfStorage<'a> {}
impl<'a> TerminalQuery for WharfStorage<'a> {}
impl<'a> SerializationQuery for WharfStorage<'a> {}
impl<'a> SourceQuery for WharfStorage<'a> {}
impl<'a> PrettyPrintQuery for WharfStorage<'a> {}
impl<'a> WharfStorage<'a> {
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "tinou98/cargo-wharf",
"path": "/cargo-wharf-frontend/src/query/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
pub trait WharfQuery: TerminalQuery {
fn definition(&self) -> Result<pb::Definition, Error> {
Ok(self.terminal()?.into_definition())
}
async fn solve(&self, bridge: &mut Bridge, options: &Options) -> Result<OutputRef, Error> {
bridge
.solve_with_cach... | code_fim | hard | {
"lang": "rust",
"repo": "tinou98/cargo-wharf",
"path": "/cargo-wharf-frontend/src/query/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tinou98/cargo-wharf path: /cargo-wharf-frontend/src/query/mod.rs
use std::iter::once;
use async_trait::*;
use chrono::prelude::*;
use failure::Error;
use petgraph::prelude::*;
use petgraph::visit::Reversed;
use buildkit_frontend::oci::*;
use buildkit_frontend::{Bridge, OutputRef};
use buildki... | code_fim | hard | {
"lang": "rust",
"repo": "tinou98/cargo-wharf",
"path": "/cargo-wharf-frontend/src/query/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(!Solution::has_path_sum(None, 0));
}
#[bench]
fn bench(b: &mut test::Bencher) {
b.iter(|| {
Solution::has_path_sum(
btree![5, 4, 8, 11, null, 13, 4, 7, 2, null, null, null, 1],
22,
)
});
}
}<|fim_prefi... | code_fim | hard | {
"lang": "rust",
"repo": "COLDTURNIP/raphanus_leetcode",
"path": "/rust/src/p112.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: COLDTURNIP/raphanus_leetcode path: /rust/src/p112.rs
/*
Problem 112. Path Sum
=====================
https://leetcode.com/problems/path-sum/
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up
all the values along the path equals the given sum.
Note... | code_fim | hard | {
"lang": "rust",
"repo": "COLDTURNIP/raphanus_leetcode",
"path": "/rust/src/p112.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Compare cards by their ranks at first, then by their suits.
/// Returns Ordering::Greater if former item is greater.
pub fn cmp_cards(&self, a: NonJokerCard, b: NonJokerCard ) -> Ordering {
self.cmp_card_ranks(a.rank(), b.rank())
.then(self.cmp_suits(a.suit(), b.suit())... | code_fim | hard | {
"lang": "rust",
"repo": "datakdtk/texas_handranks",
"path": "/playing_card/src/cmp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: datakdtk/texas_handranks path: /playing_card/src/cmp.rs
use super::card::CardRank;
use super::card::NonJokerCard;
use super::card::Suit;
use std::cmp::Ordering;
use std::collections::HashMap;
#[derive(Debug, Clone)]
/// CardComparer compares two card ranks, suits, or non-joker cards in a flexi... | code_fim | hard | {
"lang": "rust",
"repo": "datakdtk/texas_handranks",
"path": "/playing_card/src/cmp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_can_compare_suits_in_customized_order_1() {
let suits_order = [
Suit::Heart,
Suit::Club,
Suit::Spade,
Suit::Diamond,
];
let comparer = CardComparer::new_with_suit_order(CardRank::King, suits_order).expect("constr... | code_fim | hard | {
"lang": "rust",
"repo": "datakdtk/texas_handranks",
"path": "/playing_card/src/cmp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xfoxfu/limeltl path: /src/sat/transformer.rs
use crate::bool_logic::{BinaryOp, PropExpr, UnaryOp};
use std::sync::atomic::{AtomicUsize, Ordering};
/// 将任意逻辑表达式转换为 CNF 形式
pub fn convert_cnf(val: PropExpr) -> PropExpr {
PropExpr::chained_and(
flatten(conv_cnf(elim_not(elim_impl_eq(val... | code_fim | hard | {
"lang": "rust",
"repo": "xfoxfu/limeltl",
"path": "/src/sat/transformer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn plain() {
// (a) A <- B
assert_eq!(elim_impl_eq(V(1) << (V(2) | V(3))), V(1) | !(V(2) | V(3)),);
// (b) A -> B
assert_eq!(elim_impl_eq(V(1) >> (V(2) | V(3))), !V(1) | (V(2) | V(3)),);
// (c) A <-> B
assert_e... | code_fim | hard | {
"lang": "rust",
"repo": "xfoxfu/limeltl",
"path": "/src/sat/transformer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn generate_and_insert_hash_into_db(
long_url: &String,
db_connection: &PgConnection,
) -> Option<String> {
use db::schema::urls;
for attempt in 1..NUMBER_OF_HASH_ATTEMPTS + 1 {
debug!("Inserting URL '{}' into DB", long_url);
let result = diesel::insert_into(urls::table)
... | code_fim | hard | {
"lang": "rust",
"repo": "ggazzo/psag.cc",
"path": "/src/url_shortener/shorten.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ggazzo/psag.cc path: /src/url_shortener/shorten.rs
use std::io;
use std::error::Error;
use futures;
use futures::future::FutureResult;
use hyper;
use hyper::StatusCode;
use hyper::server::Response;
use hyper::header::{ContentLength, ContentType};
use diesel;
use diesel::prelude::*;
use diesel... | code_fim | hard | {
"lang": "rust",
"repo": "ggazzo/psag.cc",
"path": "/src/url_shortener/shorten.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: svmk/fund-watch-bot path: /src/telegram/task/telegram_bot_task.rs
use crate::app::model::date::Date;
use crate::{prelude::*};
use crate::telegram::service::message_handler::MessageHandler;
use crate::telegram::service::bot_instance::BotInstance;
use crate::telegram::service::event_notifier::Even... | code_fim | hard | {
"lang": "rust",
"repo": "svmk/fund-watch-bot",
"path": "/src/telegram/task/telegram_bot_task.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TelegramBotTask {
pub async fn run(&self, started_at: Option<Date>) -> Result<(), Failure> {
let events_future = self.run_events();
let import_future = self.run_import(started_at);
let run_bot = self.run_bot();
try_join3(events_future, import_future, run_bot).await... | code_fim | hard | {
"lang": "rust",
"repo": "svmk/fund-watch-bot",
"path": "/src/telegram/task/telegram_bot_task.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// args: [Int(I32)]
// result: [Int(I32)]
pub fn literal_i8_suffixed(stack: &mut Vec<Value>) -> Option<String> {
Data::with(|d| {
let n = pop(stack) as i8;
stack.push(Value::I32(d.literal.push(Literal::i8_suffixed(n))));
None
})
}
// args: [Int(I32)]
// result: [Int(I32)]
... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/watt",
"path": "/src/sym.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/watt path: /src/sym.rs
// args: [Int(I32)]
// result: [Int(I32)]
pub fn token_stream_iter_next(stack: &mut Vec<Value>) -> Option<String> {
Data::with(|d| {
let iter = &mut d.intoiter[pop(stack)];
stack.push(Value::I32(match iter.next() {
Some(token) => d.to... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/watt",
"path": "/src/sym.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/watt path: /src/sym.rs
ext = d.tokenstream[pop(stack)].clone();
let stream = &mut d.tokenstream[pop(stack)];
stream.extend(next);
None
})
}
// args: [Int(I32)]
// result: [Int(I32)]
pub fn token_tree_kind(stack: &mut Vec<Value>) -> Option<String> {
Data::w... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/watt",
"path": "/src/sym.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FIL1994/rust-file-stuff path: /src/main.rs
use std::error::Error;
use std::io::prelude::*;
use std::fs::{self, File};
use std::path::Path;
#[macro_use]
extern crate clap;
use clap::{App};
static LOREM_IPSUM: &'static str =
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do e... | code_fim | hard | {
"lang": "rust",
"repo": "FIL1994/rust-file-stuff",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Open path
let dir = Path::new("src");
// Check if it is a directory
if !dir.is_dir() {
return Err(Box::from("Is not a directory!"));
}
for entry in fs::read_dir(dir)? {
let path = entry?.path();
let file_name = path.file_name().unwrap();
println... | code_fim | hard | {
"lang": "rust",
"repo": "FIL1994/rust-file-stuff",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn print_dir_contents() -> Result<String, Box<Error>> {
// Open path
let dir = Path::new("src");
// Check if it is a directory
if !dir.is_dir() {
return Err(Box::from("Is not a directory!"));
}
for entry in fs::read_dir(dir)? {
let path = entry?.path();
le... | code_fim | hard | {
"lang": "rust",
"repo": "FIL1994/rust-file-stuff",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> OverviewerError{msg: From::from(e)}
}
}
);
}
ErrImpl!(&'static str);
ErrImpl!(String);
ErrImpl!(io::Error, "IOError");
ErrImpl!(nbtrs::Error, "NBTError", debug);<|fim_prefix|>// repo: CounterPillow/overviewer-ng path: /liboverviewer/src/error.rs
use std::error::Er... | code_fim | hard | {
"lang": "rust",
"repo": "CounterPillow/overviewer-ng",
"path": "/liboverviewer/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CounterPillow/overviewer-ng path: /liboverviewer/src/error.rs
use std::error::Error;
use std::fmt;
use std::convert::From;
use std::io;
use nbtrs;
// TODO figure out our set of error
// This current definition is just a generic container for an error message
#[derive(Debug)]
pub struct Overview... | code_fim | medium | {
"lang": "rust",
"repo": "CounterPillow/overviewer-ng",
"path": "/liboverviewer/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fhools/aoc2015 path: /day14/src/main.rs
#[derive(Debug)]
struct Reindeer {
velocity: i32,
race_time: i32,
rest_time_needed: i32,
cur_distance: i32,
cur_rest_time: i32,
cur_race_time: i32,
state: State, // 1 == racing, 2 == resting
points: i32
}
#[derive(Debug)]
e... | code_fim | hard | {
"lang": "rust",
"repo": "fhools/aoc2015",
"path": "/day14/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for r in reindeers.iter() {
println!("r: {:?}", r);
}
let winner : &Reindeer;
if PART == 1 {
winner = reindeers.iter().max_by(|r1, r2| r1.cur_distance.cmp(&r2.cur_distance)).unwrap();
println!("winner: {}", winner.cur_distance);
} else {
winner = reinde... | code_fim | hard | {
"lang": "rust",
"repo": "fhools/aoc2015",
"path": "/day14/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn write(&self, new_data: T) {
{
let mut lock = self.current_data.lock();
*lock = new_data;
}
// And tell every frame that it should update
self.frames
.iter()
.for_each(|f| f.should_update.store(true, Ordering::Releas... | code_fim | hard | {
"lang": "rust",
"repo": "lucafanselau/city-builder",
"path": "/crates/render/src/resource/swap_buffer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lucafanselau/city-builder path: /crates/render/src/resource/swap_buffer.rs
use std::{borrow::Cow, sync::atomic::Ordering};
use std::{
ops::Deref,
sync::{atomic::AtomicBool, Arc},
};
use bytemuck::Pod;
use parking_lot::Mutex;
use crate::context::GpuContext;
use super::buffer::{BufferDe... | code_fim | hard | {
"lang": "rust",
"repo": "lucafanselau/city-builder",
"path": "/crates/render/src/resource/swap_buffer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get(&self, frame_idx: u32) -> &<Context as GpuContext>::BufferHandle {
self.frame(frame_idx);
&self.frames.get(frame_idx as usize).unwrap().buffer
}
/// When you are not get(ting) a buffer every frame, you will need to call this function, to update the buffer
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "lucafanselau/city-builder",
"path": "/crates/render/src/resource/swap_buffer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gitter-badger/y-crdt path: /yrs/src/updates/encoder.rs
use crate::*;
use lib0::{any::Any, encoding::Encoder};
pub trait DSEncoder {
fn rest_encoder(&mut self) -> &mut Encoder;
fn to_buffer(self) -> Vec<u8>;
fn reset_ds_cur_val(&mut self);
fn write_ds_clock(&mut self, clock: u32)... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/y-crdt",
"path": "/yrs/src/updates/encoder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.rest_encoder.write_var_string(s);
}
fn write_parent_info(&mut self, is_y_key: bool) {
self.rest_encoder
.write_var_uint(if is_y_key { 1 as u32 } else { 0 as u32 });
}
fn write_type_ref(&mut self, info: u8) {
// In Yjs we use read_var_uint but use ... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/y-crdt",
"path": "/yrs/src/updates/encoder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eggmunkee/suri-sprint path: /src/components/particle_sys.rs
ggez::{Context,GameResult};
use ggez::graphics;
use ggez::graphics::{Rect,Image,Color,DrawParam,WrapMode,BlendMode};
use ggez::nalgebra as na;
use specs::{Component, DenseVecStorage, World, WorldExt, Entity};
//use specs::shred::{Dispa... | code_fim | hard | {
"lang": "rust",
"repo": "eggmunkee/suri-sprint",
"path": "/src/components/particle_sys.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> no_texture = false;
}
// if let Ok(rect) = ggez::graphics::Mesh::new_circle(ctx,
// ggez::graphics::DrawMode::Stroke(ggez::graphics::StrokeOptions::default()),
// na::Point2::<f32>::new(0.0, 0.0),
// self.width, 0.5,
// ggez::gr... | code_fim | hard | {
"lang": "rust",
"repo": "eggmunkee/suri-sprint",
"path": "/src/components/particle_sys.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eggmunkee/suri-sprint path: /src/components/particle_sys.rs
e ggez::{Context,GameResult};
use ggez::graphics;
use ggez::graphics::{Rect,Image,Color,DrawParam,WrapMode,BlendMode};
use ggez::nalgebra as na;
use specs::{Component, DenseVecStorage, World, WorldExt, Entity};
//use specs::shred::{Disp... | code_fim | hard | {
"lang": "rust",
"repo": "eggmunkee/suri-sprint",
"path": "/src/components/particle_sys.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
VkPipelineCoverageModulationStateCreateInfoNV
{
sType: VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV,
.. unsafe { std::mem::zeroed() }
}
}
}<|fim_prefix|>// repo: Pctg-x8/interlude path: /vk/defs/src/framebuffer_mixed_samples_nv.rs
//! VK_NV_framebuffer_mixed_samples... | code_fim | hard | {
"lang": "rust",
"repo": "Pctg-x8/interlude",
"path": "/vk/defs/src/framebuffer_mixed_samples_nv.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pctg-x8/interlude path: /vk/defs/src/framebuffer_mixed_samples_nv.rs
//! VK_NV_framebuffer_mixed_samples extensions
pub const VK_NV_FRAMEBUFFER_MIXED_SAMPLES_SPEC_VERSION: usize = 1;
pub static VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME: &'static str = "VK_NV_framebuffer_mixed_samples";
us... | code_fim | hard | {
"lang": "rust",
"repo": "Pctg-x8/interlude",
"path": "/vk/defs/src/framebuffer_mixed_samples_nv.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Change to a triangle
pub fn draw(&self, ctx: &mut Context) -> GameResult {
let circle = graphics::Mesh::new_circle(
ctx,
graphics::DrawMode::fill(),
self.pos,
PLAYER_SIZE,
0.1,
graphics::WHITE,
)?;
g... | code_fim | hard | {
"lang": "rust",
"repo": "Kushagra-0801/sidescrolling-shooter",
"path": "/src/player.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kushagra-0801/sidescrolling-shooter path: /src/player.rs
use super::{Point, SCREEN_SIZE};
use ggez::{graphics, Context, GameResult};
pub const PLAYER_SPEED: f32 = SCREEN_SIZE.1 / 100.0;
pub const PLAYER_SIZE: f32 = 10.0;
pub const PLAYER_X_POS: f32 = SCREEN_SIZE.0 / 40.0 * 3.0;
#[derive(Debug,... | code_fim | hard | {
"lang": "rust",
"repo": "Kushagra-0801/sidescrolling-shooter",
"path": "/src/player.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn bit_at(value: u8, addr: u8) -> bool {
value & (1 << addr) != 0
}
pub fn bit_at_u16(value: u16, addr: u8) -> bool {
value & (1 << addr) != 0
}
pub fn as_signed(value: u8) -> i8 {
unsafe {
mem::transmute::<u8, i8>(value)
}
}
pub fn as_signed16(value: u16) -> i16 {
unsaf... | code_fim | hard | {
"lang": "rust",
"repo": "R1tschY/avrvc",
"path": "/src/byte_convert.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn as_signed(value: u8) -> i8 {
unsafe {
mem::transmute::<u8, i8>(value)
}
}
pub fn as_signed16(value: u16) -> i16 {
unsafe {
mem::transmute::<u16, i16>(value)
}
}
pub fn as_unsigned(value: i8) -> u8 {
unsafe {
mem::transmute::<i8, u8>(value)
}
}
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "R1tschY/avrvc",
"path": "/src/byte_convert.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: R1tschY/avrvc path: /src/byte_convert.rs
use std::mem;
pub fn i16le(a: u8, b: u8) -> i16 { (b as i16) << 8 | a as i16 }
pub fn u16le(a: u8, b: u8) -> u16 { (b as u16) << 8 | a as u16 }
pub fn u16be(a: u8, b: u8) -> u16 { (a as u16) << 8 | b as u16 }
<|fim_suffix|>pub fn as_signed(value: u8) ->... | code_fim | hard | {
"lang": "rust",
"repo": "R1tschY/avrvc",
"path": "/src/byte_convert.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rokonio/glium_learning path: /src/keyboard_handler.rs
use std::collections::HashSet;
#[derive(Debug)]
pub struct KeyboardHandler {
pub key_pool: HashSet<u32>,
}
<|fim_suffix|> pub fn new() -> KeyboardHandler {
KeyboardHandler {
key_pool: HashSet::new(),
}
... | code_fim | hard | {
"lang": "rust",
"repo": "rokonio/glium_learning",
"path": "/src/keyboard_handler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn process_release(&mut self, input: u32) {
self.key_pool.remove(&input);
}
pub fn process_with<T>(&self, mut processor: T)
where
T: FnMut(u32),
{
for key in &self.key_pool {
processor(*key);
}
}
pub fn new() -> KeyboardHandler ... | code_fim | medium | {
"lang": "rust",
"repo": "rokonio/glium_learning",
"path": "/src/keyboard_handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.