text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>#[test]
fn cvtsi2sd_6() {
run_test(
&Instruction {
mnemonic: Mnemonic::CVTSI2SD,
operand1: Some(Direct(XMM1)),
operand2: Some(IndirectDisplaced(
RCX,
856764648,
Some(OperandSize::Qword),
None,
... | code_fim | hard | {
"lang": "rust",
"repo": "ftilde/rust-x86asm",
"path": "/src/test/instruction_tests/instr_cvtsi2sd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lbrande/18-chesapeake path: /lib/src/ids.rs
use crate::rounds::{OperatingRound, PrivAuction, StockRound};
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::iter::Copied;
use std::slice::Iter;
use std::str::FromStr;
/// Represents the color of a tile
#[derive(Clone, Copy, Debug, ... | code_fim | hard | {
"lang": "rust",
"repo": "lbrande/18-chesapeake",
"path": "/lib/src/ids.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"B&O" => Ok(PubComId::BAndO),
"C&A" => Ok(PubComId::CAndA),
"C&O" => Ok(PubComId::CAndO),
"LV" => Ok(PubComId::LV),
"N&W" => Ok(PubComId::NAndW),
"PRR" => Ok(PubC... | code_fim | hard | {
"lang": "rust",
"repo": "lbrande/18-chesapeake",
"path": "/lib/src/ids.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromStr for TerrainId {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"Plain" => Ok(TerrainId::Plain),
"River" => Ok(TerrainId::River),
"Mountain" => Ok(TerrainId::Mountain),
_ => Err(format!("{} can not... | code_fim | hard | {
"lang": "rust",
"repo": "lbrande/18-chesapeake",
"path": "/lib/src/ids.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: verylazyguy/binaryninja-api path: /rust/src/lib.rs
r development. Compatibility _will_ break and conventions _will_ change! They are being used for core Binary Ninja features however, so we expect much of what is already there to be reliable enough to build on, just don't be surprised if your pl... | code_fim | hard | {
"lang": "rust",
"repo": "verylazyguy/binaryninja-api",
"path": "/rust/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if load_settings.is_none() {
// TODO : The Python version has a "fixme" here but I have no idea why
if universal_view_type.is_some()
&& options.is_some()
&& options
.as_ref()
.unwrap()
.contains_key("files.universa... | code_fim | hard | {
"lang": "rust",
"repo": "verylazyguy/binaryninja-api",
"path": "/rust/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: verylazyguy/binaryninja-api path: /rust/src/lib.rs
/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// S... | code_fim | hard | {
"lang": "rust",
"repo": "verylazyguy/binaryninja-api",
"path": "/rust/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zzeroo/average path: /src/lib.rs
#![feature(test)]
extern crate chrono;
extern crate rand;
extern crate test;
use chrono::prelude::*;
use rand::Rng;
use std::time::{Duration, Instant};
fn sum(values: &Vec<(u32, Instant)>) -> Option<f64> {
let len = values.len();
let mut weight = len;... | code_fim | hard | {
"lang": "rust",
"repo": "zzeroo/average",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn gen_random_values() -> Vec<(u32, Instant)> {
let mut values: Vec<(u32, Instant)> = vec![];
for i in 0..1801 {
let random_value = rand::thread_rng().gen_range(0, 1023);
// ADC/ random_values mit dem aktuellen Zeitstempel in einm Tuppel in ein Vector speichern... | code_fim | hard | {
"lang": "rust",
"repo": "zzeroo/average",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //
// I2C Devices
//
// Create shared mux for the I2C bus
let i2c_mux = static_init!(
capsules_core::virtualizers::virtual_i2c::MuxI2C<'static, nrf52832::i2c::TWI<'static>>,
capsules_core::virtualizers::virtual_i2c::MuxI2C::new(&base_peripherals.twi0, None,)
);
... | code_fim | hard | {
"lang": "rust",
"repo": "tock/tock",
"path": "/boards/acd52832/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // RTT communication channel
let rtt_memory = components::segger_rtt::SeggerRttMemoryComponent::new()
.finalize(components::segger_rtt_memory_component_static!());
let rtt = components::segger_rtt::SeggerRttComponent::new(mux_alarm, rtt_memory)
.finalize(components::segger_rtt_... | code_fim | hard | {
"lang": "rust",
"repo": "tock/tock",
"path": "/boards/acd52832/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tock/tock path: /boards/acd52832/src/main.rs
ow should the kernel respond when a process faults.
const FAULT_RESPONSE: kernel::process::PanicFaultPolicy = kernel::process::PanicFaultPolicy {};
// Number of concurrent processes this platform supports.
const NUM_PROCS: usize = 4;
static mut PROC... | code_fim | hard | {
"lang": "rust",
"repo": "tock/tock",
"path": "/boards/acd52832/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ToBase58Check for BlockHash {
fn to_base58check(&self) -> String {
self.0
.with_prefix(Prefix::B)
.to_base58check()
}
}
impl AsRef<BlockHashInner> for BlockHash {
fn as_ref(&self) -> &BlockHashInner {
&self.0
}
}
impl Serialize for BlockHash {... | code_fim | hard | {
"lang": "rust",
"repo": "boltlabs-inc/tezedge-client",
"path": "/types/src/block_hash.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boltlabs-inc/tezedge-client path: /types/src/block_hash.rs
use std::convert::TryInto;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crypto::{Prefix, WithPrefix, WithoutPrefix};
use crypto::base58check::{FromBase58Check, ToBase58Check};
use super::FromPrefixedBase58CheckErro... | code_fim | hard | {
"lang": "rust",
"repo": "boltlabs-inc/tezedge-client",
"path": "/types/src/block_hash.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
impl Serialize for BlockHash {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer
{
serializer.serialize_str(
&self.to_base58check()
)
}
}
impl<'de> Deserialize<'de> for BlockHash {
fn deserial... | code_fim | medium | {
"lang": "rust",
"repo": "boltlabs-inc/tezedge-client",
"path": "/types/src/block_hash.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/Minecraft-Reports-GUI path: /src/report/aggregates.rs
use std::collections::HashMap;
use std::rc::Rc;
use uuid::Uuid;
use crate::report::damage::{Damage, DamageCause};
use crate::report::heal::Heal;
use crate::report::player::{Player, PlayerStatistics, SimplePlayer};
#[derive(Seriali... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/Minecraft-Reports-GUI",
"path": "/src/report/aggregates.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> kills: damages.iter()
.filter(|damage| match &damage.damager {
Some(damager) => &damager.uuid == player && damage.lethal,
None => false
})
.map(|damage| damage.damagee.clone())
... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/Minecraft-Reports-GUI",
"path": "/src/report/aggregates.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aschampion/rust-n5 path: /benches/parallel_write.rs
//! # Parallel Writing Benchmarks
//!
//! Provides parallel writing benchmarks. For parity with Java N5's
//! `N5Benchmark`, the benchmark dataset is `i16`, with a 5x5x5 grid of blocks
//! of 64x64x64. The blocks are loaded with data from this ... | code_fim | hard | {
"lang": "rust",
"repo": "aschampion/rust-n5",
"path": "/benches/parallel_write.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> b.iter(|| write(&n, &compression, &block_data, pool_size));
b.bytes =
(BLOCK_DIM * BLOCK_DIM * BLOCK_DIM) as u64 *
(N_BLOCKS * N_BLOCKS * N_BLOCKS) as u64 *
std::mem::size_of::<T>() as u64;
}
// 1 Thread. Can't macro this because of the concat_idents! limitation.
#[bench]... | code_fim | hard | {
"lang": "rust",
"repo": "aschampion/rust-n5",
"path": "/benches/parallel_write.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fdebellabre/ray-tracer path: /src/material.rs
use rand::Rng;
use crate::vec3::{Color, Vec3};
use crate::{hittable::HitRecord, ray::Ray};
pub trait Material {
fn scatter<RNG: Rng>(&self, r_in: &Ray, rec: &HitRecord, rng: &mut RNG)
-> Option<(Color, Ray)>;
}
pub enum MaterialObject ... | code_fim | hard | {
"lang": "rust",
"repo": "fdebellabre/ray-tracer",
"path": "/src/material.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ray = Ray(Vec3(-1., 0., 0.), Vec3(1.0, 0.0, 0.0));
let hit_record = HitRecord {
p: Vec3(0., 0., 0.),
normal: Vec3(-1., -1., 0.).unit_vector(),
mat: &MaterialObject::Dielectric(Dielectric {
ir: 1.0,
darken: 1.,
... | code_fim | hard | {
"lang": "rust",
"repo": "fdebellabre/ray-tracer",
"path": "/src/material.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cannot_refract = refraction_ratio * sin_theta > 1.0;
// Use Schlick's approximation for reflectance.
let r0 = (1. - refraction_ratio) / (1. + refraction_ratio);
let r0 = r0 * r0;
let r0 = r0 + (1. - r0) * (1. - cos_theta).powf(5.);
let direction = if c... | code_fim | hard | {
"lang": "rust",
"repo": "fdebellabre/ray-tracer",
"path": "/src/material.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get(&self, resource_id: &ResourceId) -> Option<Rc<Data>> {
if let Some(data) = self.table.borrow().get(resource_id) {
Some(Rc::clone(data))
} else {
None
}
}
pub fn get_as<T>(&self, resource_id: &ResourceId) -> Option<Rc<T>>
where
... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/arena.org/resource/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SoundRabbit/soldoresol path: /src/arena.org/resource/mod.rs
use crate::libs::random_id::U128Id;
use crate::libs::try_ref::TryRef;
use futures::future::join_all;
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
use std::ops::Deref;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/arena.org/resource/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Arena {
table: Rc<RefCell<HashMap<ResourceId, Rc<Data>>>>,
}
impl Arena {
pub fn new() -> Self {
Self {
table: Rc::new(RefCell::new(HashMap::new())),
}
}
fn clone(this: &Self) -> Self {
Self {
table: Rc::clone(&this.table),
... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/arena.org/resource/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn fuel_test1() {
assert_eq!(2, fuel(&12));
}
#[test]
fn fuel_test2() {
assert_eq!(2, fuel(&14));
}
#[test]
fn fuel_test3() {
assert_eq!(654, fuel(&1969));
}
#[test]
fn fuel_test4() {
assert_eq!(33583, fuel(&100756));
}
#[test]
fn more_fuel_test1() {... | code_fim | medium | {
"lang": "rust",
"repo": "dantarian/adventofcode2019",
"path": "/src/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dantarian/adventofcode2019 path: /src/day1.rs
use std::error::Error;
use std::path::PathBuf;
use std::fs::File;
use std::io::{BufRead, BufReader, ErrorKind, Read};
pub fn run_day1(filename: &PathBuf, part2: &bool) -> Result<(), Box<dyn Error>> {
let vec = read(File::open(filename)?)?;
... | code_fim | medium | {
"lang": "rust",
"repo": "dantarian/adventofcode2019",
"path": "/src/day1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn more_fuel_test1() {
assert_eq!(0, more_fuel(&8));
}
#[test]
fn more_fuel_test2() {
assert_eq!(1, more_fuel(&9));
}
#[test]
fn more_fuel_test3() {
assert_eq!(16763, more_fuel(&33583));
}
}<|fim_prefix|>// repo: dantarian/adventofcode2019 path: /src/day1.r... | code_fim | medium | {
"lang": "rust",
"repo": "dantarian/adventofcode2019",
"path": "/src/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn set_write_timeout(&self, dur: Option<Duration>) -> io::Result<()> {
self.lock().set_write_timeout(dur)
}
#[inline]
fn close(&mut self, how: Shutdown) -> io::Result<()> {
self.lock().close(how)
}
}
#[cfg(feature = "client")]
#[derive(Clone)]
pub struct... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/hyper-sync-rustls/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/hyper-sync-rustls/src/lib.rs
extern crate rustls;
extern crate hyper;
#[cfg(feature = "client")]
extern crate webpki_roots;
#[cfg(feature = "client")]
extern crate webpki;
use std::io;
use std::sync::Arc;
use std::sync::{Mutex, MutexGuard};
use std::net:... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/hyper-sync-rustls/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::Io(ref e) => e.description(),
Error::BadCerts => "the contents of the certificates file were invalid",
Error::BadKeyCount => "the private key file cont... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/hyper-sync-rustls/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=syscall");
}<|fim_prefix|>// repo: matklad/compilers path: /pyt/runtime/build.rs
use std::process::Command;
use std::env;
use std::path::Path;
fn main() {
<|fim_middle|> let out_dir = env::var("OUT_D... | code_fim | hard | {
"lang": "rust",
"repo": "matklad/compilers",
"path": "/pyt/runtime/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matklad/compilers path: /pyt/runtime/build.rs
use std::process::Command;
use std::env;
use std::path::Path;
<|fim_suffix|> println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=syscall");
}<|fim_middle|>fn main() {
let out_dir = env::var("OUT_D... | code_fim | hard | {
"lang": "rust",
"repo": "matklad/compilers",
"path": "/pyt/runtime/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn points(&self) -> &HashMap<Coordinate4d, i32> {
&self.space
}
pub fn sum_all_points(&self) -> i32 {
let mut total = 0;
for (_, v) in self.space.iter() {
total += v;
}
total
}
}<|fim_prefix|>// repo: DavidAmison/adventofcode2020 pa... | code_fim | hard | {
"lang": "rust",
"repo": "DavidAmison/adventofcode2020",
"path": "/day17_v2/src/hyperspace.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn sum_around_point(&self, point: Coordinate4d) -> i32 {
let mut total = 0;
for w in point.0-1..=point.0+1 {
for z in point.3-1..=point.3+1 {
for y in point.2-1..=point.2+1 {
for x in point.1-1..=point.1+1 {
le... | code_fim | hard | {
"lang": "rust",
"repo": "DavidAmison/adventofcode2020",
"path": "/day17_v2/src/hyperspace.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DavidAmison/adventofcode2020 path: /day17_v2/src/hyperspace.rs
use std::collections::HashMap;
pub type Coordinate4d = (i32, i32, i32, i32);
#[derive(Debug)]
pub struct HyperSpace { space: HashMap<Coordinate4d, i32> }
impl HyperSpace {
pub fn new() -> Self {
HyperSpace{ space: Has... | code_fim | hard | {
"lang": "rust",
"repo": "DavidAmison/adventofcode2020",
"path": "/day17_v2/src/hyperspace.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Sets the value for an identity column
fn set_column(&mut self, column: &str, value: &SqlArg) -> crate::result::Result<()>;
}<|fim_prefix|>// repo: roy-ganz/toql path: /crates/core/src/identity.rs
//! Identity trait.
//!
//! The identity trait is used to update foreign keys.
//! The trait is ... | code_fim | hard | {
"lang": "rust",
"repo": "roy-ganz/toql",
"path": "/crates/core/src/identity.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roy-ganz/toql path: /crates/core/src/identity.rs
//! Identity trait.
//!
//! The identity trait is used to update foreign keys.
//! The trait is used by the TreeIdentity trait and implemented for all Toql derived entities.
//! Key columns in Toql entities are automatically identity columns.
//! ... | code_fim | hard | {
"lang": "rust",
"repo": "roy-ganz/toql",
"path": "/crates/core/src/identity.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn width(&self) -> u16;
fn height(&self) -> u16;
}
impl<T: Space, D: Deref<Target = T> + PartialEq> Space for D {
fn full_width(&self) -> u16 {
self.deref().full_width()
}
fn full_height(&self) -> u16 {
self.deref().full_height()
}
fn width(&self) -> u16 {
... | code_fim | medium | {
"lang": "rust",
"repo": "yiblet/tagtask",
"path": "/src/view/space.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yiblet/tagtask path: /src/view/space.rs
use std::ops::Deref;
pub trait Space: PartialEq {
fn full_width(&self) -> u16;
fn full_height(&self) -> u16;
fn width(&self) -> u16;
fn height(&self) -> u16;
}
impl<T: Space, D: Deref<Target = T> + PartialEq> Space for D {
fn full_wid... | code_fim | medium | {
"lang": "rust",
"repo": "yiblet/tagtask",
"path": "/src/view/space.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !self.origin.headers().has::<CacheControl>() {
// Default is 1day.
self.origin.headers_mut().set(CacheControl(vec![CacheDirective::MaxAge(86400u32)]));
}
self.origin.set_body(buf);
Ok(self).into_future().boxed()
}
}<|fim_prefix|>// repo: maya... | code_fim | hard | {
"lang": "rust",
"repo": "mayah/zircon.rs",
"path": "/src/renderers/file_renderer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buf = Vec::<u8>::new();
let mut file = match File::open(path) {
Ok(x) => x,
Err(err) => {
return ZirconError::IoError(err).render()
}
};
match file.read_to_end(&mut buf) {
Ok(_) => (),
Err... | code_fim | medium | {
"lang": "rust",
"repo": "mayah/zircon.rs",
"path": "/src/renderers/file_renderer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mayah/zircon.rs path: /src/renderers/file_renderer.rs
use std::fs::File;
use std::io::Read;
use std::path::Path;
use futures::{Future, IntoFuture};
use hyper::header::{CacheControl, CacheDirective};
use prelude::*;
<|fim_suffix|> let mut file = match File::open(path) {
Ok(x... | code_fim | hard | {
"lang": "rust",
"repo": "mayah/zircon.rs",
"path": "/src/renderers/file_renderer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(task) = self.task_current() {
match task.state {
MTState::None => {
self.task_tree.remove_bheap_h();
}
MTState::Idle => {
self.task_tree.bheap_h_to_flist_h();
}
... | code_fim | hard | {
"lang": "rust",
"repo": "convexbrain/studynotes",
"path": "/sandbox/nRF52840/rust/led_ctxtsw/src/minimult.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: convexbrain/studynotes path: /sandbox/nRF52840/rust/led_ctxtsw/src/minimult.rs
_of, transmute};
use core::marker::PhantomData;
type MTTaskId = u16;
type MTTaskPri = u8;
//
fn align_up<T>(x: usize) -> usize
{
let align = align_of::<T>();
let y = (x + align - 1) / align;
... | code_fim | hard | {
"lang": "rust",
"repo": "convexbrain/studynotes",
"path": "/sandbox/nRF52840/rust/led_ctxtsw/src/minimult.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: convexbrain/studynotes path: /sandbox/nRF52840/rust/led_ctxtsw/src/minimult.rs
self.replace(I::zero(), pos1);
// bheap tail <=> flist head
self.n_flist = self.n_flist + I::one();
self.n_bheap = self.n_bheap - I::one();
self.down_bheap();
}
p... | code_fim | hard | {
"lang": "rust",
"repo": "convexbrain/studynotes",
"path": "/sandbox/nRF52840/rust/led_ctxtsw/src/minimult.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn lines_overlap(l1: &Line, l2: &Line) -> bool {
let a = l1.p1.x;
let b = l1.p1.y;
let c = l1.p2.x;
let d = l1.p2.y;
let p = l2.p1.x;
let q = l2.p1.y;
let r = l2.p2.x;
let s = l2.p2.y;
let det = (c - a) * (s - q) - (r - p) * (d - b);
if det == 0.0 {
return false;
}
let lamb... | code_fim | hard | {
"lang": "rust",
"repo": "trs/advent-of-code-2019",
"path": "/src/days/day3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trs/advent-of-code-2019 path: /src/days/day3.rs
use crate::utils::{request, lines};
use std::fmt;
#[derive(Clone, Copy)]
struct Point {
x: f32,
y: f32
}
impl fmt::Debug for Point {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {})", self.x, self.y)
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "trs/advent-of-code-2019",
"path": "/src/days/day3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> lines
}
fn lines_overlap(l1: &Line, l2: &Line) -> bool {
let a = l1.p1.x;
let b = l1.p1.y;
let c = l1.p2.x;
let d = l1.p2.y;
let p = l2.p1.x;
let q = l2.p1.y;
let r = l2.p2.x;
let s = l2.p2.y;
let det = (c - a) * (s - q) - (r - p) * (d - b);
if det == 0.0 {
return false;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "trs/advent-of-code-2019",
"path": "/src/days/day3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simhaonline/hcloud-rust path: /src/models/get_metrics_for_loadbalancer_response.rs
/*
* Hetzner Cloud API
*
* Copied from the official API documentation for the Public Hetzner Cloud.
*
* The version of the OpenAPI document: 0.0.3
*
* Generated by: https://openapi-generator.tech
*/
<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "simhaonline/hcloud-rust",
"path": "/src/models/get_metrics_for_loadbalancer_response.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GetMetricsForLoadbalancerResponse {
/// Response to GET https://api.hetzner.cloud/v1/load_balancers/{id}/metrics{?type,start,end,step}
pub fn new(metrics: crate::models::Metrics) -> GetMetricsForLoadbalancerResponse {
GetMetricsForLoadbalancerResponse {
metrics,
}
... | code_fim | medium | {
"lang": "rust",
"repo": "simhaonline/hcloud-rust",
"path": "/src/models/get_metrics_for_loadbalancer_response.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct GetMetricsForLoadbalancerResponse {
#[serde(rename = "metrics")]
pub metrics: crate::models::Metrics,
}
impl GetMetricsForLoadbalancerResponse {
/// Response to GET https://api.hetzner.cloud/v1/load_balancers/{id}/metrics{... | code_fim | medium | {
"lang": "rust",
"repo": "simhaonline/hcloud-rust",
"path": "/src/models/get_metrics_for_loadbalancer_response.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct NotesQueue {
notes: Vec<Note>,
}
impl NotesQueue {
pub fn new(mut notes: Vec<Note>) -> Self {
notes.sort_unstable_by(|a, b| {
b.start_at
.partial_cmp(&a.start_at)
.unwrap_or(std::cmp::Ordering::Equal)
});
... | code_fim | hard | {
"lang": "rust",
"repo": "Raclett3/dischord-rs",
"path": "/composer/src/generate/note.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Raclett3/dischord-rs path: /composer/src/generate/note.rs
use crate::generate::ToneKind;
#[derive(Debug, PartialEq, Clone)]
pub struct Note {
frequency: f32,
tone: ToneKind,
volume_from: f32,
volume_to: f32,
offset: f32,
start_at: f32,
end_at: f32,
}
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "Raclett3/dischord-rs",
"path": "/composer/src/generate/note.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl NotesQueue {
pub fn new(mut notes: Vec<Note>) -> Self {
notes.sort_unstable_by(|a, b| {
b.start_at
.partial_cmp(&a.start_at)
.unwrap_or(std::cmp::Ordering::Equal)
});
NotesQueue { notes }
}
pub fn next_before(&mut self, ... | code_fim | hard | {
"lang": "rust",
"repo": "Raclett3/dischord-rs",
"path": "/composer/src/generate/note.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vraisamis/AtCoder path: /ABC158/d/src/main.rs
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn readv<T: std::str::FromStr>() -> Vec<T> {
read::<S... | code_fim | hard | {
"lang": "rust",
"repo": "vraisamis/AtCoder",
"path": "/ABC158/d/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match (reversed, add_to_head) {
(false, true) => {
head = s + &head;
},
(true, true) => {
tail = tail + &s;
},
(false, false) => {
tail = tail + &s;
... | code_fim | hard | {
"lang": "rust",
"repo": "vraisamis/AtCoder",
"path": "/ABC158/d/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Self(Vec::new_with_capacity(FixedHeaderSize + MaximumLcSize + MaximumDataLength + MaximumLeSize)?))
}
#[inline(always)]
fn reserve_send(&mut self) -> &mut Vec<u8>
{
self.0.clear();
&mut self.0
}
}<|fim_prefix|>// repo: raphaelcohn/security-keys-rust path: /workspace/security-keys-rust/src... | code_fim | hard | {
"lang": "rust",
"repo": "raphaelcohn/security-keys-rust",
"path": "/workspace/security-keys-rust/src/low_level/transmit/SendBuffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raphaelcohn/security-keys-rust path: /workspace/security-keys-rust/src/low_level/transmit/SendBuffer.rs
// This file is part of security-keys-rust. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.... | code_fim | hard | {
"lang": "rust",
"repo": "raphaelcohn/security-keys-rust",
"path": "/workspace/security-keys-rust/src/low_level/transmit/SendBuffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const MaximumLeSize: usize = 3;
Ok(Self(Vec::new_with_capacity(FixedHeaderSize + MaximumLcSize + MaximumDataLength + MaximumLeSize)?))
}
#[inline(always)]
fn reserve_send(&mut self) -> &mut Vec<u8>
{
self.0.clear();
&mut self.0
}
}<|fim_prefix|>// repo: raphaelcohn/security-keys-rust pa... | code_fim | hard | {
"lang": "rust",
"repo": "raphaelcohn/security-keys-rust",
"path": "/workspace/security-keys-rust/src/low_level/transmit/SendBuffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MarcinKacperek/space_ships path: /src/systems/destroy_out_of_arena.rs
use amethyst::{
core::Transform,
ecs::{
Join,
WriteStorage,
ReadStorage,
Entities,
System
}
};
use crate::{
components::{
Rect,
tags::{
Delete... | code_fim | hard | {
"lang": "rust",
"repo": "MarcinKacperek/space_ships",
"path": "/src/systems/destroy_out_of_arena.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
(
entities,
mut transforms,
rects,
destroy_out_of_arena_tags,
mut delete_entity_tags
): Self::SystemData
) {
for (entity, transform, rect, _) in (&entities, &mut transforms, &rects, &destroy_out_... | code_fim | hard | {
"lang": "rust",
"repo": "MarcinKacperek/space_ships",
"path": "/src/systems/destroy_out_of_arena.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: onurzdg/libp2p-bittorrent-protocol path: /src/disk/manager.rs
DiskMessageOut};
use crate::disk::native::NativeFileSystem;
use crate::handler::BitTorrentHandlerEvent::TorrentErr;
use crate::peer::torrent::TorrentId;
use crate::piece::PieceState;
use crate::torrent::MetaInfo;
use crate::util::ShaH... | code_fim | hard | {
"lang": "rust",
"repo": "onurzdg/libp2p-bittorrent-protocol",
"path": "/src/disk/manager.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: onurzdg/libp2p-bittorrent-protocol path: /src/disk/manager.rs
e>>,
torrents: FnvHashSet<TorrentFile>,
file_system: TFileSystem,
queued_events: VecDeque<DiskMessageIn>,
}
impl<TFileSystem: FileSystem> DiskManager<TFileSystem> {
pub fn with_capacity(file_system: TFileSystem, capac... | code_fim | hard | {
"lang": "rust",
"repo": "onurzdg/libp2p-bittorrent-protocol",
"path": "/src/disk/manager.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("Finalizing block");
match block.finalize() {
BlockResult::Read {
torrent,
result,
files,
} => {
for file in files {
self.file_cache
.insert(file.id, F... | code_fim | hard | {
"lang": "rust",
"repo": "onurzdg/libp2p-bittorrent-protocol",
"path": "/src/disk/manager.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<I> TryReducible for I
where
I: ParallelIterator<Controlled = True>,
{
fn try_reduce<T, OP, ID>(self, identity: ID, op: OP) -> Self::Item
where
OP: Fn(T, T) -> Self::Item + Sync + Send,
ID: Fn() -> T + Sync + Send,
Self::Item: Try<Ok = T>,
{
let reducer ... | code_fim | hard | {
"lang": "rust",
"repo": "ma1ko/rayon_try_fold",
"path": "/src/traits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ma1ko/rayon_try_fold path: /src/traits.rs
{
op: OP,
identity: ID,
}
fn schedule_join_try_reduce<P, T, OP, ID>(
mut producer: P,
reducer: &TryReduceCallback<OP, ID>,
stop: &AtomicBool,
) -> P::Item
where
P: Producer,
OP: Fn(T, T) -> P::Item + Sync + Send,
ID: Fn()... | code_fim | hard | {
"lang": "rust",
"repo": "ma1ko/rayon_try_fold",
"path": "/src/traits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ma1ko/rayon_try_fold path: /src/traits.rs
educeCallback<OP, ID>,
stop: &AtomicBool,
) -> P::Item
where
P: Producer,
OP: Fn(T, T) -> P::Item + Sync + Send,
ID: Fn() -> T + Sync + Send,
P::Item: Try<Ok = T> + Send,
{
if stop.load(Ordering::Relaxed) {
P::Item::from_o... | code_fim | hard | {
"lang": "rust",
"repo": "ma1ko/rayon_try_fold",
"path": "/src/traits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: petgraph/petgraph path: /src/algo/mod.rs
i in g.node_identifiers() {
if dfs.discovered.is_visited(&i) {
continue;
}
dfs.move_to(i);
while let Some(nx) = dfs.next(Reversed(g)) {
finish_order.push(nx);
}
}
let mut dfs = Dfs... | code_fim | hard | {
"lang": "rust",
"repo": "petgraph/petgraph",
"path": "/src/algo/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for n in g.node_identifiers() {
let visited = self.nodes[g.to_index(n)].rootindex.is_some();
if !visited {
self.visit(n, g, &mut f);
}
}
debug_assert!(self.stack.is_empty());
}
fn visit<G, F>(&mut self, v: G::NodeId, g: ... | code_fim | hard | {
"lang": "rust",
"repo": "petgraph/petgraph",
"path": "/src/algo/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: petgraph/petgraph path: /src/algo/mod.rs
impl<N, VM> Default for DfsSpace<N, VM>
where
VM: VisitMap<N> + Default,
{
fn default() -> Self {
DfsSpace {
dfs: Dfs {
stack: <_>::default(),
discovered: <_>::default(),
},
}... | code_fim | hard | {
"lang": "rust",
"repo": "petgraph/petgraph",
"path": "/src/algo/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndreasChristianson/project-euler-rust path: /src/factors/all_factors.rs
// slow. need to use prime factors and combinatorics
use super::super::combinatorics::permutations::permute;
use super::prime_factors::prime_factors;
pub fn factors<T: num::PrimInt>(target: T) -> Vec<T> {
let mut ret ... | code_fim | hard | {
"lang": "rust",
"repo": "AndreasChristianson/project-euler-rust",
"path": "/src/factors/all_factors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
vec![
1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 20, 21, 22, 25, 26, 28, 30,
33, 34, 35, 36, 39, 42, 44, 45, 50, 51, 52, 55, 60, 63, 65, 66, 68, 70, 75, 77, 78,
84, 85, 90, 91, 99, 100, 102, 105, 110, 117, 119, 12... | code_fim | hard | {
"lang": "rust",
"repo": "AndreasChristianson/project-euler-rust",
"path": "/src/factors/all_factors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn factors_of_76576500() {
assert_eq!(
vec![
1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 20, 21, 22, 25, 26, 28, 30,
33, 34, 35, 36, 39, 42, 44, 45, 50, 51, 52, 55, 60, 63, 65, 66, 68, 70, 75, 77, 78,
84, 85, 9... | code_fim | hard | {
"lang": "rust",
"repo": "AndreasChristianson/project-euler-rust",
"path": "/src/factors/all_factors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xieren58/rust_cms path: /dao/src/schema.rs
table! {
tb_article (id) {
id -> Varchar,
title -> Nullable<Varchar>,
subtitle -> Nullable<Varchar>,
intro -> Nullable<Varchar>,
rcmd_weight -> Nullable<Integer>,
url -> Nullable<Varchar>,
stat... | code_fim | hard | {
"lang": "rust",
"repo": "xieren58/rust_cms",
"path": "/dao/src/schema.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>allow_tables_to_appear_in_same_query!(
tb_article,
tb_article_content,
tb_file,
tb_login_info,
);<|fim_prefix|>// repo: xieren58/rust_cms path: /dao/src/schema.rs
table! {
tb_article (id) {
id -> Varchar,
title -> Nullable<Varchar>,
subtitle -> Nullable<Varchar... | code_fim | hard | {
"lang": "rust",
"repo": "xieren58/rust_cms",
"path": "/dao/src/schema.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrde/game-rs path: /src/host_api.rs
pub trait HostApi {
fn print(&self, val: &str) {
print!("{}", val)
}
fn println(&self, val: &str) {
<|fim_suffix|> fn update_canvas(&mut self, buffer: &[u8], pitch: usize);
fn generate_audio(&mut self);
fn load_bmp(&self, pat... | code_fim | medium | {
"lang": "rust",
"repo": "chrde/game-rs",
"path": "/src/host_api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Input {
pub old: InputState,
pub new: InputState,
pub time_per_frame: f32,
}
pub struct Bitmap {
pub align_x: u32,
pub align_y: u32,
pub width: usize,
pub height: usize,
pub pixels: Vec<u8>,
}<|fim_prefix|>// repo: chrde/game-rs path: /src/host_api.rs
pub trait... | code_fim | hard | {
"lang": "rust",
"repo": "chrde/game-rs",
"path": "/src/host_api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: greenpdx/chat path: /async-server/src/lines.rs
use futures::io::AsyncRead;
use futures::stream::Stream;
use futures::task::{Context, Poll};
use std::collections::VecDeque;
use std::io;
use std::marker::Unpin;
use std::mem::replace;
use std::pin::Pin;
pub struct Lines<R> {
stream: R,
buf... | code_fim | hard | {
"lang": "rust",
"repo": "greenpdx/chat",
"path": "/async-server/src/lines.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let line_bytes = Vec::from(replace(&mut self.buf, VecDeque::new()));
String::from_utf8(line_bytes).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
}
}
impl<R: AsyncRead + Unpin> Stream for Lines<R> {
type Item = io::Result<String>;
fn poll_next(mut self: Pin<&mut Se... | code_fim | hard | {
"lang": "rust",
"repo": "greenpdx/chat",
"path": "/async-server/src/lines.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.buf.extend(&buf[0..length]);
}
Poll::Ready(Err(e)) => {
return Poll::Ready(Some(Err(e.into())));
}
Poll::Pending => {
return Poll::Pending;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "greenpdx/chat",
"path": "/async-server/src/lines.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(all(not(feature = "force-inprocess"), target_os = "macos"))]
mod macos;
#[cfg(all(not(feature = "force-inprocess"), target_os = "macos"))]
mod os {
pub use super::macos::*;
}
#[cfg(all(not(feature = "force-inprocess"), target_os = "windows"))]
mod windows;
#[cfg(all(not(feature = "force-inproce... | code_fim | hard | {
"lang": "rust",
"repo": "servo/ipc-channel",
"path": "/src/platform/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(all(not(feature = "force-inprocess"), target_os = "windows"))]
mod windows;
#[cfg(all(not(feature = "force-inprocess"), target_os = "windows"))]
mod os {
pub use super::windows::*;
}
#[cfg(any(
feature = "force-inprocess",
target_os = "android",
target_os = "ios",
target_os = "w... | code_fim | medium | {
"lang": "rust",
"repo": "servo/ipc-channel",
"path": "/src/platform/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: servo/ipc-channel path: /src/platform/mod.rs
// Copyright 2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MI... | code_fim | hard | {
"lang": "rust",
"repo": "servo/ipc-channel",
"path": "/src/platform/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `DONE` reader - This bit is set to 1 when an A/D conversion completes. It is cleared when this register is read."]
pub struct DONE_R(crate::FieldReader<bool, bool>);
impl DONE_R {
#[inline(always)]
pub(crate) fn new(bits: bool) -> Self {
DONE_R(crate:... | code_fim | hard | {
"lang": "rust",
"repo": "lpc-rs/lpc-pac",
"path": "/lpc11uxx/src/adc/dr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
impl R {
#[doc = "Bits 6:15 - When DONE is 1, this field contains a binary fraction representing the voltage on the ADn pin, divided by the voltage on the VREF pin. Zero in the field indicates that the voltage on the ADn pin was less than, equal to, or close to that on VREF, wh... | code_fim | hard | {
"lang": "rust",
"repo": "lpc-rs/lpc-pac",
"path": "/lpc11uxx/src/adc/dr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lpc-rs/lpc-pac path: /lpc11uxx/src/adc/dr.rs
#[doc = "Register `DR%s` reader"]
pub struct R(crate::R<DR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<DR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<DR_SPEC>> for... | code_fim | hard | {
"lang": "rust",
"repo": "lpc-rs/lpc-pac",
"path": "/lpc11uxx/src/adc/dr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gabriel-araujjo/entrepixels path: /src/bitmap/pixel.rs
// Only support BI_RGB and BI_BITFIELDS are current supported
use std::vec::Vec;
use std::rc::Rc;
use std::cell::RefCell;
use std::result::Result;
use std::io::Cursor;
use std::clone::Clone;
use super::super::error::Error;
use super::super:... | code_fim | hard | {
"lang": "rust",
"repo": "gabriel-araujjo/entrepixels",
"path": "/src/bitmap/pixel.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// get the pixel value
pub fn value(&mut self) -> Result<u32, Error> {
if ! self.value_already_read {
self.value_already_read = true;
let mut buf = self.bitmap_data.borrow_mut();
// seek offset (in bits)
try!(buf.seek(BitSeekFrom::Start(se... | code_fim | hard | {
"lang": "rust",
"repo": "gabriel-araujjo/entrepixels",
"path": "/src/bitmap/pixel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(0u, 10000000) {
Gc::new(i);
if i % 100000 == 0 {
println!("Heap size = {}", heap_size());
}
}
0
}<|fim_prefix|>// repo: swgillespie/boehm-rs path: /examples/example.rs
extern crate boehm = "boehm-rs";
use boehm::{init, Gc, heap_size};
<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "swgillespie/boehm-rs",
"path": "/examples/example.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swgillespie/boehm-rs path: /examples/example.rs
extern crate boehm = "boehm-rs";
use boehm::{init, Gc, heap_size};
<|fim_suffix|> for i in range(0u, 10000000) {
Gc::new(i);
if i % 100000 == 0 {
println!("Heap size = {}", heap_size());
}
}
0
}<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "swgillespie/boehm-rs",
"path": "/examples/example.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foxfriends/lumber path: /src/parser/mod.rs
//! Handles parsing of Lumber source files.
#![allow(clippy::upper_case_acronyms)]
<|fim_suffix|>impl Parser {
pub fn parse_module(source_code: &str) -> crate::Result<crate::Pairs> {
Ok(Self::parse(Rule::module, source_code)?)
}
p... | code_fim | medium | {
"lang": "rust",
"repo": "foxfriends/lumber",
"path": "/src/parser/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn parse_handle(source_code: &str) -> crate::Result<crate::Pairs> {
Ok(Self::parse(Rule::external_handle, source_code)?)
}
pub fn parse_question(source_code: &str) -> crate::Result<crate::Pairs> {
Ok(Self::parse(Rule::question, source_code)?)
}
}
#[cfg(test)]
mod test... | code_fim | hard | {
"lang": "rust",
"repo": "foxfriends/lumber",
"path": "/src/parser/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>(0x01 << 31)) | (((value as u32) & 0x01) << 31);
self.w
}
}
impl R {
#[doc = "Bit 0 - Selects source of WDT clock"]
#[inline(always)]
pub fn clksel(&self) -> CLKSEL_R {
CLKSEL_R::new((self.bits & 0x01) != 0)
}
#[doc = "Bit 31 - If this bit is set to one writing to t... | code_fim | hard | {
"lang": "rust",
"repo": "Erguotou/lpc-pac",
"path": "/lpc11uxx/src/wwdt/clksel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Erguotou/lpc-pac path: /lpc11uxx/src/wwdt/clksel.rs
#[doc = "Reader of register CLKSEL"]
pub type R = crate::R<u32, super::CLKSEL>;
#[doc = "Writer for register CLKSEL"]
pub type W = crate::W<u32, super::CLKSEL>;
#[doc = "Register CLKSEL `reset()`'s with value 0"]
impl crate::ResetValue for supe... | code_fim | hard | {
"lang": "rust",
"repo": "Erguotou/lpc-pac",
"path": "/lpc11uxx/src/wwdt/clksel.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: darrellp/firstlox path: /src/Parser/statement.rs
pub mod sstructs {
use crate::lox_error::lox_error::LoxError;
use crate::parser::parser::ParseReturn;
use crate::{build_struct, build_structs, exprType};
<|fim_suffix|> pub trait Accept {
fn accept(&self, visitor: &mut dyn ... | code_fim | medium | {
"lang": "rust",
"repo": "darrellp/firstlox",
"path": "/src/Parser/statement.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub trait Accept {
fn accept(&self, visitor: &mut dyn Visitor) -> Result<ParseReturn, LoxError>;
}
}<|fim_prefix|>// repo: darrellp/firstlox path: /src/Parser/statement.rs
pub mod sstructs {
use crate::lox_error::lox_error::LoxError;
use crate::parser::parser::ParseReturn;
use... | code_fim | medium | {
"lang": "rust",
"repo": "darrellp/firstlox",
"path": "/src/Parser/statement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn points_command(&self, privmsg: &PrivateMessage, command: &CommandData) -> Option<Message> {
let args = &command.args;
if args.is_empty() {
let points = match get_points(&self.connection, &privmsg.tags["user-id"]) {
Ok(points) => points,
E... | code_fim | hard | {
"lang": "rust",
"repo": "matijakevic/lordbornebot",
"path": "/modules/points/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matijakevic/lordbornebot path: /modules/points/src/lib.rs
extern crate env_logger;
#[macro_use]
extern crate log;
extern crate rusqlite;
#[macro_use]
extern crate lordbornebot_core;
mod data;
use data::*;
use lordbornebot_core::{CommandData, Config, Message, Module, PrivateMessage};
use rusqli... | code_fim | hard | {
"lang": "rust",
"repo": "matijakevic/lordbornebot",
"path": "/modules/points/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.is_empty() {
let points = match get_points(&self.connection, &privmsg.tags["user-id"]) {
Ok(points) => points,
Err(e) => {
warn!("{}", e);
return None;
}
};
Some(pri... | code_fim | hard | {
"lang": "rust",
"repo": "matijakevic/lordbornebot",
"path": "/modules/points/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.