text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>pub struct AudioController<S> {
sink: rodio::Sink,
changed_target_buffer: Arc<RwLock<Option<Arc<SamplesBuffer<S>>>>>,
target_buffer: Arc<SamplesBuffer<S>>,
changed_time: Arc<RwLock<Option<f32>>>,
time: Arc<RwLock<f32>>,
speed: Arc<RwLock<f32>>,
loop_mode: Arc<RwLock<bool>>,
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "OTOMariK/yee_player",
"path": "/src/buffer_player.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OTOMariK/yee_player path: /src/buffer_player.rs
use rodio::{source::Source, Decoder, OutputStreamHandle, Sample};
use std::{
path::Path,
sync::{Arc, RwLock},
time::Duration,
};
/// A buffer of samples treated as a source.
pub struct SamplesBuffer<S> {
data: Vec<S>,
channels:... | code_fim | hard | {
"lang": "rust",
"repo": "OTOMariK/yee_player",
"path": "/src/buffer_player.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cloudflare/lol-html path: /examples/defer_scripts/main.rs
use lol_html::{element, HtmlRewriter, Settings};
use std::io;
use std::io::prelude::*;
fn main() {
let stdin = io::stdin();
let mut stdout = io::stdout();
<|fim_suffix|> // Feed chunks from the stdin to the rewriter
loop ... | code_fim | hard | {
"lang": "rust",
"repo": "cloudflare/lol-html",
"path": "/examples/defer_scripts/main.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Feed chunks from the stdin to the rewriter
loop {
let mut stdin = stdin.lock();
let buffer = stdin.fill_buf().unwrap();
let len = buffer.len();
if len > 0 {
rewriter.write(buffer).unwrap();
stdin.consume(len);
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "cloudflare/lol-html",
"path": "/examples/defer_scripts/main.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rlkelly/z3-cxx path: /build.rs
use cmake;
fn build_z3() {
let mut cfg = cmake::Config::new("z3");
cfg
// Don't build `libz3.so`, build `libz3.a` instead.
.define("Z3_BUILD_LIBZ3_SHARED", "false")
// Don't build the Z3 repl.
.define("Z3_BUILD_EXECUTABLE", ... | code_fim | hard | {
"lang": "rust",
"repo": "rlkelly/z3-cxx",
"path": "/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if cfg!(target_os = "windows") {
println!("cargo:rustc-link-lib=static=libz3");
} else {
println!("cargo:rustc-link-lib=static=z3");
}
if let Some(cxx) = cxx {
println!("cargo:rustc-link-lib={}", cxx);
}
}
fn main() {
build_z3();
cxx_build::bridge("src... | code_fim | hard | {
"lang": "rust",
"repo": "rlkelly/z3-cxx",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
build_z3();
cxx_build::bridge("src/lib.rs")
.include("z3.h")
.include("z3_fpa.h")
.include("z3_optimization.h")
.include("z3_ast_containers.h")
.flag_if_supported("-std=c++17")
.compile("z3_cxx");
println!("cargo:rerun-if-changed=src... | code_fim | hard | {
"lang": "rust",
"repo": "rlkelly/z3-cxx",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeandudey/cc13x2-rs path: /src/aux_adi4/mux3.rs
#[doc = "Reader of register MUX3"]
pub type R = crate::R<u8, super::MUX3>;
#[doc = "Writer for register MUX3"]
pub type W = crate::W<u8, super::MUX3>;
#[doc = "Register MUX3 `reset()`'s with value 0"]
impl crate::ResetValue for super::MUX3 {
ty... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/aux_adi4/mux3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>xio24(&self) -> bool {
*self == ADCCOMPB_IN_A::AUXIO24
}
#[doc = "Checks if the value of the field is `AUXIO25`"]
#[inline(always)]
pub fn is_auxio25(&self) -> bool {
*self == ADCCOMPB_IN_A::AUXIO25
}
#[doc = "Checks if the value of the field is `AUXIO26`"]
#[in... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/aux_adi4/mux3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>OMPB_IN_A::AUXIO22)
}
#[doc = "Internal. Only to be used through TI provided API."]
#[inline(always)]
pub fn auxio23(self) -> &'a mut W {
self.variant(ADCCOMPB_IN_A::AUXIO23)
}
#[doc = "Internal. Only to be used through TI provided API."]
#[inline(always)]
pub fn au... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/aux_adi4/mux3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // compute λ(a*r) and λ'(a*r)
let r = (d.x*d.x + d.y*d.y).sqrt();
let ar = self.a*r;
let lambda = (*(self.lambda))(ar); // λ(a*r)
let dlambda = (*(self.dlambda))(ar); // λ'(a*r)
// ______ Computation of value F(u;θ) ______
// compute elem... | code_fim | hard | {
"lang": "rust",
"repo": "Trdonja/Difkon",
"path": "/src/transformation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Trdonja/Difkon path: /src/transformation.rs
use matrices::*;
/*
This structure stores the information needed to compute the transformation
F: ℝ² -> ℝ², F(u) = V(r)*R(r)*(u - u₀)
and its gradient with respect to transformation parameters, if needed.
Here, u₀ = (x₀, y₀) ∈ ℝ² is the center of ... | code_fim | hard | {
"lang": "rust",
"repo": "Trdonja/Difkon",
"path": "/src/transformation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // compute λ(a*r)
let r = (d.x*d.x + d.y*d.y).sqrt();
let lambda = (*(self.lambda))(self.a*r);
// compute elements of symetric matrix V(r) = λ(a*r)*Ξ + I
// V(r) = λ(a*r)*⎡ξ₁₁ ξ₁₂⎤ + ⎡1 0⎤
// ⎣ξ₁₂ ξ₂₂⎦ ⎣0 1⎦
let mat_v = SymMa... | code_fim | hard | {
"lang": "rust",
"repo": "Trdonja/Difkon",
"path": "/src/transformation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_parse_key_lookup_arb(r#"key_lookup("accounts","123")"#, "accounts", json!("123"));
test_parse_key_lookup_arb(r#"key_lookup( accounts ,"123")"#, "accounts", json!("123"));
test_parse_key_lookup_arb(r#"key_lookup("accounts",123)"#, "accounts", json!(123.0));
test_parse_k... | code_fim | hard | {
"lang": "rust",
"repo": "JPMoresmau/kv_eql",
"path": "/src/parse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> i: &'a str,
) -> IResult<&'a str, Vec<Value>, E> {
context(
"array",
preceded(
char('['),
cut(terminated(
separated_list0(preceded(sp, char(',')), json_value),
preceded(sp, char(']')),
)),
),
)(i)
}
fn... | code_fim | hard | {
"lang": "rust",
"repo": "JPMoresmau/kv_eql",
"path": "/src/parse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JPMoresmau/kv_eql path: /src/parse.rs
ract)),
spaced(","),
quoted_str)
),
preceded(sp, char(')')),
)),
),
)
,|(((first,first_key),(second,second_key)),j... | code_fim | hard | {
"lang": "rust",
"repo": "JPMoresmau/kv_eql",
"path": "/src/parse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: garbein/rodent-redis path: /src/server.rs
use crate::commands::CommandInfo;
use crate::db::Db;
use crate::networking;
use crate::resp::Resp;
use async_std::io::{self, BufReader};
use async_std::net::{TcpListener, TcpStream};
use async_std::prelude::*;
use async_std::task;
use structopt::StructOp... | code_fim | hard | {
"lang": "rust",
"repo": "garbein/rodent-redis",
"path": "/src/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// 处理请求
async fn run(&self, mut stream: TcpStream) -> anyhow::Result<()> {
// 心跳检测
unsafe {
networking::set_keepalive(&stream, 300)?;
}
loop {
let mut reader = BufReader::new(&stream);
// 解析redis协议
let resp = Resp::pa... | code_fim | hard | {
"lang": "rust",
"repo": "garbein/rodent-redis",
"path": "/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: osanshouo/enumcombinatorics path: /src/lib.rs
//! Collection of permutation, combination, sequence and multichoose of `usize`s.
//!
//! This crate provides iterators (or streaming iterators) generating all possible
//! permutations, combinations, ... of 0, 1, ..., n-1. Here is an example:
//!
... | code_fim | medium | {
"lang": "rust",
"repo": "osanshouo/enumcombinatorics",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub mod permutation;
pub use crate::permutation::Permutation;
pub mod sequence;
pub use crate::sequence::Sequence;
pub mod combination;
pub use combination::Combination;
pub mod multichoose;
pub use crate::multichoose::Multichoose;<|fim_prefix|>// repo: osanshouo/enumcombinatorics path: /src/lib.rs
/... | code_fim | medium | {
"lang": "rust",
"repo": "osanshouo/enumcombinatorics",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[group]
#[prefixes("courses")]
#[commands(mk, rm, mv, rename, deprecate, list, add_uc)]
struct Courses;
#[command]
#[description("Cria salas das cadeiras especificadas, associadas ao ano especificado.")]
#[usage("ano semestre [CADEIRA, ...]")]
#[min_args(3)]
#[required_permissions(ADMINISTRATOR)]
pub as... | code_fim | hard | {
"lang": "rust",
"repo": "MIEIdiscord/Rusteze",
"path": "/src/commands/study.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[command]
#[description("Add channel to existing course.")]
#[usage("CADEIRA NEW_CHANNEL")]
#[min_args(2)]
#[required_permissions(ADMINISTRATOR)]
pub async fn add_uc(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
let trash = ctx.data.read().await;
let mut roles = get!(> trash, MiEI,... | code_fim | hard | {
"lang": "rust",
"repo": "MIEIdiscord/Rusteze",
"path": "/src/commands/study.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MIEIdiscord/Rusteze path: /src/commands/study.rs
use crate::{channels::MiEI, get, log};
use futures::{
future,
stream::{self, StreamExt},
};
use once_cell::sync::Lazy;
use regex::{Regex, RegexBuilder};
use serenity::{
framework::standard::{
macros::{command, group},
A... | code_fim | hard | {
"lang": "rust",
"repo": "MIEIdiscord/Rusteze",
"path": "/src/commands/study.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/gitoxide path: /gix-pack/src/index/access.rs
use std::{mem::size_of, ops::Range};
use crate::{
data,
index::{self, EntryIndex, PrefixLookupResult, FAN_LEN},
};
const N32_SIZE: usize = size_of::<u32>();
const N64_SIZE: usize = size_of::<u64>();
const V1_HEADER_SIZE: usize = FAN_LE... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-pack/src/index/access.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::cmp::Ordering::*;
match prefix.cmp_oid(mid_sha) {
Less => upper_bound = mid,
Equal => match candidates {
Some(candidates) => {
let first_past_entry = ((0..mid).rev())
.take_while(|prev| prefix.cmp_... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-pack/src/index/access.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug_assert_eq!(self.version, index::Version::V2);
let ofs32 = crate::read_u32(offset);
if (ofs32 & N32_HIGH_BIT) == N32_HIGH_BIT {
let from = pack64_offset + (ofs32 ^ N32_HIGH_BIT) as usize * N64_SIZE;
crate::read_u64(&self.data[from..][..N64_SIZE])
... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-pack/src/index/access.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TaskId {
fn new() -> Self {
static NEXT_ID: AtomicU64 = AtomicU64::new(0);
TaskId(NEXT_ID.fetch_add(1, Ordering::Relaxed))
}
}<|fim_prefix|>// repo: load1n9/agave path: /crates/api/src/sys/task/mod.rs
use alloc::boxed::Box;
use core::{future::Future, pin::Pin};
pub mod execu... | code_fim | hard | {
"lang": "rust",
"repo": "load1n9/agave",
"path": "/crates/api/src/sys/task/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> static NEXT_ID: AtomicU64 = AtomicU64::new(0);
TaskId(NEXT_ID.fetch_add(1, Ordering::Relaxed))
}
}<|fim_prefix|>// repo: load1n9/agave path: /crates/api/src/sys/task/mod.rs
use alloc::boxed::Box;
use core::{future::Future, pin::Pin};
pub mod executor;
pub struct Task {
id: TaskI... | code_fim | medium | {
"lang": "rust",
"repo": "load1n9/agave",
"path": "/crates/api/src/sys/task/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: load1n9/agave path: /crates/api/src/sys/task/mod.rs
use alloc::boxed::Box;
use core::{future::Future, pin::Pin};
pub mod executor;
<|fim_suffix|> static NEXT_ID: AtomicU64 = AtomicU64::new(0);
TaskId(NEXT_ID.fetch_add(1, Ordering::Relaxed))
}
}<|fim_middle|>pub struct Task {... | code_fim | hard | {
"lang": "rust",
"repo": "load1n9/agave",
"path": "/crates/api/src/sys/task/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.backoff_delay = None;
self.first_poll = false;
let available_object = self.pool.try_take();
let object_in_progress = self.factory_future_in_progress.is_some();
if available_object.is_none() && !object_in_progress {
debug!("get object from connector... | code_fim | hard | {
"lang": "rust",
"repo": "gngeorgiev/fut_pool_rs",
"path": "/src/taker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gngeorgiev/fut_pool_rs path: /src/taker.rs
use std::io::{Error, ErrorKind, Result};
use std::pin::Pin;
use std::task::Context;
use std::time::{Duration, Instant};
use futures::{ready, try_ready, Future, FutureExt, Poll};
use futures_timer::Delay;
use crate::backoff::BackoffStrategy;
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "gngeorgiev/fut_pool_rs",
"path": "/src/taker.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ghcom275/socketpair path: /src/winx.rs
//! `SocketpairStream` and `socketpair_stream` for Windows.
use std::{
convert::TryInto,
fmt::{self, Arguments, Debug},
fs::File,
io::{self, IoSlice, IoSliceMut, Read, Write},
os::windows::{
ffi::OsStrExt,
io::{AsRawHand... | code_fim | hard | {
"lang": "rust",
"repo": "ghcom275/socketpair",
"path": "/src/winx.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AsRawHandle for SocketpairStream {
#[inline]
fn as_raw_handle(&self) -> RawHandle {
self.0.as_raw_handle()
}
}
impl IntoRawHandle for SocketpairStream {
#[inline]
fn into_raw_handle(self) -> RawHandle {
self.0.into_raw_handle()
}
}
impl FromRawHandle for Sock... | code_fim | hard | {
"lang": "rust",
"repo": "ghcom275/socketpair",
"path": "/src/winx.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.write_all(buf)
}
#[cfg(write_all_vectored)]
#[inline]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice]) -> io::Result<()> {
self.0.write_all_vectored(bufs)
}
#[inline]
fn write_fmt(&mut self, fmt: Arguments) -> io::Result<()> {
self.0.write... | code_fim | hard | {
"lang": "rust",
"repo": "ghcom275/socketpair",
"path": "/src/winx.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dfriedenberger/Prellblock path: /prellblock/src/consensus/praftbft/notify.rs
#![allow(clippy::module_name_repetitions)]
use std::{
collections::HashMap,
future::Future,
hash::Hash,
pin::Pin,
sync::{Arc, Mutex},
task::{Context, Poll, Waker},
};
type NotifyMapInner<T> = A... | code_fim | hard | {
"lang": "rust",
"repo": "dfriedenberger/Prellblock",
"path": "/prellblock/src/consensus/praftbft/notify.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
index: 0,
inner: self.inner.clone(),
state: self.state.clone(),
}
}
}
impl<T> Future for Wait<T>
where
T: Hash + Eq + Clone + Unpin,
{
type Output = ();
fn poll(mut self: Pin<&mut Self>, ctx: &mut Context) -> Poll<Self::Output> {
... | code_fim | hard | {
"lang": "rust",
"repo": "dfriedenberger/Prellblock",
"path": "/prellblock/src/consensus/praftbft/notify.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>nnel is suspended, as a result of writing EN bit to 0."]
#[inline(always)]
pub fn ctcif2(&self) -> CTCIF2_R {
CTCIF2_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 2 - Channel x block repeat transfer complete interrupt flag This bit is set by hardware. It is cleared by softw... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32h7/src/stm32h747cm4/mdma/c2isr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32h7/src/stm32h747cm4/mdma/c2isr.rs
#[doc = "Reader of register C2ISR"]
pub type R = crate::R<u32, super::C2ISR>;
#[doc = "Reader of field `TEIF2`"]
pub type TEIF2_R = crate::R<bool, bool>;
#[doc = "Reader of field `CTCIF2`"]
pub type CTCIF2_R = crate::... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32h7/src/stm32h747cm4/mdma/c2isr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mlcruz/upgrade_rs path: /src/handle_input.rs
,
game_state: &mut GameState,
look_at_camera: &mut FreeCamera,
free_camera: &mut FreeCamera,
view: &mut View,
speed: &mut f32,
main_obj: &mut SceneObject,
plane: &mut SceneObject,
texture_pool: &Vec<&u32>,
) {
match... | code_fim | hard | {
"lang": "rust",
"repo": "mlcruz/upgrade_rs",
"path": "/src/handle_input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Permite movimentação no plano y
if game_state.can_fly == false {
new_vec.y = 0.0;
}
*main_obj = main_obj.translate(new_vec.x, new_vec.y, new_vec.z)
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "mlcruz/upgrade_rs",
"path": "/src/handle_input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (glutin::VirtualKeyCode::Numpad7, glutin::ElementState::Pressed) => {
view.lighting.global = glm::vec3(
view.lighting.global.x + 0.05,
view.lighting.global.y,
view.lighting.global.z,
... | code_fim | hard | {
"lang": "rust",
"repo": "mlcruz/upgrade_rs",
"path": "/src/handle_input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jdkaplan/advent-of-code path: /2022/src/bin/day02.rs
use std::str::FromStr;
const INPUT: &str = include_str!("../../input/day02.txt");
fn main() {
println!("{:?}", part1(INPUT));
println!("{:?}", part2(INPUT));
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
enum Play {
Rock,
P... | code_fim | hard | {
"lang": "rust",
"repo": "jdkaplan/advent-of-code",
"path": "/2022/src/bin/day02.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match (self, opponent) {
(Loss, Rock) => Scissors,
(Loss, Paper) => Rock,
(Loss, Scissors) => Paper,
(Tie, Rock) => Rock,
(Tie, Paper) => Paper,
(Tie, Scissors) => Scissors,
(Win, Rock) => Paper,
(Win, ... | code_fim | hard | {
"lang": "rust",
"repo": "jdkaplan/advent-of-code",
"path": "/2022/src/bin/day02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: panicbit/rfi path: /src/lib.rs
extern crate git2;
extern crate regex;
extern crate pulldown_cmark;
extern crate reqwest;
extern crate serde;
extern crate serde_json as json;
#[macro_use] extern crate s<|fim_suffix|>atic;
#[macro_use] extern crate matches;
pub mod rfc;
pub mod errors;
pub mod gi... | code_fim | medium | {
"lang": "rust",
"repo": "panicbit/rfi",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>atic;
#[macro_use] extern crate matches;
pub mod rfc;
pub mod errors;
pub mod github;<|fim_prefix|>// repo: panicbit/rfi path: /src/lib.rs
extern crate git2;
extern crate regex;
extern crate pulldown_cmark;
extern crate reqw<|fim_middle|>est;
extern crate serde;
extern crate serde_json as json;
#[macro_... | code_fim | medium | {
"lang": "rust",
"repo": "panicbit/rfi",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TotalKrill/bevy_obj path: /src/lib.rs
mod loader;
pub use loader::*;
<|fim_suffix|>/// Adds support for Obj file loading to Apps
#[derive(Default)]
pub struct ObjPlugin;
impl Plugin for ObjPlugin {
fn build(&self, app: &mut App) {
app.init_asset_loader::<ObjLoader>();
}
}<|fim_... | code_fim | easy | {
"lang": "rust",
"repo": "TotalKrill/bevy_obj",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> app.init_asset_loader::<ObjLoader>();
}
}<|fim_prefix|>// repo: TotalKrill/bevy_obj path: /src/lib.rs
mod loader;
pub use loader::*;
use bevy::app::prelude::*;
use bevy::asset::AddAsset;
<|fim_middle|>/// Adds support for Obj file loading to Apps
#[derive(Default)]
pub struct ObjPlugin;
im... | code_fim | medium | {
"lang": "rust",
"repo": "TotalKrill/bevy_obj",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TotalKrill/bevy_obj path: /src/lib.rs
mod loader;
pub use loader::*;
use bevy::app::prelude::*;
use bevy::asset::AddAsset;
<|fim_suffix|>impl Plugin for ObjPlugin {
fn build(&self, app: &mut App) {
app.init_asset_loader::<ObjLoader>();
}
}<|fim_middle|>/// Adds support for Obj ... | code_fim | medium | {
"lang": "rust",
"repo": "TotalKrill/bevy_obj",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_bits(dev: dev_t) -> DeviceType {
DeviceType(dev)
}
pub fn bits(&self) -> dev_t {
self.0
}
pub fn major(&self) -> u32 {
((self.0 >> 32 & 0xfffff000) | ((self.0 >> 8) & 0xfff)) as u32
}
pub fn minor(&self) -> u32 {
((self.0 >> 12 & 0... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/proc/bin/starnix/types/device_type.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvanotti/fuchsia-mirror path: /src/proc/bin/starnix/types/device_type.rs
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::types::uapi::*;
#[derive(Copy, Clone, Debug, D... | code_fim | medium | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/proc/bin/starnix/types/device_type.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheSirC/backend-website-pmc path: /src/models.rs
#![allow(non_camel_case_types)]
use crate::diesel::Queryable;
use crate::serde::{Serialize,Deserialize};
#[derive(Queryable, Serialize, Deserialize)]
pub struct beamsplitters {
manufacturer: Option<String>,
model: Option<String>,
diam... | code_fim | hard | {
"lang": "rust",
"repo": "TheSirC/backend-website-pmc",
"path": "/src/models.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Queryable, Serialize, Deserialize)]
pub struct shapes {
name: String,
}
#[derive(Queryable, Serialize, Deserialize)]
pub struct waveplates {
manufacturer: Option<String>,
model: Option<String>,
diameter: Option<f64>,
quantity: Option<i32>,
shape: Option<String>,
mount... | code_fim | hard | {
"lang": "rust",
"repo": "TheSirC/backend-website-pmc",
"path": "/src/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match &value {
X::A(_x) => {}
X::B(_y) => {}
}
println!("{:?}", value);
}<|fim_prefix|>// repo: loiclec/fuzzcheck-rs path: /fuzzcheck/tests/expansions/enums_with_generic_type_params.rs
use fuzzcheck::{DefaultMutator, Mutator};
<|fim_middle|>#[derive(Clone, Debug, DefaultMutat... | code_fim | hard | {
"lang": "rust",
"repo": "loiclec/fuzzcheck-rs",
"path": "/fuzzcheck/tests/expansions/enums_with_generic_type_params.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loiclec/fuzzcheck-rs path: /fuzzcheck/tests/expansions/enums_with_generic_type_params.rs
use fuzzcheck::{DefaultMutator, Mutator};
#[derive(Clone, Debug, DefaultMutator)]
pub enum X<T> {
A(T),
B(Vec<T>),
}
#[test]
#[no_coverage]
fn test_compile() {
<|fim_suffix|> match &value {
... | code_fim | medium | {
"lang": "rust",
"repo": "loiclec/fuzzcheck-rs",
"path": "/fuzzcheck/tests/expansions/enums_with_generic_type_params.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn load_compile_benchmark_metadata() -> HashMap<String, CompileBenchmarkMetadata> {
let serialized = EmbeddedCompileBenchmarks::get(SERIALIZED_SUITE_NAME)
.unwrap()
.data
.to_vec();
let metadata: metadata::CompileBenchmarkSuite = serde_json::from_slice(&serialized)
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/site/src/benchmark_metadata/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /site/src/benchmark_metadata/mod.rs
use hashbrown::HashMap;
use rust_embed::RustEmbed;
use collector::compile::benchmark::category::Category;
use collector::compile::benchmark::BenchmarkConfig;
use crate::benchmark_metadata::metadata::SERIALIZED_SUITE_NAME;
mod meta... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/site/src/benchmark_metadata/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn update_mesh(
&mut self,
surface: graphics::SurfaceHandle,
verts: &[CanvasVertex],
idxes: &[u16],
) -> Result<graphics::MeshHandle> {
if let Some((nv, ni, handle)) = self.mesh {
if nv >= verts.len() && ni >= idxes.len() {
let sl... | code_fim | hard | {
"lang": "rust",
"repo": "KKHarmless/crayon",
"path": "/modules/imgui/src/renderer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KKHarmless/crayon path: /modules/imgui/src/renderer.rs
use std::sync::Arc;
use crayon::{application, graphics, resource, utils};
use crayon::application::errors::*;
use imgui::{DrawList, ImGui, Ui};
impl_vertex!{
CanvasVertex {
position => [Position; Float; 2; false],
texc... | code_fim | hard | {
"lang": "rust",
"repo": "KKHarmless/crayon",
"path": "/modules/imgui/src/renderer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline(always)]
fn stream_clear_transfer_complete_flag(&mut self) {
//NOTE(unsafe) Atomic write with no side-effects and we only access the bits
// that belongs to the StreamX
let dma = unsafe { &*I::ptr() };
... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32h7xx-hal",
"path": "/src/dma/dma.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> //NOTE(unsafe) Atomic read with no side effects
let dma = unsafe { &*I::ptr() };
dma.$isr.read().$tcisr().bit_is_set()
}
#[inline(always)]
fn stream_get_half_transfer_flag() -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32h7xx-hal",
"path": "/src/dma/dma.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32h7xx-hal path: /src/dma/dma.rs
f
}
/// Set the peripheral_burst.
#[inline(always)]
#[must_use]
pub fn peripheral_burst(
mut self,
peripheral_burst: config::BurstMode,
) -> Self {
self.peripheral_burst = peripheral_burst;
self
... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32h7xx-hal",
"path": "/src/dma/dma.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: norman784/gox path: /src/layer.rs
use crate::{
get_value, get_value_int, get_value_string, read_dict, read_int, Bounded, Chunk, Image,
};
#[derive(Debug, Copy, Clone)]
pub enum Shape {
Cube = 1,
Cylinder = 2,
Sphere = 0,
}
#[derive(Debug)]
pub struct Layer {
pub base_id: i32,
pub b... | code_fim | hard | {
"lang": "rust",
"repo": "norman784/gox",
"path": "/src/layer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Layer {
base_id,
blocks,
id,
image_path,
material,
name,
shape: {
match shape {
1 => Shape::Cube,
2 => Shape::Cylinder,
_ => Shape::Sphere,
}
},
transform,
bounds,
}
}
}<|fim_prefix|>// repo... | code_fim | hard | {
"lang": "rust",
"repo": "norman784/gox",
"path": "/src/layer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn rotate_right(game: &mut VecDeque<usize>, k:usize) {
for _ in 0..k {
let back = game.pop_back().unwrap();
game.push_front(back);
}
}
fn rotate_left(game: &mut VecDeque<usize>, l:usize) {
for _ in 0..l {
let back = game.pop_front().unwrap();
game.push_back(back);
}
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "quandrum/aoc2018",
"path": "/day7+/src/day9.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quandrum/aoc2018 path: /day7+/src/day9.rs
use std::collections::{ HashMap, VecDeque };
#[aoc_generator(day9)]
pub fn input_generator(_input: &str) -> Vec<(usize, usize)> {
[(424, 71144)].to_vec()
}
#[aoc(day9, part1)]
fn part1(input: &Vec<(usize, usize)>) -> usize {
let nplayers = input[0]... | code_fim | hard | {
"lang": "rust",
"repo": "quandrum/aoc2018",
"path": "/day7+/src/day9.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xuorig/anicca path: /src/cli/mod.rs
pub(crate) mod diff;
pub(crate) mod formatters;
<|fim_suffix|>#[derive(Debug, StructOpt)]
pub enum Command {
/// Diff two OpenAPI descriptions
Diff(diff::DiffCommand),
}
impl Anicca {
pub fn run(&self) {
match &self.command {
... | code_fim | medium | {
"lang": "rust",
"repo": "xuorig/anicca",
"path": "/src/cli/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, StructOpt)]
pub enum Command {
/// Diff two OpenAPI descriptions
Diff(diff::DiffCommand),
}
impl Anicca {
pub fn run(&self) {
match &self.command {
Command::Diff(command) => command.run(),
}
}
}<|fim_prefix|>// repo: xuorig/anicca path: /src/cl... | code_fim | medium | {
"lang": "rust",
"repo": "xuorig/anicca",
"path": "/src/cli/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub unsafe fn mdd_bootstrap_initialize() -> windows::HRESULT {
#[link(name = "Microsoft.ProjectReunion.Bootstrap")]
extern "system" {
fn MddBootstrapInitialize(major_minor_version: u32,
version_tag: *const u16,
min_version: PackageVersion) -> windows::HRESULT;
}... | code_fim | hard | {
"lang": "rust",
"repo": "riverar/winui-rs-poc",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = window.Activate();
self.window = Some(window);
result
}
}
pub unsafe fn mdd_bootstrap_initialize() -> windows::HRESULT {
#[link(name = "Microsoft.ProjectReunion.Bootstrap")]
extern "system" {
fn MddBootstrapInitialize(major_minor_version: u32,
... | code_fim | hard | {
"lang": "rust",
"repo": "riverar/winui-rs-poc",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: riverar/winui-rs-poc path: /src/main.rs
#![windows_subsystem = "console"]
use std::{convert::{TryFrom}};
use bindings::{
Microsoft,
Microsoft::UI::Xaml::{
Application,
ApplicationInitializationCallback,
Controls::Button,
HorizontalAlignment,
Laun... | code_fim | hard | {
"lang": "rust",
"repo": "riverar/winui-rs-poc",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/recovery/lib/recovery-ui/src/text_field.rs
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::{
button::{Button, ButtonOptions, ButtonShape... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/recovery/lib/recovery-ui/src/text_field.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // This row is necessary to align the rectangles to create a border
builder.start_group(
&("Border row"),
Flex::with_options_ptr(FlexOptions::row(
MainAxisSize::Max,
MainAxisAlignment::Start,
CrossAxisAlignment::Center... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/recovery/lib/recovery-ui/src/text_field.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_focused(&mut self, scene: &mut Scene, focused: bool) {
if let Some(button) = &mut self.button {
button.set_focused(scene, focused);
}
}
pub fn handle_pointer_event(
&mut self,
scene: &mut Scene,
context: &mut ViewAssistantContext,... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/recovery/lib/recovery-ui/src/text_field.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/baremetalisp path: /kernel/src/driver/device/allwinner/memory.rs
// Allwinner A64
pub const DEVICE_MEM_START: u64 = 0x01000000;
pub const DEVICE_MEM_END: u64 = 0x02000000;
pub const ROM_START: u64 = 0x00000000;
pub const ROM_END: u64 = 0x00010000;
pub const SRAM_START: u64 = 0x00010000;... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/baremetalisp",
"path": "/kernel/src/driver/device/allwinner/memory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const SUNXI_SCP_BASE: u32 = SUNXI_SRAM_A2_BASE + SUNXI_SRAM_A2_SIZE - SUNXI_SCP_SIZE;
pub const SUNXI_SCP_SIZE: u32 = 0x4000;
// Memory-mapped devices
pub const SUNXI_CPU_MBIST_BASE: u32 = 0x01502000;
pub const SUNXI_CPUCFG_BASE: u32 = 0x01700000;
pub const SUNXI_SYSCON_BASE: u32 = 0x01c00000;
pub co... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/baremetalisp",
"path": "/kernel/src/driver/device/allwinner/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Memory-mapped devices
pub const SUNXI_CPU_MBIST_BASE: u32 = 0x01502000;
pub const SUNXI_CPUCFG_BASE: u32 = 0x01700000;
pub const SUNXI_SYSCON_BASE: u32 = 0x01c00000;
pub const SUNXI_DMA_BASE: u32 = 0x01c02000;
pub const SUNXI_KEYMEM_BASE: u32 = 0x01c0b000;
pub const SUNXI_SMHC0_BASE: u32 = 0x01c0f000;
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/baremetalisp",
"path": "/kernel/src/driver/device/allwinner/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AtheMathmo/rugrads path: /src/iter.rs
use super::Node;
use std::collections::HashMap;
fn relevant_parents<'a, 'b, T>(parents: &'b Vec<Node<'a, T>>, start_idx: usize) -> Vec<&'b Node<'a, T>> {
parents.iter()
.filter(|p| {
p.progenitors.contains(&start_idx) || p.i... | code_fim | hard | {
"lang": "rust",
"repo": "AtheMathmo/rugrads",
"path": "/src/iter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, 'b, T: 'a> Iterator for RevTopology<'a, 'b, T> {
type Item = &'a Node<'b, T>;
fn next(&mut self) -> Option<&'a Node<'b, T>> {
if let Some(node) = self.childless_nodes.pop() {
for p in relevant_parents(&node.parents, self.start) {
let mut cc = self.chil... | code_fim | hard | {
"lang": "rust",
"repo": "AtheMathmo/rugrads",
"path": "/src/iter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sunkaiiii/study_computer_science path: /Learn_Rust/the_rust_programming_langauge/chapter13closure_and_iterator/src/main.rs
use std::thread;
use std::time::Duration;
fn simulated_expensive_calculation(intensity:u32) -> u32{
println!("calculating slowly...");
thread::sleep(Duration::from_... | code_fim | medium | {
"lang": "rust",
"repo": "sunkaiiii/study_computer_science",
"path": "/Learn_Rust/the_rust_programming_langauge/chapter13closure_and_iterator/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Cacher { calculation: calculation, value: None }
}
fn value(&mut self, arg:u32) -> u32{
match self.value {
Some(v)=>v,
None=>{
let v = (self.calculation)(arg);
self.value = Some(v);
v
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "sunkaiiii/study_computer_science",
"path": "/Learn_Rust/the_rust_programming_langauge/chapter13closure_and_iterator/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cocagne/aspen-server path: /src/ida.rs
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum IDA {
Replication {
width: u8,
write_threshold: u8
},
ReedSolomon {
width: u8,
read_threshold: u8,
write_threshold: u8
}
}
<|fim_suffix|> pub f... | code_fim | hard | {
"lang": "rust",
"repo": "cocagne/aspen-server",
"path": "/src/ida.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn read_threshold(&self) -> u8 {
match self {
IDA::Replication{ width, write_threshold } => *width / 2 + 1,
IDA::ReedSolomon{ width, write_threshold, read_threshold } => *read_threshold
}
}
}<|fim_prefix|>// repo: cocagne/aspen-server path: /src/ida.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "cocagne/aspen-server",
"path": "/src/ida.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn write_threshold(&self) -> u8 {
match self {
IDA::Replication{ width, write_threshold } => *write_threshold,
IDA::ReedSolomon{ width, write_threshold, read_threshold } => *write_threshold
}
}
pub fn read_threshold(&self) -> u8 {
match self... | code_fim | hard | {
"lang": "rust",
"repo": "cocagne/aspen-server",
"path": "/src/ida.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RSSchermer/web_glitz.rs path: /web_glitz/src/pipeline/resources/resource_bindings_encoding.rs
} => {
state.set_active_texture(*unit).apply(gl).unwrap();
match texture_data {
TextureData::Texture2D(data) => unsafe {
d... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/web_glitz.rs",
"path": "/web_glitz/src/pipeline/resources/resource_bindings_encoding.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> BindGroupEncoder {
context,
bindings,
_marker: marker::PhantomData,
}
}
}
macro_rules! nest_pairs {
($head:tt) => ($head);
($head:tt, $($tail:tt),*) => (($head, nest_pairs!($($tail),*)));
}
macro_rules! nest_pairs_reverse {
([$head:tt] ... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/web_glitz.rs",
"path": "/web_glitz/src/pipeline/resources/resource_bindings_encoding.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RSSchermer/web_glitz.rs path: /web_glitz/src/pipeline/resources/resource_bindings_encoding.rs
is not
// public.
pub(crate) struct ResourceBindingDescriptor {
internal: BindingDescriptorInternal,
}
impl ResourceBindingDescriptor {
pub(crate) fn bind(&self, connection: &mut Connection) {
... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/web_glitz.rs",
"path": "/web_glitz/src/pipeline/resources/resource_bindings_encoding.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (ent, fov, pos) in (&entities, &mut fields_of_view, &positions).join() {
if fov.is_dirty {
fov.is_dirty = false;
fov.visible_tiles.clear();
fov.visible_tiles = field_of_view(Point::new(pos.x, pos.y), fov.range, &*map);
... | code_fim | hard | {
"lang": "rust",
"repo": "Zij-IT/Roguelike",
"path": "/src/ecs/systems/visibility_system.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Zij-IT/Roguelike path: /src/ecs/systems/visibility_system.rs
use crate::{
components::{FieldOfView, Position},
map_builder::map::{Map, TileStatus},
};
use rltk::{field_of_view, Point};
use specs::prelude::*;
<|fim_suffix|>impl<'a> System<'a> for VisibilitySystem {
type SystemData = ... | code_fim | hard | {
"lang": "rust",
"repo": "Zij-IT/Roguelike",
"path": "/src/ecs/systems/visibility_system.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, data: Self::SystemData) {
let (entities, player_entity, positions, mut map, mut fields_of_view) = data;
for (ent, fov, pos) in (&entities, &mut fields_of_view, &positions).join() {
if fov.is_dirty {
fov.is_dirty = false;
fo... | code_fim | hard | {
"lang": "rust",
"repo": "Zij-IT/Roguelike",
"path": "/src/ecs/systems/visibility_system.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: baptistemanson/rust-pathfinder path: /rules/src/rules/finesse.rs
use dice::Roll;
use crate::{
character::Character, rules::RuleImplementation, timeline::get_modifier, world::World,
};
<|fim_suffix|> let str_mod = get_modifier(c.ability_score.strength);
let dex_mod = get_modi... | code_fim | medium | {
"lang": "rust",
"repo": "baptistemanson/rust-pathfinder",
"path": "/rules/src/rules/finesse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let str_mod = get_modifier(c.ability_score.strength);
let dex_mod = get_modifier(c.ability_score.dexterity);
if str_mod < dex_mod {
let r = r.remove_bonus("str");
r + Roll::flat("finesse", dex_mod) // replace str by dex
} else {
r
... | code_fim | medium | {
"lang": "rust",
"repo": "baptistemanson/rust-pathfinder",
"path": "/rules/src/rules/finesse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn default_mutation_kinds() -> Vec<(MutationKind, usize)> {
use MutationKind::*;
vec![
(AddConnection, 10),
(RemoveConnection, 10),
(AddNode, 10),
(RemoveNode, 10),
(ModifyWeight, 10),
(ModifyBias, 10),
(ModifyActivation, 10),
(M... | code_fim | hard | {
"lang": "rust",
"repo": "stjepangolemac/neat-rs",
"path": "/core/src/neat/configuration.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The fitness cost of every connection in the gene
pub connection_cost: f64,
/// The mutation rate of offspring
pub mutation_rate: f64,
/// The ratio of genomes that will survive to the next generation
pub survival_ratio: f64,
/// The types of mutations available and their... | code_fim | hard | {
"lang": "rust",
"repo": "stjepangolemac/neat-rs",
"path": "/core/src/neat/configuration.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stjepangolemac/neat-rs path: /core/src/neat/configuration.rs
use std::default::Default;
use crate::mutations::MutationKind;
/// Holds configuration options of the whole NEAT process
#[derive(Debug)]
pub struct Configuration {
/// The generations limit of for the evolution process
pub m... | code_fim | hard | {
"lang": "rust",
"repo": "stjepangolemac/neat-rs",
"path": "/core/src/neat/configuration.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let back_number = PF.get_print_number(201, 3, 2, "20121115001:1;20121115002:1,7|2*1", "中国体育彩票演示票\n演示票竞彩足球胜平负 单场固定\n200243-945712-189922-67 FD362CCE 00546858\n─────────────────────\n周日001\n主队:皇家马德里 Vs 客队:巴塞罗那\n(1)@12.9元\n周日002\n主队:皇家马德里 Vs 客队:巴塞罗那\n(1)@12.0元+(7+)@2.0元\n").unwrap();
info!("{}", ba... | code_fim | hard | {
"lang": "rust",
"repo": "limitee/football",
"path": "/game/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_gl_map() -> BTreeMap<i64, Json> {
let mut gl_map = BTreeMap::<i64, Json>::new();
{
let mut lev = json!(r#"
{"data":[{"bonus":1000,"bonus_after_tax":800,"create_time":1460639394,"descrip":"一等奖","game_id":200,"id":1,"lev":1,"term_code":2015001,"version":0},{"bonus":800,"bonus_after_tax":600,"c... | code_fim | hard | {
"lang": "rust",
"repo": "limitee/football",
"path": "/game/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: limitee/football path: /game/src/main.rs
extern crate game;
use game::validate::ValidateFactory;
use game::base::Ticket;
use game::VF;
use game::DF;
use game::PF;
extern crate cons;
use cons::ErrCode;
extern crate rustc_serialize;
use rustc_serialize::json::Json;
use rustc_serialize::json::ToJ... | code_fim | hard | {
"lang": "rust",
"repo": "limitee/football",
"path": "/game/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: randomPoison/gunship-rs path: /lib/polygon_math/src/color.rs
use std::slice;
pub const RED: Color = Color { r: 1.0, b: 0.0, g: 0.0, a: 1.0 };
pub const WHITE: Color = Color { r: 1.0, b: 1.0, g: 1.0, a: 1.0 };
pub const BLUE: Color = Color { r: 0.0, b: 1.0, g: 0.0, a: 1.0 };
/// A struct rep... | code_fim | hard | {
"lang": "rust",
"repo": "randomPoison/gunship-rs",
"path": "/lib/polygon_math/src/color.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<Color> for (f32, f32, f32, f32) {
fn from(from: Color) -> (f32, f32, f32, f32) {
let Color { r, g, b, a } = from;
(r, g, b, a)
}
}
impl<'a> From<&'a Color> for (f32, f32, f32, f32) {
fn from(from: &Color) -> (f32, f32, f32, f32) {
let &Color { r, g, b, a } = ... | code_fim | hard | {
"lang": "rust",
"repo": "randomPoison/gunship-rs",
"path": "/lib/polygon_math/src/color.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Number { value: item }
}
}
fn main() {
let my_str = "hello";
let _my_string = String::from(my_str);
let num = Number::from(30);
println!("My number is {:?}", num);
let int = 5;
let num: Number = int.into();
println!("My number is {:?}", num);
}<|fim_prefix|>// re... | code_fim | hard | {
"lang": "rust",
"repo": "frankhart2018/rust-by-example",
"path": "/6-conversion/from-and-into-1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.