text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>_wrapper_super!(EquippableItem, gfc::Item);<|fim_prefix|>// repo: whatisaphone/war-is-here path: /crates/aether/src/darksiders1/code/vigil/darksiders/world/actor/item/equippableitem.rs
use crate::darksiders1::gfc;
use darksider<|fim_middle|>s1_sys::target;
struct_wrapper!(EquippableItem, target::gfc__Eq... | code_fim | medium | {
"lang": "rust",
"repo": "whatisaphone/war-is-here",
"path": "/crates/aether/src/darksiders1/code/vigil/darksiders/world/actor/item/equippableitem.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyclopunk/labyrinth-brew-game path: /crates/lab-demo/src/systems.rs
use lab_world::*;
use lab_builder::prelude::*;
use lab_entities::prelude::*;
use crate::*;
use std::{cell::RefCell, rc::Rc, sync::Arc};
use lab_core::prelude::*;
// move to a resources file of some sort.
mod tiles {
pub con... | code_fim | hard | {
"lang": "rust",
"repo": "cyclopunk/labyrinth-brew-game",
"path": "/crates/lab-demo/src/systems.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tiles.interaction = TileInteraction { caller: |ctx| {
let open_sprite = Some(ctx.world_catalog.unwrap().components.get(tiles::BRICK_WINDOW_OPEN).unwrap().sprite.atlas_sprite);
// if a non-player hits a window, crash it if not block it
if let... | code_fim | hard | {
"lang": "rust",
"repo": "cyclopunk/labyrinth-brew-game",
"path": "/crates/lab-demo/src/systems.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PCouaillier/tachikoma path: /src/main.rs
/*
* This is a Rust implementation of the Settler starter bot for Halite-II
* For the most part, the code is organized like the Python version, so see that
* code for more information.
*/
mod hlt;
mod strategy;
use hlt::game::Game;
use hlt::logging:... | code_fim | medium | {
"lang": "rust",
"repo": "PCouaillier/tachikoma",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Initialize logging
let mut logger = Logger::new(game.my_id);
logger.log(&format!("Starting my {} bot!", name));
//run(&game, name);
run(&game, name, logger);
}<|fim_prefix|>// repo: PCouaillier/tachikoma path: /src/main.rs
/*
* This is a Rust implementation of the Settler starter... | code_fim | medium | {
"lang": "rust",
"repo": "PCouaillier/tachikoma",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Grissess/synfone2 path: /src/synth/noise.rs
use super::{
FactoryParameters, GenBox, GenFactoryError, Generator, GeneratorFactory, Parameters, Rate,
SampleBuffer,
};
use std::mem;
use ::rand::{Rng, SeedableRng, XorShiftRng};
#[derive(Debug)]
pub struct Noise {
pub rng: XorShiftRng,
... | code_fim | hard | {
"lang": "rust",
"repo": "Grissess/synfone2",
"path": "/src/synth/noise.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.buf
}
fn set_buffer(&mut self, buf: SampleBuffer) -> SampleBuffer {
mem::replace(&mut self.buf, buf)
}
}
pub struct NoiseFactory;
impl GeneratorFactory for NoiseFactory {
fn new(&self, params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> {
Ok(B... | code_fim | hard | {
"lang": "rust",
"repo": "Grissess/synfone2",
"path": "/src/synth/noise.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GeneratorFactory for NoiseFactory {
fn new(&self, params: &mut FactoryParameters) -> Result<GenBox, GenFactoryError> {
Ok(Box::new(Noise {
rng: XorShiftRng::from_seed(::rand::random()),
buf: SampleBuffer::new(params.env.default_buffer_size),
}))
}
}
pu... | code_fim | hard | {
"lang": "rust",
"repo": "Grissess/synfone2",
"path": "/src/synth/noise.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lams3/raytracing-rust path: /src/structures/transform.rs
use crate::structures::{Vec3, Point3, Quaternion, Ray};
#[derive(PartialEq, Clone, Copy, Debug, Default)]
pub struct Transform {
pub translation: Vec3,
pub rotation: Quaternion,
pub scale: Vec3
}
impl Transform {
pub fn n... | code_fim | hard | {
"lang": "rust",
"repo": "lams3/raytracing-rust",
"path": "/src/structures/transform.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn transform_point(&self, point: Point3) -> Point3 {
self.transform_vector(point) + self.translation
}
pub fn inverse_transform_ray(&self, ray: Ray) -> Ray {
Ray::with_time(
self.inverse_transform_point(ray.origin),
self.inverse_transform_vector(ra... | code_fim | hard | {
"lang": "rust",
"repo": "lams3/raytracing-rust",
"path": "/src/structures/transform.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if hand == crate::Result::Win { println!("Win!!"); }
else if hand == crate::Result::Lose { println!("Lose..."); }
else { println!("Draw"); }
}
}
#[derive(Debug,PartialEq)]
enum Hand { Rock, Scissors, Paper }
impl Hand {
fn from(&self, hand: i32) -> Hand {
match hand... | code_fim | hard | {
"lang": "rust",
"repo": "ytyaru/Rust.Janken.20190708185201",
"path": "/src/2/janken/src/main.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug,PartialEq)]
enum Result { Win, Lose, Draw }
impl crate::Result {
fn show(&self, hand: crate::Result) {
if hand == crate::Result::Win { println!("Win!!"); }
else if hand == crate::Result::Lose { println!("Lose..."); }
else { println!("Draw"); }
}
}
#[derive(De... | code_fim | hard | {
"lang": "rust",
"repo": "ytyaru/Rust.Janken.20190708185201",
"path": "/src/2/janken/src/main.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ytyaru/Rust.Janken.20190708185201 path: /src/2/janken/src/main.rs
/*
* じゃんけんゲーム。
* CreatedAt: 2019-07-08
*/
use rand::Rng;
use std::io::Write;
use std::io::stdout;
fn main() {
loop {
println!("じゃんけんゲーム");
print!("1:✊ 2:✌ 3:✋> ");
stdout().flush();
let playe... | code_fim | hard | {
"lang": "rust",
"repo": "ytyaru/Rust.Janken.20190708185201",
"path": "/src/2/janken/src/main.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f469/dma2d/opfccr.rs
#[doc = "Register `OPFCCR` reader"]
pub struct R(crate::R<OPFCCR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<OPFCCR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f469/dma2d/opfccr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `CM` writer - Color mode"]
pub struct CM_W<'a> {
w: &'a mut W,
}
impl<'a> CM_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: CM_A) -> &'a mut W {
unsafe { self.bits(variant.into()) }
}
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f469/dma2d/opfccr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as _
}
}
#[doc = "Field `CM` reader - Color mode"]
pub struct CM_R(crate::FieldReader<u8, CM_A>);
impl CM_R {
pub(crate) fn new(bits: u8) -> Self {
CM_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn varia... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f469/dma2d/opfccr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: D4nte/next-session path: /src/lib.rs
#![warn(
unused_extern_crates,
rust_2018_idioms,
missing_copy_implementations,
unused_qualifications,
unused_results,
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::fallible_impl_from,
clippy::cast_precision_loss,
clippy::cast_pos... | code_fim | medium | {
"lang": "rust",
"repo": "D4nte/next-session",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen(start)]
pub fn run_app() {
let _ = App::<Model>::new().mount_to_body();
}<|fim_prefix|>// repo: D4nte/next-session path: /src/lib.rs
#![warn(
unused_extern_crates,
rust_2018_idioms,
missing_copy_implementations,
unused_qualifications,
unused_results,
clippy::cast_possible_truncation... | code_fim | hard | {
"lang": "rust",
"repo": "D4nte/next-session",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print!("image 1 and 2 are {:.2}% equal -> acceptable difference {}%", images.get_similarity(), images.get_acpt_diff());
}<|fim_prefix|>// repo: Vinicios13/image-comparator path: /src/main.rs
mod image_comparator;
mod input_helper;
fn main() {
let image_path1 = input_helper::get_image_path(1usize)... | code_fim | medium | {
"lang": "rust",
"repo": "Vinicios13/image-comparator",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vinicios13/image-comparator path: /src/main.rs
mod image_comparator;
mod input_helper;
fn main() {
let image_path1 = input_helper::get_image_path(1usize);
let image_path2 = input_helper::get_image_path(2usize);
let acpt_diff = input_helper::get_acpt_diff();
<|fim_suffix|> p... | code_fim | medium | {
"lang": "rust",
"repo": "Vinicios13/image-comparator",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::main]
async fn main() -> Result<(), sqlx::Error> {
let mut conn = SqliteConnectOptions::from_str("basic_async.db")
.unwrap()
.create_if_missing(true)
.journal_mode(SqliteJournalMode::Off)
.synchronous(SqliteSynchronous::Off)
.connect()
.await?;
... | code_fim | hard | {
"lang": "rust",
"repo": "zorrock/fast-sqlite3-inserts",
"path": "/src/bin/basic_async.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zorrock/fast-sqlite3-inserts path: /src/bin/basic_async.rs
//! naive but async version
//!
//! This is very similar to basic.rs, just that it is asynchronous. I also wanted to try out sqlx
//! and rest of all the examples are sync and uses rusqlite
//!
//! previous: basic.rs
//! next: basic_prep... | code_fim | medium | {
"lang": "rust",
"repo": "zorrock/fast-sqlite3-inserts",
"path": "/src/bin/basic_async.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut v = vec![4, 6, 1, 8, 11, 13, 3];
bubble_sort(&mut v);
assert_eq!(v, vec![1, 3, 4, 6, 8, 11, 13]);
}
}<|fim_prefix|>// repo: a-bakos/rust-playground path: /archived-learning/hands-on-data-structures-and-algorithms-in-rust/p06-sorting/v1-sorting/src/lib.rs
use std::fmt::... | code_fim | medium | {
"lang": "rust",
"repo": "a-bakos/rust-playground",
"path": "/archived-learning/hands-on-data-structures-and-algorithms-in-rust/p06-sorting/v1-sorting/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wraithan/adventofcode-rs path: /2018/day05/src/lib.rs
#![deny(clippy::all)]
static ASCII_LOWER: [char; 26] = [
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z',
];
pub fn solve_puzzle_part_1(input: &str) ->... | code_fim | hard | {
"lang": "rust",
"repo": "wraithan/adventofcode-rs",
"path": "/2018/day05/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = "aA";
let expected = 0;
let result = solve_puzzle_part_1(input).unwrap();
assert_eq!(result, expected)
}
#[test]
fn example_02() {
let input = "abBA";
let expected = 0;
let result = solve_puzzle_part_1(input).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "wraithan/adventofcode-rs",
"path": "/2018/day05/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = "aabAAB";
let expected = 6;
let result = solve_puzzle_part_1(input).unwrap();
assert_eq!(result, expected)
}
#[test]
fn example_06() {
let input = "dabAcCaCBAcCcaDA";
let expected = 10;
let result = solve_puzzle_part_1(input)... | code_fim | hard | {
"lang": "rust",
"repo": "wraithan/adventofcode-rs",
"path": "/2018/day05/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bikeshedder/async-runtime path: /src/rt/tokio_03.rs
//! This module contains the Tokio 0.3 implementation of the Runtime trait.
use std::time::Duration;
<|fim_suffix|>/// Tokio 0.3 runtime
#[derive(Default, Clone, Copy)]
pub struct Runtime {}
impl crate::Runtime for Runtime {
fn sleep(&sel... | code_fim | easy | {
"lang": "rust",
"repo": "bikeshedder/async-runtime",
"path": "/src/rt/tokio_03.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Box::pin(tokio_03::time::sleep(duration))
}
fn spawn(&self, future: BoxFuture<'static, ()>) {
tokio_03::spawn(future);
}
}<|fim_prefix|>// repo: bikeshedder/async-runtime path: /src/rt/tokio_03.rs
//! This module contains the Tokio 0.3 implementation of the Runtime trait.
use ... | code_fim | medium | {
"lang": "rust",
"repo": "bikeshedder/async-runtime",
"path": "/src/rt/tokio_03.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hpmason/randomize path: /examples/32_rand.rs
#![no_std]
#![no_main]
#![feature(isa_attribute)]
/// This ROM prints number of ticks per set of random number generated
/// Used to compare the speed of the algo on the GBA, since GBA is a
/// 32 bit system
use gba::{debug::{DebugInterface, DebugLe... | code_fim | hard | {
"lang": "rust",
"repo": "Hpmason/randomize",
"path": "/examples/32_rand.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[instruction_set(arm::a32)]
extern "C" fn irq_handler_a32() {
// we just use this a32 function to jump over back to t32 code.
irq_handler_t32()
}
fn irq_handler_t32() {
// disable Interrupt Master Enable to prevent an interrupt during the handler
unsafe { IME.write(false) };
// read which int... | code_fim | hard | {
"lang": "rust",
"repo": "Hpmason/randomize",
"path": "/examples/32_rand.rs",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeandersonbc/rust-tutorial path: /4-rust-variables/src/main.rs
fn main() {
// By default, variables are immutable in Rust. As the doc says, "This
// is one of many nudges in Rust that encourages you to write your code
// in a way that takes advantage of the safety and easy concurren... | code_fim | medium | {
"lang": "rust",
"repo": "jeandersonbc/rust-tutorial",
"path": "/4-rust-variables/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Constants are always immutable. We use the keyword "const" instead
// of "let" for constants. You can't use "mut" and you have to provide
// the datatype, as well:
const MAX_VALUE : u32 = 100_000;
println!("MAX VALUE IS: {}", MAX_VALUE);
// NOTE: Shadowing is different from mak... | code_fim | hard | {
"lang": "rust",
"repo": "jeandersonbc/rust-tutorial",
"path": "/4-rust-variables/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> display: &HashMap<(isize, isize), isize>,
) -> Option<((isize, isize), (isize, isize))> {
let paddle = display
.iter()
.filter(|((x, y), value)| !(*x == -1 && *y == 0) && **value == 3)
.map(|(pos, _)| *pos)
.next()?;
let ball = display
.iter()
.f... | code_fim | hard | {
"lang": "rust",
"repo": "GKnirps/adventofcode-2019",
"path": "/day-13/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GKnirps/adventofcode-2019 path: /day-13/src/main.rs
use intcode::{parse, run_program, ReturnStatus, State};
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::{BufReader, Read};
use std::path::Path;
fn main() -> Result<(), String> {
let filename = env::args()
... | code_fim | hard | {
"lang": "rust",
"repo": "GKnirps/adventofcode-2019",
"path": "/day-13/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(8, sum(5, 3));
}
}<|fim_prefix|>// repo: FeodalherreN/codeabbey_rs path: /src/tasks/sum.rs
fn sum(a: i32, b: i32) -> i32 {
a + b
}
<|fim_middle|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sum_sums_two_integers() {
| code_fim | medium | {
"lang": "rust",
"repo": "FeodalherreN/codeabbey_rs",
"path": "/src/tasks/sum.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FeodalherreN/codeabbey_rs path: /src/tasks/sum.rs
fn sum(a: i32, b: i32) -> i32 {
a + b
}
<|fim_suffix|> assert_eq!(8, sum(5, 3));
}
}<|fim_middle|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sum_sums_two_integers() {
| code_fim | medium | {
"lang": "rust",
"repo": "FeodalherreN/codeabbey_rs",
"path": "/src/tasks/sum.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mohrezaei/num-integer path: /benches/power10.rs
#![feature(test)]
extern crate num_integer;
extern crate num_traits;
extern crate test;
use num_integer::log10;
use num_integer::is_power_of_ten;
use num_integer::Power10;
use num_traits::One;
use num_traits::PrimInt;
use num_traits::Zero;
use te... | code_fim | hard | {
"lang": "rust",
"repo": "mohrezaei/num-integer",
"path": "/benches/power10.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let u = v as u32;
u == POWER10_HASH_U8[(u & 7) as usize]
}
fn random_10000_vec_u8() -> Vec<u8> {
let mut v = Vec::new();
let mut x: u32 = 0;
let mut rng = SplitMix {
v: 0xCAFE_1234_FEED_5678,
};
while x < 10000 {
v.push(rng.next_u8());
x += 1;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "mohrezaei/num-integer",
"path": "/benches/power10.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lireer/ricochet-robot-solver path: /ricochet_board/src/positions.rs
use itertools::Itertools;
use std::{fmt, mem, ops};
use crate::{Board, Direction, Robot, DIRECTIONS, ROBOTS};
/// The type a position is encoded as.
///
/// Depending on the number of bits in a value, different positions on a ... | code_fim | hard | {
"lang": "rust",
"repo": "Lireer/ricochet-robot-solver",
"path": "/ricochet_board/src/positions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Sets `row` as the new row value.
fn set_row(&mut self, row: PositionEncoding) {
// get the column of the current position and add the new row information
self.encoded_position = (self.encoded_position & Self::COLUMN_FLAG) ^ row;
}
/// Moves the Position one field to `d... | code_fim | hard | {
"lang": "rust",
"repo": "Lireer/ricochet-robot-solver",
"path": "/ricochet_board/src/positions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
runner().ok(
"@import url(\"a.css\") handheld and (max-width: 400px);\n"
),
"@import url(\"a.css\") handheld and (max-width: 400px);\n"
);
}
#[test]
fn simple() {
assert_eq!(
runner().ok("@impor... | code_fim | hard | {
"lang": "rust",
"repo": "magikid/rsass",
"path": "/tests/spec/css/plain/import/conditions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: magikid/rsass path: /tests/spec/css/plain/import/conditions.rs
//! Tests auto-converted from "sass-spec/spec/css/plain/import/conditions.hrx"
#[allow(unused)]
fn runner() -> crate::TestRunner {
super::runner()
}
#[test]
fn both() {
assert_eq!(
runner().ok(
"@import ... | code_fim | hard | {
"lang": "rust",
"repo": "magikid/rsass",
"path": "/tests/spec/css/plain/import/conditions.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
runner().ok("@import \"a.css\" supports(a(b));\n"),
"@import \"a.css\" supports(a(b));\n"
);
}
#[test]
fn condition_negation() {
assert_eq!(
runner().ok("@import \"a.css\" supports(not (a: b));"),
"@import \"a.... | code_fim | hard | {
"lang": "rust",
"repo": "magikid/rsass",
"path": "/tests/spec/css/plain/import/conditions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kevina/rust path: /src/rustdoc/rustdoc.rs
/* rustdoc: rust -> markdown translator
* Copyright 2011 Google Inc.
*/
#[doc = "A single operation on the document model"]
type pass = fn~(srv: astsrv::srv, doc: doc::cratedoc) -> doc::cratedoc;
fn run_passes(
srv: astsrv::srv,
doc: doc::cra... | code_fim | hard | {
"lang": "rust",
"repo": "kevina/rust",
"path": "/src/rustdoc/rustdoc.rs",
"mode": "psm",
"license": "BSD-1-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let source_file = argv[1];
run(source_file);
}
#[doc = "Runs rustdoc over the given file"]
fn run(source_file: str) {
let default_name = source_file;
let srv = astsrv::mk_srv_from_file(source_file);
let doc = extract::from_srv(srv, default_name);
run_passes(srv, doc, [
pr... | code_fim | hard | {
"lang": "rust",
"repo": "kevina/rust",
"path": "/src/rustdoc/rustdoc.rs",
"mode": "spm",
"license": "BSD-1-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: caputomarcos/radius-rs path: /src/vendors/shiva.rs
/// Definitions for vendor Shiva, vendor value 166
use nom::IResult;
#[allow(unused_imports)]
use nom::number::streaming::{be_u64, be_u32, be_u16, be_u8};
#[allow(unused_imports)]
use std::net::{Ipv4Addr, Ipv6Addr};
use crate::radius::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "caputomarcos/radius-rs",
"path": "/src/vendors/shiva.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ShivaTypeOfService(pub u32);
#[allow(non_upper_case_globals)]
impl ShivaTypeOfService {
pub const Analog: ShivaTypeOfService = ShivaTypeOfService(1);
pub const DigitizedAnalog: ShivaTypeOfService = ShivaTypeOfService(2);
pub const Digital... | code_fim | hard | {
"lang": "rust",
"repo": "caputomarcos/radius-rs",
"path": "/src/vendors/shiva.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ShivaFunction(pub u32);
#[allow(non_upper_case_globals)]
impl ShivaFunction {
pub const Unknown: ShivaFunction = ShivaFunction(0);
pub const Dialin: ShivaFunction = ShivaFunction(1);
pub const Dialout: ShivaFunction = ShivaFunction(2);
... | code_fim | hard | {
"lang": "rust",
"repo": "caputomarcos/radius-rs",
"path": "/src/vendors/shiva.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheSpiritXIII/bote.rs path: /bote/src/lib.rs
use std::cell::RefCell;
/// A user of the chat.
pub trait User {
/// The nick name of the user.
fn nick(&self) -> &str {
self.user()
}
/// The user name of the user.
fn user(&self) -> &str;
}
/// A message type with a sender.
pub trait Sende... | code_fim | hard | {
"lang": "rust",
"repo": "TheSpiritXIII/bote.rs",
"path": "/bote/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Visits the message type.
fn visit<T: Visitor<Self>>(&self, visitor: &T);
}
/// A bot plugin for processing messages.
pub trait Plugin<T: Message> {
/// Runs the plugin with the given message. Returns true if this plugin stops proceeding plugins
/// from running.
fn run(&mut self, message: &T) ->... | code_fim | hard | {
"lang": "rust",
"repo": "TheSpiritXIII/bote.rs",
"path": "/bote/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `adpll_sdm_dither_en_2458` writer - "]
pub struct ADPLL_SDM_DITHER_EN_2458_W<'a> {
w: &'a mut W,
}
impl<'a> ADPLL_SDM_DITHER_EN_2458_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/rf/lo_config_2458.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/rf/lo_config_2458.rs
#[doc = "Register `lo_config_2458` reader"]
pub struct R(crate::R<LO_CONFIG_2458_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<LO_CONFIG_2458_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/rf/lo_config_2458.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println("");
println(fmt!("Informations of screen %?:", screen.root()));
println(fmt!(" width..........: %?", screen.width_in_pixels()));
println(fmt!(" height.........: %?", screen.height_in_pixels()));
println(fmt!(" white pixel....: %?", screen.white_pixel()));
println(fmt!("... | code_fim | hard | {
"lang": "rust",
"repo": "mibitzi/rust-xcb",
"path": "/examples/screen_info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let screen;
loop {
let n : Option<&xcb::xproto::Screen> = iter.next();
match n {
Some(s) => {
if i == screen_num {
screen = s;
break;
}
}
None => { fail!(~"Whut") }
}... | code_fim | medium | {
"lang": "rust",
"repo": "mibitzi/rust-xcb",
"path": "/examples/screen_info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mibitzi/rust-xcb path: /examples/screen_info.rs
extern mod xcb;
use std::iterator::{Iterator};
use xcb::base::*;
fn main() {
let (conn, screen_num) = Connection::connect();
<|fim_suffix|> println("");
println(fmt!("Informations of screen %?:", screen.root()));
println(fmt!(" w... | code_fim | hard | {
"lang": "rust",
"repo": "mibitzi/rust-xcb",
"path": "/examples/screen_info.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // "waste some time"
for i in 1024..1024 + 32 {
report(&p, i);
}
// should be no overflow at this point
report(&p, perf_csr.rf(utra::perfcounter::STATUS_OVERFLOW));
// register some more events
for i in 128..128 + 8 {
event0_csr.wfo(utra::event_source0::PERFEVE... | code_fim | hard | {
"lang": "rust",
"repo": "betrusted-io/gateware",
"path": "/sim/perfcounter/testbench/src/main.rs",
"mode": "spm",
"license": "CERN-OHL-1.2",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: betrusted-io/gateware path: /sim/perfcounter/testbench/src/main.rs
#![no_std]
#![no_main]
use utralib::{generated::*};
// allocate a global, unsafe static string. You can use this to force writes to RAM.
#[used] // This is necessary to keep DBGSTR from being optimized out
static mut DBGSTR: [u... | code_fim | hard | {
"lang": "rust",
"repo": "betrusted-io/gateware",
"path": "/sim/perfcounter/testbench/src/main.rs",
"mode": "psm",
"license": "CERN-OHL-1.2",
"source": "the-stack-v2"
} |
<|fim_suffix|> // this starts the performance counter
perf_csr.wfo(utra::perfcounter::RUN_RESET_RUN, 1);
// register some events
for i in 0..16 {
event2_csr.wfo(utra::event_source0::PERFEVENT_CODE, i * 4);
event3_csr.wfo(utra::event_source1::PERFEVENT_CODE, i * 4 + 1);
event4_csr... | code_fim | hard | {
"lang": "rust",
"repo": "betrusted-io/gateware",
"path": "/sim/perfcounter/testbench/src/main.rs",
"mode": "spm",
"license": "CERN-OHL-1.2",
"source": "the-stack-v2"
} |
<|fim_suffix|>tern "C" {
pub fn _sceNpDrmPackageDecrypt(
buffer: *mut crate::ctypes::c_void,
size: SceSize,
opt: *mut _sceNpDrmPackageDecrypt_opt,
) -> crate::ctypes::c_int;
}<|fim_prefix|>// repo: pheki/vitasdk-sys path: /src/psp2/npdrmpackage.rs
/* automatically generated by rust-bind... | code_fim | hard | {
"lang": "rust",
"repo": "pheki/vitasdk-sys",
"path": "/src/psp2/npdrmpackage.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pheki/vitasdk-sys path: /src/psp2/npdrmpackage.rs
/* automatically generated by rust-bindgen 0.65.1 */
#[allow(unused_imports)]
use crate::psp2::types::*;
#[allow(unused_imports)]
use crate::psp2common::types::*;
#[repr(C)]
pub struct _sceN<|fim_suffix|>tern "C" {
pub fn _sceNpDrmPackageDe... | code_fim | hard | {
"lang": "rust",
"repo": "pheki/vitasdk-sys",
"path": "/src/psp2/npdrmpackage.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>geCheck(
buffer: *const crate::ctypes::c_void,
size: SceSize,
zero: crate::ctypes::c_int,
identifier: crate::ctypes::c_uint,
) -> crate::ctypes::c_int;
}
extern "C" {
pub fn _sceNpDrmPackageDecrypt(
buffer: *mut crate::ctypes::c_void,
size: SceSize,
... | code_fim | medium | {
"lang": "rust",
"repo": "pheki/vitasdk-sys",
"path": "/src/psp2/npdrmpackage.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let now = Instant::now();
let matches = App::new(NAME)
.version(VERSION)
.author(AUTHOR)
.about(DESCRIPTION)
.args(&[
Arg::from_usage(
"<TEST> +required
'A nix expression containing testcases.'",
),
... | code_fim | hard | {
"lang": "rust",
"repo": "stoeffel/nix-test-runner",
"path": "/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stoeffel/nix-test-runner path: /src/main.rs
extern crate clap;
use clap::{value_t, App, Arg};
use failure::Error;
use std::fs::File;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::process;
use std::time::Instant;
static NAME: &str = env!("CARGO_PKG_NAME");
static VERSION:... | code_fim | hard | {
"lang": "rust",
"repo": "stoeffel/nix-test-runner",
"path": "/src/main.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn formatting(
result: &nix_test_runner::TestResult,
reporter: nix_test_runner::Reporter,
output: Option<&Path>,
now: Option<Instant>,
) -> Result<(), Error> {
let formatted = result.format(now.map(|instant| instant.elapsed()), reporter)?;
match output {
None => io::stdout(... | code_fim | hard | {
"lang": "rust",
"repo": "stoeffel/nix-test-runner",
"path": "/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nilstrieb/chip-8 path: /src/interpreter/mod.rs
//! # A CHIP-8 interpreter in Rust
//! resources
//! https://github.com/mattmikolay/chip-8/wiki/Mastering-CHIP%E2%80%908
//! http://devernay.free.fr/hacks/chip8/C8TECH10.HTM
//! https://en.wikipedia.org/wiki/CHIP-8
#[cfg(test)]
mod test;
use rand:... | code_fim | hard | {
"lang": "rust",
"repo": "Nilstrieb/chip-8",
"path": "/src/interpreter/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while vm.pc < program.len() as u16 {
let instruction = program[vm.pc as usize];
execute(instruction, &mut vm);
vm.next();
}
}
fn execute(instruction: u16, em: &mut Chip8Vm) {
match instruction {
0x00E0 => unimplemented!(), // clear display
0x00EE => { /... | code_fim | hard | {
"lang": "rust",
"repo": "Nilstrieb/chip-8",
"path": "/src/interpreter/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run(program: &[u16]) {
let mut vm = Chip8Vm::new();
vm.pc = 200;
while vm.pc < program.len() as u16 {
let instruction = program[vm.pc as usize];
execute(instruction, &mut vm);
vm.next();
}
}
fn execute(instruction: u16, em: &mut Chip8Vm) {
match instruc... | code_fim | hard | {
"lang": "rust",
"repo": "Nilstrieb/chip-8",
"path": "/src/interpreter/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let head = match parser::parse_Command(&s) {
Ok(h) => h,
Err(e) => {
println!("Couldn't parse '{}': {:#?}", s, e);
continue;
}
};
let result = eval::e... | code_fim | hard | {
"lang": "rust",
"repo": "skeleten/petlang",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skeleten/petlang path: /src/main.rs
#![feature(conservative_impl_trait)]
extern crate rustyline;
mod ast;
mod eval;
mod parser;
fn main() {
<|fim_suffix|> loop {
let rl = ed.readline(">> ");
match rl {
Ok(s) => {
ed.add_history_entry(&s);
... | code_fim | hard | {
"lang": "rust",
"repo": "skeleten/petlang",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pftbest/msp430g2553 path: /src/usci_a0_uart_mode/uca0irrctl.rs
#[doc = "Register `UCA0IRRCTL` reader"]
pub struct R(crate::R<UCA0IRRCTL_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<UCA0IRRCTL_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
... | code_fim | hard | {
"lang": "rust",
"repo": "pftbest/msp430g2553",
"path": "/src/usci_a0_uart_mode/uca0irrctl.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> W(writer)
}
}
#[doc = "Field `UCIRRXFE` reader - IRDA Receive Filter enable"]
pub type UCIRRXFE_R = crate::BitReader<bool>;
#[doc = "Field `UCIRRXFE` writer - IRDA Receive Filter enable"]
pub type UCIRRXFE_W<'a, const O: u8> =
crate::BitWriter<'a, u8, UCA0IRRCTL_SPEC, bool, O>;
#[doc = "Fi... | code_fim | hard | {
"lang": "rust",
"repo": "pftbest/msp430g2553",
"path": "/src/usci_a0_uart_mode/uca0irrctl.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input = File::open(&opts.input_file)?;
io::copy(&mut input, &mut writer)?;
Ok(())
}<|fim_prefix|>// repo: pineapplehunter/Append-Only-Storage path: /examples/save.rs
use structopt::StructOpt;
use hash_storage::storage::Storage;
use std::error::Error;
use std::fs::File;
use std::io;... | code_fim | medium | {
"lang": "rust",
"repo": "pineapplehunter/Append-Only-Storage",
"path": "/examples/save.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pineapplehunter/Append-Only-Storage path: /examples/save.rs
use structopt::StructOpt;
use hash_storage::storage::Storage;
use std::error::Error;
use std::fs::File;
use std::io;
<|fim_suffix|> let storage = Storage::new(&opts.out_dir);
let mut writer = storage.new_file_writer();
let... | code_fim | hard | {
"lang": "rust",
"repo": "pineapplehunter/Append-Only-Storage",
"path": "/examples/save.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x in consolidated_heap {
println!("Response {} - {} - {} - {} - {} - {}",
x.id,
x.score,
x.scorea,
x.scoreb,
x.scorec,
x.scored,
);
}
println!("Scanning memory with capacity {}...complete", SIZE);
... | code_fim | hard | {
"lang": "rust",
"repo": "justinrmiller/slide",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: justinrmiller/slide path: /src/main.rs
use std::collections::BinaryHeap;
use std::io;
use std::io::prelude::*;
use std::time::{Instant};
use std::thread;
use ordered_float::OrderedFloat;
use evmap::{ReadHandle, WriteHandle};
use rand::{Rng};
use uuid::Uuid;
const SIZE: u32 = 8 * 1024 * 1024;... | code_fim | hard | {
"lang": "rust",
"repo": "justinrmiller/slide",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (n, m) = {
let t = read_vec::<i64>();
(t[0], t[1])
};
let pmym = read_vec2::<i64>(m as u32);
let mut test = vec!["".to_string(); m as usize];
let mut sub: Vec<_> = pmym
.clone()
.into_iter()
.enumerate()
.map(|x| (x.1, x.0))
.... | code_fim | medium | {
"lang": "rust",
"repo": "helloooooo/prac-algo",
"path": "/atcoder/src/abc113c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (0..n).map(|_| read_vec()).collect()
}
fn main() {
let (n, m) = {
let t = read_vec::<i64>();
(t[0], t[1])
};
let pmym = read_vec2::<i64>(m as u32);
let mut test = vec!["".to_string(); m as usize];
let mut sub: Vec<_> = pmym
.clone()
.into_iter()
... | code_fim | medium | {
"lang": "rust",
"repo": "helloooooo/prac-algo",
"path": "/atcoder/src/abc113c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: helloooooo/prac-algo path: /atcoder/src/abc113c.rs
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()
}
<|fim_suffix|> let (n, m) = {
let t = read_vec::<i64>();
(t[0], t[1])
... | code_fim | hard | {
"lang": "rust",
"repo": "helloooooo/prac-algo",
"path": "/atcoder/src/abc113c.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bamorim/cos470-sistemas-distribuidos path: /t1/rust/src/bin/signal_receiver.rs
extern crate nix;
use std::convert::AsRef;
use nix::sys::signal;
use std::thread;
use std::time::Duration;
use std::fmt::format;
use std::env;
<|fim_suffix|>unsafe fn handle(s:i32, a: &signal::SigAction) {
let msg ... | code_fim | hard | {
"lang": "rust",
"repo": "bamorim/cos470-sistemas-distribuidos",
"path": "/t1/rust/src/bin/signal_receiver.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Block waiting
match env::args().nth(1) {
Some(x) => match x.as_ref() {
"block" => thread::park(),
"busy" => loop {},
_ => println!("Invalid block type"),
},
_ => println!("Need the block type argument"),
}
}
unsafe fn handle(s:i32, a: &signal::SigAction) {
let ms... | code_fim | hard | {
"lang": "rust",
"repo": "bamorim/cos470-sistemas-distribuidos",
"path": "/t1/rust/src/bin/signal_receiver.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tic str]> {
Some(self::words::WORDS)
}<|fim_prefix|>// repo: PSeitz/f4ker-rs path: /src/locales/de/lorem/mod.rs
mod words;
pub fn supplemental() -> Opti<|fim_middle|>on<&'static [&'static str]> {
None
}
pub fn words() -> Option<&'static [&'sta | code_fim | medium | {
"lang": "rust",
"repo": "PSeitz/f4ker-rs",
"path": "/src/locales/de/lorem/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PSeitz/f4ker-rs path: /src/locales/de/lorem/mod.rs
mod words;
pub fn supplemental() -> Opti<|fim_suffix|>
pub fn words() -> Option<&'static [&'static str]> {
Some(self::words::WORDS)
}<|fim_middle|>on<&'static [&'static str]> {
None
}
| code_fim | easy | {
"lang": "rust",
"repo": "PSeitz/f4ker-rs",
"path": "/src/locales/de/lorem/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn words() -> Option<&'static [&'static str]> {
Some(self::words::WORDS)
}<|fim_prefix|>// repo: PSeitz/f4ker-rs path: /src/locales/de/lorem/mod.rs
mod words;
pub fn supplemental() -> Opti<|fim_middle|>on<&'static [&'static str]> {
None
}
| code_fim | easy | {
"lang": "rust",
"repo": "PSeitz/f4ker-rs",
"path": "/src/locales/de/lorem/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fungust/rust-heed-v0.12 path: /heed/src/env.rs
anonicalize_path(path: &Path) -> io::Result<PathBuf> {
let canonical = path.canonicalize()?;
let url = url::Url::from_file_path(&canonical).map_err(|_e| io::Error::new(io::ErrorKind::Other, "URL passing error"))?;
url.to_file_path().map_... | code_fim | hard | {
"lang": "rust",
"repo": "fungust/rust-heed-v0.12",
"path": "/heed/src/env.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fungust/rust-heed-v0.12 path: /heed/src/env.rs
ise::event::SignalEvent;
use crate::flags::Flags;
use crate::mdb::error::mdb_result;
use crate::{Database, Error, PolyDatabase, Result, RoTxn, RwTxn};
use crate::mdb::ffi;
/// The list of opened environments, the value is an optional environment, ... | code_fim | hard | {
"lang": "rust",
"repo": "fungust/rust-heed-v0.12",
"path": "/heed/src/env.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Returns a struct that allows to wait for the effective closing of an environment.
pub fn env_closing_event<P: AsRef<Path>>(path: P) -> Option<EnvClosingEvent> {
let lock = OPENED_ENV.read().unwrap();
lock.get(path.as_ref()).map(|(_env, se)| EnvClosingEvent(se.clone()))
}
#[derive(Clone)]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "fungust/rust-heed-v0.12",
"path": "/heed/src/env.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: istaheev/x64_rust_kernel path: /src/bits.rs
// A try to implement bitwise operations on numbers using ranges
use core::ops::{Sub, BitOr, BitAnd, Not, Shl, Shr, Range};
use core::num::One;
pub fn get_single<T>(number: T, pos: usize) -> T where T: One + Sub<Output=T> + BitAnd<Output=T> + Shl<usi... | code_fim | hard | {
"lang": "rust",
"repo": "istaheev/x64_rust_kernel",
"path": "/src/bits.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // get bits
assert_eq!(0b010, get_range(num, 0..3));
assert_eq!(0b101, get_range(num, 1..4));
assert_eq!(0b1010101, get_range(num, 1..64));
assert_eq!(1, get_single(num, 5));
assert_eq!(0, get_single(num, 6));
// set bits
assert_eq!(0b11001100, set_range(num, 0..16, 0b1100... | code_fim | hard | {
"lang": "rust",
"repo": "istaheev/x64_rust_kernel",
"path": "/src/bits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> reverse_words(String::from("a good example"))
}<|fim_prefix|>// repo: DownsizeEngineering/tRust_problems path: /src/reverse_words.rs
pub fn run () -> String {
<|fim_middle|> pub fn reverse_words(s: String) -> String {
s.split_ascii_whitespace().rev().collect::<Vec<&str>>().join(" "... | code_fim | medium | {
"lang": "rust",
"repo": "DownsizeEngineering/tRust_problems",
"path": "/src/reverse_words.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DownsizeEngineering/tRust_problems path: /src/reverse_words.rs
pub fn run () -> String {
<|fim_suffix|> reverse_words(String::from("a good example"))
}<|fim_middle|> pub fn reverse_words(s: String) -> String {
s.split_ascii_whitespace().rev().collect::<Vec<&str>>().join(" "... | code_fim | medium | {
"lang": "rust",
"repo": "DownsizeEngineering/tRust_problems",
"path": "/src/reverse_words.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[command("get")]
#[description("Check the current log channel")]
#[usage("")]
pub async fn log_channel(ctx: &Context, msg: &Message) -> CommandResult {
match get!(ctx, Config, read).log_channel() {
Some(ch) => {
msg.channel_id
.say(&ctx, format!("Log channel: {}", ... | code_fim | medium | {
"lang": "rust",
"repo": "MIEIdiscord/Rusteze",
"path": "/src/commands/admin/log_channel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MIEIdiscord/Rusteze path: /src/commands/admin/log_channel.rs
use crate::{config::Config, get};
use serenity::{
framework::standard::{
macros::{command, group},
Args, CommandResult,
},
model::{channel::Message, id::ChannelId},
prelude::*,
};
<|fim_suffix|>#[comman... | code_fim | hard | {
"lang": "rust",
"repo": "MIEIdiscord/Rusteze",
"path": "/src/commands/admin/log_channel.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[command("set")]
#[description("Set the logging channel")]
#[usage("#channel_mention")]
pub async fn log_channel_set(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let channel_id = args.single::<ChannelId>().ok();
get!(ctx, Config, write).set_log_channel(channel_id)?;
msg.ch... | code_fim | hard | {
"lang": "rust",
"repo": "MIEIdiscord/Rusteze",
"path": "/src/commands/admin/log_channel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Id405/sea.0 path: /src/protocol/common.rs
use std::{convert::TryInto, error::Error, fmt};
use uuid::Uuid;
/*
Here I will describe the message format
a simple non parted message is described like this
\sea.0 RECIEVER SENDER message_type %{PAYLOAD}
an example exchange wherein JANLILI requests ... | code_fim | hard | {
"lang": "rust",
"repo": "Id405/sea.0",
"path": "/src/protocol/common.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let payload_parts = (payload.len() as f32 / payload_part_length as f32).ceil() as usize;
let message_parted_begin = Self {
message_type: MessageType::Sea1 {
action: "res".to_string(),
id: id.to_string(),
parts: payload_parts as u... | code_fim | hard | {
"lang": "rust",
"repo": "Id405/sea.0",
"path": "/src/protocol/common.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.view_in_map_j =
(self.view_in_map_j + shift.1)
.max(-self.view_in_map_width * frac)
.min(self.map_size as f64 - self.view_in_map_width * (1.0 - frac) - f64::EPSILON);
}
fn look_at(&mut self, pos: (f64, f64)) {
// Shift view
... | code_fim | hard | {
"lang": "rust",
"repo": "Ahrimanox/strategy_game",
"path": "/src/game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // let d = (released_map_cell[0] as i32 - active_unit_position[0] as i32).abs() + (released_map_cell[1] as i32 - active_unit_position[1] as i32).abs();
// if d <= active_unit.remaining_moves as i32 {
// // Make the mov... | code_fim | hard | {
"lang": "rust",
"repo": "Ahrimanox/strategy_game",
"path": "/src/game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ahrimanox/strategy_game path: /src/game.rs
1])
]
});
let unit_constraint = Box::new(
UnitConstraint {
unit_map: Rc::downgrade(&self.unit_ma... | code_fim | hard | {
"lang": "rust",
"repo": "Ahrimanox/strategy_game",
"path": "/src/game.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _: Vec<()> = futures::future::try_join_all(futs).await?;
fx_log_info!("client {} exited", node_name);
Ok(())
}
#[derive(StructOpt, Debug)]
enum Opt {
#[structopt(name = "weave-node")]
WeaveNode { listen_addr_0: String, listen_addr_1: String },
#[structopt(name = "fuchsia-node... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/weave/tests/weave_ip_forward/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let node_name_str = match opt {
Opt::WeaveNode { .. } => "weave_node",
Opt::FuchsiaNode => "fuchsia_node",
Opt::WlanNode { .. } => "wlan_node",
Opt::WpanNode { .. } => "wpan_node",
};
fuchsia_syslog::init_with_tags(&[node_name_str])?;
match opt {
Op... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/weave/tests/weave_ip_forward/src/main.rs",
"mode": "spm",
"license": "BSD-2-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.