text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: mchesser/platformer path: /src/game.rs
use anyhow::Context;
use macroquad::{
prelude::{Rect, UVec2, Vec2, WHITE},
texture::{draw_texture, load_texture, Texture2D},
window::{screen_height, screen_width},
};
use crate::{
bitfont::BitFont,
controller::{KeyboardController, NoneC... | code_fim | hard | {
"lang": "rust",
"repo": "mchesser/platformer",
"path": "/src/game.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let background = load_texture("./assets/background.png")
.await
.context("Failed to load background image")?;
let font_spritesheet =
load_texture("./assets/fonts/Victoria.png").await.context("Failed to load font")?;
let font = BitFont::new(32, 96... | code_fim | hard | {
"lang": "rust",
"repo": "mchesser/platformer",
"path": "/src/game.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> static TEST_STRING: &'static str = r#"Test string,
with multiple lines."#;
self.font.draw_text(Vec2::ZERO, TEST_STRING);
}
}
fn create_player(position: Vec2, spritesheet: Texture2D) -> Entity<Creature, KeyboardController> {
let fw = 64;
let fh = 128;
let idle = Animation {... | code_fim | hard | {
"lang": "rust",
"repo": "mchesser/platformer",
"path": "/src/game.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tessereth/kalaha-rust path: /src/ai/mod.rs
use std::fmt;
use super::Kalaha;
use super::player::Player;
#[cfg(test)]
mod tests;
pub trait AI: fmt::Debug {
fn choose(&self, game: &Kalaha) -> usize;
}
#[derive(Debug)]
pub struct FirstValid {}
impl AI for FirstValid {
fn choose(&self, ga... | code_fim | hard | {
"lang": "rust",
"repo": "tessereth/kalaha-rust",
"path": "/src/ai/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> game.bank(player) as i32 - game.bank(&player.next()) as i32
}
fn all_children(&self, game: &Kalaha) -> Vec<(usize, Kalaha)> {
let mut ret = Vec::new();
// Reverse the order because generally the later ponds are a better choice
// and we want to prune asap
f... | code_fim | hard | {
"lang": "rust",
"repo": "tessereth/kalaha-rust",
"path": "/src/ai/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct AlphaBeta {
depth: u32,
}
impl AlphaBeta {
pub fn new(depth: u32) -> AlphaBeta {
AlphaBeta { depth }
}
// See https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning
fn alpha_beta(&self, game: &Kalaha, player: &Player, depth: u32, alpha: i32, beta... | code_fim | hard | {
"lang": "rust",
"repo": "tessereth/kalaha-rust",
"path": "/src/ai/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kunjee17/test_sqlx path: /src/main.rs
use anyhow::Result;
use dotenv::dotenv;
use sqlx::{PgPool, Row, Done};
use sqlx::postgres::PgRow;
#[derive(sqlx::FromRow, Debug)]
struct Todo {
id : i64,
description: String,
done: bool
}
#[tokio::main]
async fn main() -> Result<()> {
doten... | code_fim | hard | {
"lang": "rust",
"repo": "kunjee17/test_sqlx",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Have to loop through all rows to print the values
println!("Todo query rows {:#?}", todos_query.len());
let todos_query_map = sqlx::query(select_query).try_map(|row : PgRow| Ok(Todo {
id : row.try_get("id")?,
description : row.try_get("description")?,
done : row.tr... | code_fim | hard | {
"lang": "rust",
"repo": "kunjee17/test_sqlx",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tomaka/futures-rs path: /futures-io/src/ready_tracker.rs
use std::io::{self, Read, Write};
use futures::{Poll, Task};
use futures::stream::Stream;
use Ready;
/// An I/O object which can be used to track the read/write readiness of an
/// underlying object.
///
/// Many I/O objects implement a... | code_fim | hard | {
"lang": "rust",
"repo": "tomaka/futures-rs",
"path": "/futures-io/src/ready_tracker.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn is_wouldblock<T>(res: &io::Result<T>) -> bool {
match *res {
Ok(_) => false,
Err(ref e) => e.kind() == io::ErrorKind::WouldBlock,
}
}
impl<S: Read> Read for ReadyTracker<S> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let res = self.inner.read(buf);
... | code_fim | hard | {
"lang": "rust",
"repo": "tomaka/futures-rs",
"path": "/futures-io/src/ready_tracker.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fqliao/rust_lab path: /custom_type_demo/src/structure/mod.rs
#[derive(Debug)]
struct Person<'a> {
name: &'a str,
age: u8,
}
// a unit struct
#[derive(Debug)]
struct Nil;
// a tuple struct
#[derive(Debug)]
struct Pair(i32, f32);
<|fim_suffix|> let pair = Pair(1, 1.2);
println!("... | code_fim | hard | {
"lang": "rust",
"repo": "fqliao/rust_lab",
"path": "/custom_type_demo/src/structure/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn rect_area(rect: &Rectangle) -> f32 {
// 嵌套解构
let Rectangle {
p1: Point { x: x1, y: y1 },
p2: Point { x: x2, y: y2 },
} = rect;
let area1 = (rect.p2.x - rect.p1.x) * (rect.p2.y - rect.p1.y);
println!("area1:{}", area1);
let area = (x2 - x1) * (y2 - y1);
area
}... | code_fim | hard | {
"lang": "rust",
"repo": "fqliao/rust_lab",
"path": "/custom_type_demo/src/structure/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut vec = Vec::new();
loop{
let mut a = rand::thread_rng().gen_range(0,101);
if a<91{
vec.push(a);
}
else{
break;
}
}
vec.sort();
println!("{:?}",vec);
}<|fim_prefix|>// repo: UmerMIB/rust_basic_examples path: /All task/src/... | code_fim | medium | {
"lang": "rust",
"repo": "UmerMIB/rust_basic_examples",
"path": "/All task/src/main_30.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: UmerMIB/rust_basic_examples path: /All task/src/main_30.rs
// task07
// Generate a Integer Vector until a certain condition is met
// Generate a random integer vector between 0 to 100 and keep on adding numbers to the vector until a number
// greater than 90 is generated. Once the vector is gene... | code_fim | medium | {
"lang": "rust",
"repo": "UmerMIB/rust_basic_examples",
"path": "/All task/src/main_30.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chfi/gfaestus path: /src/gfa.rs
pub mod load;
#[allow(unused_imports)]
use handlegraph::{
ha<|fim_suffix|>utablehandlegraph::*,
packed::*,
pathhandlegraph::*,
};
#[allow(unused_imports)]
use handlegraph::packedgraph::PackedGraph;<|fim_middle|>ndle::{Direction, Edge, Handle, NodeId}... | code_fim | medium | {
"lang": "rust",
"repo": "chfi/gfaestus",
"path": "/src/gfa.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>[allow(unused_imports)]
use handlegraph::packedgraph::PackedGraph;<|fim_prefix|>// repo: chfi/gfaestus path: /src/gfa.rs
pub mod load;
#[allow(unused_imports)]
use handlegraph::{
handle::{Direction, Edge, Handle, NodeId},
handlegraph::*,
m<|fim_middle|>utablehandlegraph::*,
packed::*,
... | code_fim | medium | {
"lang": "rust",
"repo": "chfi/gfaestus",
"path": "/src/gfa.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>utablehandlegraph::*,
packed::*,
pathhandlegraph::*,
};
#[allow(unused_imports)]
use handlegraph::packedgraph::PackedGraph;<|fim_prefix|>// repo: chfi/gfaestus path: /src/gfa.rs
pub mod load;
#[allow(unused_imports)]
use handlegraph::{
ha<|fim_middle|>ndle::{Direction, Edge, Handle, NodeId}... | code_fim | medium | {
"lang": "rust",
"repo": "chfi/gfaestus",
"path": "/src/gfa.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgottschlag/arietta-ymodem-boot path: /src/timer.rs
use core::intrinsics;
const PIT_MR: *mut u32 = 0xFFFFFE30 as *mut u32;
const PIT_MR_PITEN : u32 = 1 << 24;
const PIT_MR_PIV_MASK : u32 = 0xfffff;
const PIT_PIIR: *mut u32 = 0xFFFFFE3C as *mut u32;
<|fim_suffix|>impl Timer {
pub fn init... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/arietta-ymodem-boot",
"path": "/src/timer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn expired(&mut self) -> bool {
unsafe {
(intrinsics::volatile_load(PIT_PIIR) - self.start) >= self.duration
}
}
}<|fim_prefix|>// repo: mgottschlag/arietta-ymodem-boot path: /src/timer.rs
use core::intrinsics;
const PIT_MR: *mut u32 = 0xFFFFFE30 as *mut u32;
co... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/arietta-ymodem-boot",
"path": "/src/timer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `P4IES4` writer - P4IES4"]
pub struct P4IES4_W<'a> {
w: &'a mut W,
}
impl<'a> P4IES4_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[i... | code_fim | hard | {
"lang": "rust",
"repo": "chrismolli/msp430fr6972",
"path": "/src/port_3_4/p4ies.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `P4IES6` writer - P4IES6"]
pub struct P4IES6_W<'a> {
w: &'a mut W,
}
impl<'a> P4IES6_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[i... | code_fim | hard | {
"lang": "rust",
"repo": "chrismolli/msp430fr6972",
"path": "/src/port_3_4/p4ies.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrismolli/msp430fr6972 path: /src/port_3_4/p4ies.rs
#[doc = "Register `P4IES` reader"]
pub struct R(crate::R<P4IES_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<P4IES_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::conver... | code_fim | hard | {
"lang": "rust",
"repo": "chrismolli/msp430fr6972",
"path": "/src/port_3_4/p4ies.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Create a small signed integer (immediate).
fn create_small_s(&self, n: isize) -> Self::TermT;
/// Create a {} term.
fn create_empty_binary(&self) -> Self::TermT;
/// Get a proxy object for building a tuple.
fn create_tuple_builder(&mut self, sz: usize) -> Self::TupleBuilderT;
/// Get... | code_fim | hard | {
"lang": "rust",
"repo": "puzza007/ErlangRT",
"path": "/src/rt_defs/term_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get a proxy object for building a tuple.
fn create_tuple_builder(&mut self, sz: usize) -> Self::TupleBuilderT;
/// Get a proxy object for building a list (forward builder).
fn create_list_builder(&mut self) -> Self::ListBuilderT;
}<|fim_prefix|>// repo: puzza007/ErlangRT path: /src/rt_defs/t... | code_fim | hard | {
"lang": "rust",
"repo": "puzza007/ErlangRT",
"path": "/src/rt_defs/term_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: puzza007/ErlangRT path: /src/rt_defs/term_builder.rs
use num;
/// A generic trait used to hide Raw Tuple interface and decouple tuple parsing
/// from actual tuple implementation.
pub trait ITupleBuilder<TermT: Copy> {
unsafe fn set_element_base0(&mut self, i: usize, val: TermT);
fn make_... | code_fim | medium | {
"lang": "rust",
"repo": "puzza007/ErlangRT",
"path": "/src/rt_defs/term_builder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GeTechG/svgParser path: /src/parse_svg_path.rs
use crate::svg_parse;
pub struct Point {
path: Vec<Vec<String>>
}
impl Point {
pub fn new(path:&str) -> Point {
Point {
path: svg_parse::parse(path)
}
}
pub(crate) fn at(&self, pos:f64) -> [f64; 2] {
... | code_fim | hard | {
"lang": "rust",
"repo": "GeTechG/svgParser",
"path": "/src/parse_svg_path.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len >= pos {
let dv = (len - pos) / (len - prev[2]);
let npos = [
cur[0] * (1.0 - dv) + prev[0] * dv,
cur[1] * (1.0 - dv) + prev[1] * dv
];
... | code_fim | hard | {
"lang": "rust",
"repo": "GeTechG/svgParser",
"path": "/src/parse_svg_path.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jsantell/mentat path: /tx-parser/src/lib.rs
// Copyright 2016 Mozilla
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/licenses/LICENSE-2.0
//... | code_fim | hard | {
"lang": "rust",
"repo": "jsantell/mentat",
"path": "/tx-parser/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_lookup_ref() {
let input = [Value::Vector(vec![kw("db", "add"),
Value::Vector(vec![kw("test", "a1"),
Value::Text("v1".into())]),
kw("te... | code_fim | hard | {
"lang": "rust",
"repo": "jsantell/mentat",
"path": "/tx-parser/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn value_to_namespaced_keyword(val: &Value) -> Option<NamespacedKeyword> {
val.as_namespaced_keyword().map(|x| x.clone())
}
def_value_satisfy_parser_fn!(Tx, keyword, NamespacedKeyword, value_to_namespaced_keyword);
def_parser_fn!(Tx, entid, Value, Entid, input, {
Tx::<I>::integer()
.map(|... | code_fim | hard | {
"lang": "rust",
"repo": "jsantell/mentat",
"path": "/tx-parser/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = self.eval().sub(v0.data(), v1.data())?;
let value = self.make_node(result, vec![v0.input(), v1.input()], {
let id0 = v0.id();
let id1 = v1.id();
move |graph, store, gradient| {
... | code_fim | hard | {
"lang": "rust",
"repo": "ma2bd/gad",
"path": "/gad/src/arith.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ma2bd/gad path: /gad/src/arith.rs
// Copyright (c) Facebook, Inc. and its affiliates
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{
core::{CoreAlgebra, HasDims},
error::Result,
graph::{Config1, ConfigN, Graph, Value},
linked::LinkedAlgebra,
store::GradientStore,
... | code_fim | hard | {
"lang": "rust",
"repo": "ma2bd/gad",
"path": "/gad/src/arith.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn ones(&mut self, _v: &()) {}
#[inline]
fn neg(&mut self, _v: &()) {}
#[inline]
fn sub(&mut self, _v0: &(), _v1: &()) -> Result<()> {
Ok(())
}
#[inline]
fn mul(&mut self, _v0: &(), _v1: &()) -> Result<()> {
Ok(())
}
}
macro_rules! impl... | code_fim | hard | {
"lang": "rust",
"repo": "ma2bd/gad",
"path": "/gad/src/arith.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redirectionio/libredirectionio path: /src/marker/transformer/mod.rs
mod camelize;
mod dasherize;
mod lowercase;
mod replace;
mod slice;
mod underscorize;
mod uppercase;
<|fim_suffix|>pub trait Transform {
fn transform(&self, str: String) -> String;
}<|fim_middle|>pub use camelize::Camelize;... | code_fim | hard | {
"lang": "rust",
"repo": "redirectionio/libredirectionio",
"path": "/src/marker/transformer/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Transform {
fn transform(&self, str: String) -> String;
}<|fim_prefix|>// repo: redirectionio/libredirectionio path: /src/marker/transformer/mod.rs
mod camelize;
mod dasherize;
mod lowercase;
mod replace;
mod slice;
mod underscorize;
mod uppercase;
<|fim_middle|>pub use camelize::Camelize;... | code_fim | hard | {
"lang": "rust",
"repo": "redirectionio/libredirectionio",
"path": "/src/marker/transformer/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/googapis path: /googapis/genproto/google.cloud.videointelligence.v1p1beta1.rs
ShotChangeDetectionConfig {
/// Model to use for shot change detection.
/// Supported values: "builtin/stable" (the default if unset) and
/// "builtin/latest".
#[prost(string, tag = "1")]
... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.videointelligence.v1p1beta1.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>]
pub frames: ::prost::alloc::vec::Vec<ExplicitContentFrame>,
}
/// Annotation results for a single video.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VideoAnnotationResults {
/// Output only. Video file location in
/// [Google Cloud Storage](https://cloud.google.com/storage/).
... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.videointelligence.v1p1beta1.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>y to all users. In the
/// future this may be exclusively available as a premium feature."
#[prost(bool, tag = "5")]
pub enable_automatic_punctuation: bool,
/// Optional. For file formats, such as MXF or MKV, supporting multiple audio
/// tracks, specify up to two tracks. Default: trac... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.videointelligence.v1p1beta1.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gorylpe/rust-picipolo path: /src/game_logic/tests.rs
use crate::game_logic::{GameLogicImpl, GameLogic};
use crate::data::{Config, Input, GameMode};
use std::ops::Range;
<|fim_suffix|> let game_mode = GameMode::Small;
let mut game_logic = GameLogicImpl::new(Config {
range: Range {... | code_fim | medium | {
"lang": "rust",
"repo": "gorylpe/rust-picipolo",
"path": "/src/game_logic/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let game_mode = GameMode::Small;
let mut game_logic = GameLogicImpl::new(Config {
range: Range {start: 0, end: 100}
});
let initial_state = game_logic.initial_state();
let change_mode_input = Input::ChangeGameMode(game_mode.clone());
let after_state = game_logic.apply_input... | code_fim | medium | {
"lang": "rust",
"repo": "gorylpe/rust-picipolo",
"path": "/src/game_logic/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for Move {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let MoveType::Castling { is_queenside } = self.move_type {
if is_queenside {
return write!(f, "O-O-O");
} else {
return write!(f, "O-O");
}... | code_fim | hard | {
"lang": "rust",
"repo": "jacobgardner/chessAI",
"path": "/src/chess/chess_move.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let MoveType::Castling { is_queenside } = self.move_type {
if is_queenside {
return write!(f, "O-O-O");
} else {
return write!(f, "O-O");
}
}
write!(
f,
"{}{:?}{}{:?}{}{}",
s... | code_fim | hard | {
"lang": "rust",
"repo": "jacobgardner/chessAI",
"path": "/src/chess/chess_move.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacobgardner/chessAI path: /src/chess/chess_move.rs
use std::fmt;
use crate::chess::{PieceType, RankFile};
#[derive(PartialEq, Debug, Clone)]
pub enum MoveType {
Standard,
Castling { is_queenside: bool },
Promotion { promoted_to: PieceType },
EnPassant,
}
// NOTE: It is imposs... | code_fim | hard | {
"lang": "rust",
"repo": "jacobgardner/chessAI",
"path": "/src/chess/chess_move.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dinoocch/proc-macro-workshop path: /builder/src/lib.rs
extern crate proc_macro;
extern crate quote;
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};
fn is_optional(ty: &syn::Type) -> bool {
match ty {
syn::Type::Path(syn::TypePath { path: p,... | code_fim | hard | {
"lang": "rust",
"repo": "dinoocch/proc-macro-workshop",
"path": "/builder/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let set_fields = named_ast_fields.iter().map(|f| {
let ident = &f.ident;
let field_type = &f.ty;
let builder_path_repr = builder_path_to_match();
let meta_func = f.attrs.iter().find(|attr| attr.path == builder_path_repr);
if is_optional(field_type) {
... | code_fim | hard | {
"lang": "rust",
"repo": "dinoocch/proc-macro-workshop",
"path": "/builder/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.#ident = Some(#ident);
self
}
},
}
}
});
let appenders = named_ast_fields.iter().map(|f| {
let ident = &f.ident;
let field_type = &f.ty;
let builder_path_repr = bui... | code_fim | hard | {
"lang": "rust",
"repo": "dinoocch/proc-macro-workshop",
"path": "/builder/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KrutNA/volume-controller-ui path: /src/button/renderer.rs
use iced_wgpu::{button::StyleSheet, defaults, Defaults, Primitive, Renderer as WgpuRenderer};
use iced_native::{
Background, Color, Element, Layout, MouseCursor, Point,
Rectangle, Vector, Renderer as NativeRenderer,
};
use super::... | code_fim | hard | {
"lang": "rust",
"repo": "KrutNA/volume-controller-ui",
"path": "/src/button/renderer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
_defaults: &Defaults,
bounds: Rectangle,
cursor_position: Point,
is_pressed: bool,
style: &Box<dyn StyleSheet>,
content: &Element<'_, Message, Self>,
content_layout: Layout<'_>,
) -> Self::Output {
let is_mouse_over = b... | code_fim | hard | {
"lang": "rust",
"repo": "KrutNA/volume-controller-ui",
"path": "/src/button/renderer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
#[macro_export]
macro_rules! impl_behavior {
{ $(impl Behavior for $ty:ty;)* } =>
{
$(
#[typetag::serde]
impl $crate::Behavior for $ty {
fn insert(&self, entity: &mut hecs::EntityBuilder) {
entity.add(self.clone());
}
})*
... | code_fim | hard | {
"lang": "rust",
"repo": "bch29/simgame",
"path": "/types/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bch29/simgame path: /types/src/lib.rs
pub mod config;
pub mod mesh;
mod model;
pub use model::{
MeshKey, ModelDirectory, ModelKey, ModelRenderData, TextureDirectory, TextureKey,
};
pub use simgame_voxels::{VoxelData, VoxelDelta, VoxelDirectory};
<|fim_suffix|>}
#[macro_export]
macro_rules... | code_fim | hard | {
"lang": "rust",
"repo": "bch29/simgame",
"path": "/types/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn extend() {
let mut mem = InMemoryStorage::default();
mem.write(b"key1", b"val");
let len = mem.extend(b"key1", b"ue1");
assert_eq!(len, 6);
let x = mem.read(b"key1").unwrap();
assert_eq!(x, b"value1");
let len = mem.extend(b"key2", b"value222");
let x = mem.read(... | code_fim | hard | {
"lang": "rust",
"repo": "Dalot/RedisLess",
"path": "/redisless/src/storage/tests/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dalot/RedisLess path: /redisless/src/storage/tests/mod.rs
use std::{thread::sleep, time::Duration};
use crate::storage::Storage;
use crate::storage::{in_memory::InMemoryStorage, models::Expiry};
#[test]
fn test_in_memory_storage() {
let mut mem = InMemoryStorage::default();
mem.write(b... | code_fim | medium | {
"lang": "rust",
"repo": "Dalot/RedisLess",
"path": "/redisless/src/storage/tests/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ops = Op::read_all(&self.code);
let mut pos: usize = 0;
// TODO: figure out stateful iterators
for (op_index, op) in ops.iter().enumerate() {
op.print(&self, op_index, pos);
pos += op.cost();
}
}
pub fn get_line(&self, op_index: ... | code_fim | hard | {
"lang": "rust",
"repo": "mjvmroz/drool",
"path": "/src/chunk.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mjvmroz/drool path: /src/chunk.rs
use crate::op::Op;
use crate::value::Value;
use std::{u8, usize};
struct LineData {
ops: usize,
line: usize,
}
impl LineData {
fn new(line: usize) -> LineData {
LineData { line, ops: 1 }
}
fn tick(&mut self) {
self.ops += 1... | code_fim | hard | {
"lang": "rust",
"repo": "mjvmroz/drool",
"path": "/src/chunk.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn operation(&mut self, op: Op, op_line: usize) {
op.write_to(&mut self.code);
match self.lines.last_mut() {
None => self.lines.push(LineData::new(op_line)),
Some(last_line) => {
if last_line.line == op_line {
last_line.ti... | code_fim | hard | {
"lang": "rust",
"repo": "mjvmroz/drool",
"path": "/src/chunk.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> anyhow::Result<()> {
let config = Config::init()?;
smol::run(eventually_app_example::run(config))
}<|fim_prefix|>// repo: SINHASantos/eventually-rs path: /eventually-app-example/src/bin/eventually-app-example-api.rs
#![allow(missing_docs)]
use envconfig::Envconfig;
<|fim_middle|>us... | code_fim | easy | {
"lang": "rust",
"repo": "SINHASantos/eventually-rs",
"path": "/eventually-app-example/src/bin/eventually-app-example-api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/eventually-rs path: /eventually-app-example/src/bin/eventually-app-example-api.rs
#![allow(missing_docs)]
use envconfig::Envconfig;
use eventually_app_example::config::Config;
<|fim_suffix|> let config = Config::init()?;
smol::run(eventually_app_example::run(config))
}<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "SINHASantos/eventually-rs",
"path": "/eventually-app-example/src/bin/eventually-app-example-api.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>15),
Rgb(207, 127, 15),
Rgb(207, 135, 23),
Rgb(207, 135, 23),
Rgb(199, 135, 23),
Rgb(199, 143, 23),
Rgb(199, 151, 31),
Rgb(191, 159, 31),
Rgb(191, 159, 31),
Rgb(191, 167, 39),
Rgb(191, 167, 39),
Rgb(191, 175, 47),
... | code_fim | hard | {
"lang": "rust",
"repo": "filipedeschamps/doom-fire-algorithm",
"path": "/playground/rust-algorithm-render-in-terminal/src/palette.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Rgb(183, 175, 47),
Rgb(183, 183, 47),
Rgb(183, 183, 55),
Rgb(207, 207, 111),
Rgb(223, 223, 159),
Rgb(239, 239, 199),
Rgb(255, 255, 255),
];
return palette[index];
}
pub fn get_bg_color(index: usize) -> Bg<Rgb> {
return Bg(get_color(index))... | code_fim | hard | {
"lang": "rust",
"repo": "filipedeschamps/doom-fire-algorithm",
"path": "/playground/rust-algorithm-render-in-terminal/src/palette.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filipedeschamps/doom-fire-algorithm path: /playground/rust-algorithm-render-in-terminal/src/palette.rs
extern crate termion;
use termion::color::{Bg, Rgb};
fn get_color(index: usize) -> Rgb {
let palette: Vec<Rgb> = vec![
Rgb(7, 7, 7),
Rgb(31, 7, 7),
Rgb(47, 15, 7),... | code_fim | hard | {
"lang": "rust",
"repo": "filipedeschamps/doom-fire-algorithm",
"path": "/playground/rust-algorithm-render-in-terminal/src/palette.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /gtk4/src/file_chooser_dialog.rs
// Take a look at the license at the top of the repository in the LICENSE file.
use crate::prelude::*;
use crate::{FileChooserAction, FileChooserDialog, ResponseType, Widget, Window};
use glib::object::{Cast, IsA};
use glib::translate::*;
u... | code_fim | medium | {
"lang": "rust",
"repo": "zecakeh/gtk4-rs",
"path": "/gtk4/src/file_chooser_dialog.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for FileChooserDialog {
fn default() -> Self {
glib::object::Object::new::<Self>(&[])
.expect("Can't construct FileChooserDialog object with default parameters")
}
}<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /gtk4/src/file_chooser_dialog.rs
// Take a look at the... | code_fim | hard | {
"lang": "rust",
"repo": "zecakeh/gtk4-rs",
"path": "/gtk4/src/file_chooser_dialog.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> glib::object::Object::new::<Self>(&[])
.expect("Can't construct FileChooserDialog object with default parameters")
}
}<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /gtk4/src/file_chooser_dialog.rs
// Take a look at the license at the top of the repository in the LICENSE file.
use ... | code_fim | hard | {
"lang": "rust",
"repo": "zecakeh/gtk4-rs",
"path": "/gtk4/src/file_chooser_dialog.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tx.execute(
"create table if not exists record_messages (
position_lat integer,
position_long integer,
speed float,
distance float,
elevation float,
heart_rate integer,
timestamp dateti... | code_fim | hard | {
"lang": "rust",
"repo": "stadelmanma/garmin-run-tracker",
"path": "/garmin_run_tracker/src/db/schema.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tx.execute(
"create table if not exists lap_messages (
start_position_lat integer,
start_position_long integer,
start_elevation float,
end_position_lat integer,
end_position_long integer,
end_elevation floa... | code_fim | hard | {
"lang": "rust",
"repo": "stadelmanma/garmin-run-tracker",
"path": "/garmin_run_tracker/src/db/schema.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stadelmanma/garmin-run-tracker path: /garmin_run_tracker/src/db/schema.rs
use super::{db_path, open_db_connection};
use log::debug;
use rusqlite::{params, Result};
/// Create the database and required tables
pub fn create_database() -> Result<()> {
let db = db_path();
if db.exists() {
... | code_fim | hard | {
"lang": "rust",
"repo": "stadelmanma/garmin-run-tracker",
"path": "/garmin_run_tracker/src/db/schema.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>, Setup,
WithIndexedProducer, WithProducer, WithSetup,
};
#[cfg(feature = "default-executor")]
pub use self::executor::DefaultExecutor;
#[cfg(feature = "rayon-executor")]
pub use self::executor::RayonExecutor;
#[cfg(feature = "sequential-executor")]
pub use self::executor::SequentialExecutor;
#[cfg(fe... | code_fim | hard | {
"lang": "rust",
"repo": "Bergmann89/asparit",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bergmann89/asparit path: /src/lib.rs
mod core;
mod executor;
mod iter;
mod misc;
mod std;
pub use self::core::{
Consumer, Driver, Executor, ExecutorCallback, Folder, FromParallelIterator,
IndexedParallelIterator, IndexedProducer, IndexedProducerCallback, IntoParallelIterator,
IntoPa... | code_fim | hard | {
"lang": "rust",
"repo": "Bergmann89/asparit",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // roll back our first transactions that actually contains something
changeset.rollback_transaction().unwrap();
assert_eq!(changeset.transaction_depth(), 1);
let rolled_back: Changes = vec![
(b"key0", (Some(b"val0-1"), vec![1, 10])),
(b"key1", (Some(b"val1"), vec![1])),
(b"key42", (Some(... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/primitives/state-machine/src/overlayed_changes/changeset.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl OverlayedChangeSet {
/// Get a mutable reference for a value.
///
/// Can be rolled back or committed when called inside a transaction.
#[must_use = "A change was registered, so this value MUST be modified."]
pub fn modify(
&mut self,
key: StorageKey,
init: impl Fn() -> StorageValue,
at_... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/primitives/state-machine/src/overlayed_changes/changeset.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/substrate path: /primitives/state-machine/src/overlayed_changes/changeset.rs
:Hash,
};
const PROOF_OVERLAY_NON_EMPTY: &str = "\
An OverlayValue is always created with at least one transaction and dropped as soon
as the last transaction is removed; qed";
type DirtyKeysSets<K> = Sma... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/primitives/state-machine/src/overlayed_changes/changeset.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expr = match class {
ImageClass::Sampled | ImageClass::Multisampled => {
let ms = match class {
crate::ImageClass::Multisampled => true,
_ => false,
};
//TODO: fix t... | code_fim | hard | {
"lang": "rust",
"repo": "monocodus-demonstrations/naga",
"path": "/src/back/glsl.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: monocodus-demonstrations/naga path: /src/back/glsl.rs
size: columns,
}),
),
TypeInner::Array { base, .. } => (
Cow::Owned(format!("{}[{}]", base_expr, index)),
module.borrow_type(base),
... | code_fim | hard | {
"lang": "rust",
"repo": "monocodus-demonstrations/naga",
"path": "/src/back/glsl.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: monocodus-demonstrations/naga path: /src/back/glsl.rs
let expr = match class {
ImageClass::Sampled | ImageClass::Multisampled => {
let ms = match class {
crate::ImageClass::Multisampled => true,
_ => fals... | code_fim | hard | {
"lang": "rust",
"repo": "monocodus-demonstrations/naga",
"path": "/src/back/glsl.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marmistrz/wasi-misc-tests path: /src/utils.rs
use crate::wasi::*;
use libc;
pub fn create_dir(dir_fd: libc::__wasi_fd_t, dir_name: &str) {
let status = wasi_path_create_directory(dir_fd, dir_name);
assert_eq!(status, libc::__WASI_ESUCCESS, "creating a directory");
}
pub fn cleanup_dir(... | code_fim | hard | {
"lang": "rust",
"repo": "marmistrz/wasi-misc-tests",
"path": "/src/utils.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Create an empty file with the given name.
pub fn create_file(dir_fd: libc::__wasi_fd_t, file_name: &str) {
let mut file_fd = libc::__wasi_fd_t::max_value() - 1;
let status = wasi_path_open(
dir_fd,
0,
file_name,
libc::__WASI_O_CREAT,
0,
0,
... | code_fim | hard | {
"lang": "rust",
"repo": "marmistrz/wasi-misc-tests",
"path": "/src/utils.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForgottenMaster/aoc-2019 path: /aoc17.rs
42,1,7,1,42,11,48,1,1,1,48,1,1,1,48,1,1,1,48,7,46,1,3,1,46,1,3,1,5,11,9,7,14,1,3,1,5,1,9,1,9,1,5,1,14,1,3,1,5,1,9,1,9,1,5,1,14,1,3,1,5,1,9,1,9,1,5,1,10,11,3,1,9,1,9,1,5,1,10,1,3,1,3,1,1,1,3,1,9,1,9,1,5,1,10,1,3,11,9,1,9,1,5,1,10,1,7,1,1,1,13,1,9,1,5,1,6,1... | code_fim | hard | {
"lang": "rust",
"repo": "ForgottenMaster/aoc-2019",
"path": "/aoc17.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let CheckpointType::Output = self.run_to_next_checkpoint(&mut input, &mut output) {}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#[derive(Debug)]
enum SpaceType {
Empty,
Scaffold,
... | code_fim | hard | {
"lang": "rust",
"repo": "ForgottenMaster/aoc-2019",
"path": "/aoc17.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // part 2
{
const CHARACTER_LIMIT: usize = 20;
// from the coords, we need to determine the path the robot will take
// with the turns that are needed.
let instruction_sequence = coords.determine_instruction_sequence();
let mut all_subsequences = Vec::<... | code_fim | hard | {
"lang": "rust",
"repo": "ForgottenMaster/aoc-2019",
"path": "/aoc17.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xanecs/rust-mysql-simple path: /src/scramble/sha1.rs
use std::num::Wrapping;
use byteorder::ByteOrder;
use byteorder::ReadBytesExt;
use byteorder::WriteBytesExt;
use byteorder::BigEndian as BE;
static K1: u32 = 0x5A827999u32;
static K2: u32 = 0x6ED9EBA1u32;
static K3: u32 = 0x8F1BBCDCu32;
stat... | code_fim | hard | {
"lang": "rust",
"repo": "xanecs/rust-mysql-simple",
"path": "/src/scramble/sha1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn should_compute_sha1_hash() {
assert_eq!(sha1(&[115u8, 104u8, 97u8]),
vec![0xd8u8, 0xf4u8, 0x59u8, 0x03u8, 0x20u8, 0xe1u8,
0x34u8, 0x3au8, 0x91u8, 0x5bu8, 0x63u8, 0x94u8,
0x17u8, 0x06u8, 0x50u8, 0xa8u8, 0xf3u8, 0x... | code_fim | hard | {
"lang": "rust",
"repo": "xanecs/rust-mysql-simple",
"path": "/src/scramble/sha1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut output = Vec::with_capacity(20);
output.write_u32::<BE>(hash[0]);
output.write_u32::<BE>(hash[1]);
output.write_u32::<BE>(hash[2]);
output.write_u32::<BE>(hash[3]);
output.write_u32::<BE>(hash[4]);
output
}
#[cfg(test)]
mod test {
pub use super::sha1;
#[test]
... | code_fim | hard | {
"lang": "rust",
"repo": "xanecs/rust-mysql-simple",
"path": "/src/scramble/sha1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: neil-lobracco/tracker path: /src/server/src/scoring.rs
pub fn get_new_scores(player1_elo: f64, player2_elo: f64, player1_score: f64, player2_score: f64) -> (f64, f64) {
let r1 = player1_elo;
let r2 = player2_elo;
let e1 = 1_f64 / (1_f64 + (10_f64.powf((r2 - r1) / 400_f64)));
let ... | code_fim | medium | {
"lang": "rust",
"repo": "neil-lobracco/tracker",
"path": "/src/server/src/scoring.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn normalize_scores(p1score: f64, p2score: f64) -> (f64, f64) {
let sum = p1score + p2score;
(p1score / sum, p2score / sum)
}<|fim_prefix|>// repo: neil-lobracco/tracker path: /src/server/src/scoring.rs
pub fn get_new_scores(player1_elo: f64, player2_elo: f64, player1_score: f64, player2_score: f... | code_fim | medium | {
"lang": "rust",
"repo": "neil-lobracco/tracker",
"path": "/src/server/src/scoring.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let allowed_origins = AllowedOrigins::some_exact(&[ // 4.
"http://localhost:5001",
"http://127.0.0.1:5001",
"http://18.216.57.75:5001",
"http://0.0.0.0:5001",
]);
CorsOptions { // 5.
allowed_origins,
allowed_methods: vec![Method::Get].into_iter(... | code_fim | hard | {
"lang": "rust",
"repo": "erflod5/CovidGo",
"path": "/Rust/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erflod5/CovidGo path: /Rust/src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
extern crate rocket_contrib;
extern crate redis;
extern crate rocket_cors;
//ROCKET
//use rocket::response::content;
use rocket_contrib::serve::StaticFiles;
//cpu
use std::time... | code_fim | hard | {
"lang": "rust",
"repo": "erflod5/CovidGo",
"path": "/Rust/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Client::new()
.get("http://18.216.57.75:8002/cpu")
.send()
.and_then(|mut res| {
let body = mem::replace(res.body_mut(), Decoder::empty());
body.concat2()
})
.map_err(|err| println!("request error: {}", err))
.map(|body| {
... | code_fim | hard | {
"lang": "rust",
"repo": "erflod5/CovidGo",
"path": "/Rust/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matiasop/chess-board-representation path: /src/structs.rs
use std::cmp::PartialEq;
#[allow(dead_code)]
#[derive(Copy, Clone, Debug)]
pub enum PieceType {
Pawn,
Knight,
Bishop,
Rook,
Queen,
King,
}
#[derive(Copy, Clone)]
pub struct Piece {
pub piece_type: PieceType,
... | code_fim | medium | {
"lang": "rust",
"repo": "matiasop/chess-board-representation",
"path": "/src/structs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.x == other.x && self.y == other.y
}
}<|fim_prefix|>// repo: matiasop/chess-board-representation path: /src/structs.rs
use std::cmp::PartialEq;
#[allow(dead_code)]
#[derive(Copy, Clone, Debug)]
pub enum PieceType {
Pawn,
Knight,
Bishop,
Rook,
Queen,
King,
}
<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "matiasop/chess-board-representation",
"path": "/src/structs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: khwilson/advent2018 path: /dec06/src/main.rs
#[macro_use] extern crate lazy_static;
extern crate regex;
use std::env;
use std::process;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::HashMap;
use regex::Regex;
mod cmdline;
fn main() {
let args: Vec<String> =... | code_fim | hard | {
"lang": "rust",
"repo": "khwilson/advent2018",
"path": "/dec06/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Point {
fn new(x: i64, y: i64, num: usize) -> Point {
Point { x, y, num }
}
fn maxx(&self) -> i64 {
if self.x > self.y { return self.x } else { return self.y }
}
fn dist(&self, x: i64, y: i64) -> i64 {
(self.x - x).abs() + (self.y - y).abs()
}
}
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "khwilson/advent2018",
"path": "/dec06/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ExtBuilder::default()
.balances(vec![(ALICE, DOT, 100)])
.build()
.execute_with(|| {
assert_ok!(Tokens::set_lock(ID_1, DOT, &ALICE, 10));
assert_ok!(Tokens::set_lock(ID_2, DOT, &ALICE, 20));
assert_eq!(Tokens::locks(ALICE, DOT).len(), 2);
assert_ok!(Tokens::remove_lock(ID_2, DOT, &ALICE... | code_fim | hard | {
"lang": "rust",
"repo": "jimmychu0807/orml-exchange",
"path": "/pallets/orml/tokens/src/tests.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn currency_adapter_slashing_balance_should_work() {
ExtBuilder::default().build().execute_with(|| {
let _ = TreasuryCurrencyAdapter::deposit_creating(&TREASURY_ACCOUNT, 111);
assert_ok!(TreasuryCurrencyAdapter::reserve(&TREASURY_ACCOUNT, 69));
assert!(TreasuryCurrencyAdapter::slash(&TREASU... | code_fim | hard | {
"lang": "rust",
"repo": "jimmychu0807/orml-exchange",
"path": "/pallets/orml/tokens/src/tests.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jimmychu0807/orml-exchange path: /pallets/orml/tokens/src/tests.rs
a {
free: Balance::max_value(),
reserved: 0,
frozen: 0
}
)
.into_result(),
Err(ArithmeticError::Overflow.into())
);
// below ed
assert_eq!(
Tokens::deposit_consequence(
&CHARLIE,
DOT,... | code_fim | hard | {
"lang": "rust",
"repo": "jimmychu0807/orml-exchange",
"path": "/pallets/orml/tokens/src/tests.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn cnf_density(&mut self, cnf: CnfFormula, lvl: usize) -> f64 {
if cnf.is_empty() {
return 1.0;
}
if cnf.len() == 1 && cnf[0].is_empty() {
return 0.0;
}
if let Some(d) = self.cache.get(&cnf) {
return *d;
}
... | code_fim | medium | {
"lang": "rust",
"repo": "clinuxrulz/int_fact",
"path": "/src/density.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clinuxrulz/int_fact path: /src/density.rs
use std::collections::HashMap;
use crate::{CnfClause, CnfFormula, Lit, Var};
pub struct DensityCtx {
cnf: CnfFormula,
cache: HashMap<CnfFormula,f64>,
}
impl DensityCtx {
pub fn new<Cnf:Into<CnfFormula>>(cnf: Cnf) -> DensityCtx {
let... | code_fim | medium | {
"lang": "rust",
"repo": "clinuxrulz/int_fact",
"path": "/src/density.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pfg1_idx = registry.add_particle_force_generator(Box::new(pfg1));
registry.add_force_for_particle(p1_idx, pfg1_idx);
registry.add_force_for_particle(p2_idx, pfg1_idx);
println!("initial position and velocity");
println!("p1 position = {:?}", registry.get_particle(p1_idx).get_posi... | code_fim | hard | {
"lang": "rust",
"repo": "bumzack/godot",
"path": "/game-physics/examples/demos/particle_contact01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bumzack/godot path: /game-physics/examples/demos/particle_contact01.rs
use game_physics::prelude::*;
use math::prelude::*;
fn main() {
let mut registry = ParticleForceRegistry::new();
let anchor = Tuple4D::new_point(10.0, 10.0, 10.0);
let mut pfg1 = ParticleForceFakeSpring::new();... | code_fim | hard | {
"lang": "rust",
"repo": "bumzack/godot",
"path": "/game-physics/examples/demos/particle_contact01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..BUFFER_HEIGHT {
self.clear_row(i)
}
self.col = 0;
self.row = 0;
}
}
impl fmt::Write for VgaBuffer {
fn write_str(&mut self, s: &str) -> fmt::Result {
let mut writer = self.writer.lock();
for byte in s.bytes() {
wr... | code_fim | hard | {
"lang": "rust",
"repo": "JustAPerson/denuos",
"path": "/src/kernel/vga.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { self.buffer.as_mut() }
}
/// Moves all lines up one row and clears the last line
fn new_line(&mut self) {
const LAST_ROW: usize = BUFFER_HEIGHT - 1;
if self.row >= LAST_ROW {
for row in 0..LAST_ROW {
let buffer = self.buffer();
... | code_fim | hard | {
"lang": "rust",
"repo": "JustAPerson/denuos",
"path": "/src/kernel/vga.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.