text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let tasks = vec![
Task::FileOperation(docker_ignore_write(&run_context)),
Task::ExecCommand(build_docker),
Task::FileOperation(docker_ignore_remove(&run_context)),
Task::ExecCommand(build_caddy),
Task::ExecCommand(run_compose)
];
tasks
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "shakyShane/m2run",
"path": "/src/run/start.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shakyShane/m2run path: /src/run/start.rs
use context::RunContext;
use build;
use run;
use task::Task;
use build::php::docker_ignore_write;
use build::php::docker_ignore_remove;
<|fim_suffix|> let tasks = vec![
Task::FileOperation(docker_ignore_write(&run_context)),
Task::Exec... | code_fim | hard | {
"lang": "rust",
"repo": "shakyShane/m2run",
"path": "/src/run/start.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ELW::PSEL_3 => 3,
PSELW::PSEL_4 => 4,
PSELW::PSEL_5 => 5,
PSELW::PSEL_6 => 6,
PSELW::PSEL_7 => 7,
}
}
}
#[doc = r" Proxy"]
pub struct _PSELW<'a> {
w: &'a mut W,
}
impl<'a> _PSELW<'a> {
#[doc = r" Writes `variant` to the field"]
#[inli... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/cmp1/muxcr/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ferrous-systems/imxrt1052 path: /src/cmp1/muxcr/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u8,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u8,
}
impl super::MUXCR {
#[doc = r" Modifies the contents of the register"]
#[inline]
... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/cmp1/muxcr/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wolfgang/srl path: /src/input/terminal_input.rs
use console::Key;
use crate::input::Input;
use crate::input::move_direction::MoveDirection;
use crate::input::move_direction::MoveDirection::*;
pub struct TerminalInput {
pressed_key: Key
}
<|fim_suffix|> pub fn on_key(&mut self, key: Key... | code_fim | medium | {
"lang": "rust",
"repo": "wolfgang/srl",
"path": "/src/input/terminal_input.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.pressed_key == Key::Escape
}
fn wants_to_move(&self, direction: MoveDirection) -> bool {
match direction {
Left => {self.pressed_key == Key::ArrowLeft}
Right => {self.pressed_key == Key::ArrowRight}
Up => {self.pressed_key == Key::ArrowUp}
... | code_fim | medium | {
"lang": "rust",
"repo": "wolfgang/srl",
"path": "/src/input/terminal_input.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Input for TerminalInput {
fn quit_game(&self) -> bool {
self.pressed_key == Key::Escape
}
fn wants_to_move(&self, direction: MoveDirection) -> bool {
match direction {
Left => {self.pressed_key == Key::ArrowLeft}
Right => {self.pressed_key == Key::... | code_fim | medium | {
"lang": "rust",
"repo": "wolfgang/srl",
"path": "/src/input/terminal_input.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cbrewster/modulo path: /modulo/src/file/file_thread.rs
use ::core::core_msg::ToCoreThreadMsg;
use ::file::file_msg::{FileThreadId, ToFileThreadMsg, SaveResult};
use ::file::text::{Line, Point};
use std::fs::File;
use std::io::{Read, Write};
use std::path::PathBuf;
use std::sync::mpsc::{Sender, R... | code_fim | hard | {
"lang": "rust",
"repo": "cbrewster/modulo",
"path": "/modulo/src/file/file_thread.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line in data.lines() {
self.data.push(Line::new(line.into()));
}
info!("Loaded file from path: {:?}", path);
}
}
fn handle_replace_text(&mut self, begin: Point, end: Option<Point>, text: String) {
info!("Replacing text betwee... | code_fim | hard | {
"lang": "rust",
"repo": "cbrewster/modulo",
"path": "/modulo/src/file/file_thread.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kingkongtree/new-tee-os path: /hal/src/arch/x86_vm/tss.rs
use lazy_static::lazy_static;
use x86_64::{structures::tss::TaskStateSegment, VirtAddr};
pub const EMERGENCY_IST_INDEX: u16 = 0;
const EMERGENCY_STACK_SIZE: usize = 4096 * 4;
<|fim_suffix|> let stack_start = VirtAddr::from_pt... | code_fim | hard | {
"lang": "rust",
"repo": "kingkongtree/new-tee-os",
"path": "/hal/src/arch/x86_vm/tss.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stack_start = VirtAddr::from_ptr(unsafe { &KERNEL_INTR_STACK });
let stack_end = stack_start + EMERGENCY_STACK_SIZE;
stack_end
};
tss
};
}<|fim_prefix|>// repo: kingkongtree/new-tee-os path: /hal/src/arch/x86_vm/tss.rs
use lazy_static::lazy_stat... | code_fim | hard | {
"lang": "rust",
"repo": "kingkongtree/new-tee-os",
"path": "/hal/src/arch/x86_vm/tss.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stack_start = VirtAddr::from_ptr(unsafe { &EMERGENCY_STACK });
let stack_end = stack_start + EMERGENCY_STACK_SIZE;
stack_end
};
tss.privilege_stack_table[0] = {
// no cascaded interrupt here, so one stack per CPU is sufficient
... | code_fim | hard | {
"lang": "rust",
"repo": "kingkongtree/new-tee-os",
"path": "/hal/src/arch/x86_vm/tss.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ratijas/mess path: /mess-client/src/gui/view/status_bar.rs
use imports::*;
#[derive(Default)]
pub struct StatusBar<'a> {
message: &'a str,
error: bool
}
impl<'a> StatusBar<'a> {
pub fn message(mut self, message: &'a str) -> StatusBar<'a> {
self.message = message;
s... | code_fim | hard | {
"lang": "rust",
"repo": "ratijas/mess",
"path": "/mess-client/src/gui/view/status_bar.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Paragraph::default()
.text(help)
.raw(false)
.block(Block::default()
.border_style(Style::default().fg(Color::Reset))
.borders(border::LEFT | border::RIGHT | border::BOTTOM))
.draw(area, buf... | code_fim | hard | {
"lang": "rust",
"repo": "ratijas/mess",
"path": "/mess-client/src/gui/view/status_bar.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amv-dev/autoincrement path: /src/atomic.rs
use std::sync::atomic::{AtomicU16, AtomicU32, AtomicU64, AtomicU8, AtomicUsize};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Thread-safe container for keeping autoincrement counter
#[derive(Debug, Clone)]
#[cfg_attr(feature = "s... | code_fim | hard | {
"lang": "rust",
"repo": "amv-dev/autoincrement",
"path": "/src/atomic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn init_with(value: Self) -> AsyncIncrement<Self> {
AsyncIncrement(Self::into_atomic(value))
}
fn init_from(self) -> AsyncIncrement<Self> {
Self::init_with(self)
}
}
/// Only for type-safe purposes. You don't need to use this trait.
pub trait Atomic: Send + Sync + std::fm... | code_fim | hard | {
"lang": "rust",
"repo": "amv-dev/autoincrement",
"path": "/src/atomic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Epictetus/rust path: /src/test/compile-fail/lambda-mutate.rs
// error-pattern:assigning to upvar
// Make sure we can't write to upvars from lambdas
fn main() {
let i = 0;
let ctr = lambda () -<|fim_suffix|> log_err ctr();
log_err ctr();
log_err ctr();
log_err i;
}<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "Epictetus/rust",
"path": "/src/test/compile-fail/lambda-mutate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>> int { i = i + 1; ret i; };
log_err ctr();
log_err ctr();
log_err ctr();
log_err ctr();
log_err ctr();
log_err i;
}<|fim_prefix|>// repo: Epictetus/rust path: /src/test/compile-fail/lambda-mutate.rs
// error-pattern:assigning to upvar
// Make sure we can't write to up<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "Epictetus/rust",
"path": "/src/test/compile-fail/lambda-mutate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>listener.local_addr().unwrap().port();
println!(
"Starting server at {}",
format!("http://127.0.0.1:{}", port)
);
run(listener)?.await
}<|fim_prefix|>// repo: jonknapp/zero2prod path: /src/main.rs
use std::env;
use std::net::TcpListener;
use zero2prod::configuration::get_confi... | code_fim | hard | {
"lang": "rust",
"repo": "jonknapp/zero2prod",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonknapp/zero2prod path: /src/main.rs
use std::env;
use std::net::TcpListener;
use zero2prod::configuration::get_configuration;
use zero2prod::startup::run;
#[actix_web::main]
async fn main() -> std::i<|fim_suffix|>("PORT").unwrap_or(configuration.application_port.to_string())
);
let li... | code_fim | medium | {
"lang": "rust",
"repo": "jonknapp/zero2prod",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /library/core/tests/fmt/float.rs
#[test]
fn test_format_f64() {
assert_eq!("1", format!("{:.0}", 1.0f64));
assert_eq!("9", format!("{:.0}", 9.4f64));
assert_eq!("10", format!("{:.0}", 9.9f64));
assert_eq!("9.8", format!("{:.1}", 9.849f64));
assert_eq!("9.... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/library/core/tests/fmt/float.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("2e0", format!("{:.0e}", 1.5f32));
assert_eq!("2e0", format!("{:.0e}", 2.5f32));
assert_eq!("4e0", format!("{:.0e}", 3.5f32));
assert_eq!("4e0", format!("{:.0e}", 4.5f32));
assert_eq!("6e0", format!("{:.0e}", 5.5f32));
assert_eq!("1.28e2", format!("{:.2e}", 127.5f32));
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/library/core/tests/fmt/float.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wasanx25/yew-sample path: /src/components/drag_list.rs
use yew::{Component, ComponentLink, DragEvent, html, Html};
use yew::prelude::*;
use yew::utils::document;
use yew::web_sys::{Element, Node};
use wasm_bindgen::{JsCast, JsValue};
use js_sys::{Array};
use crate::contents::user::User;
const ... | code_fim | hard | {
"lang": "rust",
"repo": "wasanx25/yew-sample",
"path": "/src/components/drag_list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let drag_over_target = e.current_target().unwrap();
let drag_over_element = drag_over_target.dyn_ref::<Element>().unwrap();
drag_over_element.class_list().add(&class_name);
true
}
Msg::DragLeave(e) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "wasanx25/yew-sample",
"path": "/src/components/drag_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let class_name = Array::new();
class_name.set(0, JsValue::from(DRAG_OVER_CLASS_NAME));
let drag_over_target = e.current_target().unwrap();
let drag_over_element = drag_over_target.dyn_ref::<Element>().unwrap()... | code_fim | hard | {
"lang": "rust",
"repo": "wasanx25/yew-sample",
"path": "/src/components/drag_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: therahulkanyal/funky path: /ifds/src/keyboard.rs
#![allow(dead_code)]
use std::io;
use std::sync::mpsc;
use std::thread;
use termion::input::TermRead;
use termion::{event::Key};
<|fim_suffix|> Events { rx, input_handle }
}
pub fn next(&self) -> Result<Key, mpsc::RecvError> {
... | code_fim | hard | {
"lang": "rust",
"repo": "therahulkanyal/funky",
"path": "/ifds/src/keyboard.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Events { rx, input_handle }
}
pub fn next(&self) -> Result<Key, mpsc::RecvError> {
self.rx.recv()
}
}<|fim_prefix|>// repo: therahulkanyal/funky path: /ifds/src/keyboard.rs
#![allow(dead_code)]
use std::io;
use std::sync::mpsc;
use std::thread;
use termion::input::TermRead;... | code_fim | hard | {
"lang": "rust",
"repo": "therahulkanyal/funky",
"path": "/ifds/src/keyboard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/core/src/physical_optimizer/repartition.rs
itionsExec",
"AggregateExec: mode=Partial, gby=[], aggr=[]",
"ParquetExec: file_groups={2 groups: [[x:0..50], [x:50..100]]}, projection=[c1]",
];
let expected_csv = [
... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/core/src/physical_optimizer/repartition.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_optimized!(expected, plan, 2, true, 10);
}
Ok(())
}
#[test]
fn parallelization_two_partitions() -> Result<()> {
let plan_parquet = aggregate(parquet_exec_two_partitions());
let plan_csv = aggregate(csv_exec_two_partitions());
let exp... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/core/src/physical_optimizer/repartition.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/core/src/physical_optimizer/repartition.rs
nt(true).to_string();
let actual_lines = trim_plan_display(&plan);
assert_eq!(
&expected_lines, &actual_lines,
"\n\nexpected:\n\n{:#?}\nactual:\n\n{:#?... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/core/src/physical_optimizer/repartition.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let msg = ResponseMessage::<V, ()> {
success: true,
data: Some(self.data),
error: None,
};
Response::build_from(Json(msg).respond_to(req).unwrap()).ok()
}
}<|fim_prefix|>// repo: tactical-rudeirer/rudeirer.wtf path: /server/src/messages/resp... | code_fim | hard | {
"lang": "rust",
"repo": "tactical-rudeirer/rudeirer.wtf",
"path": "/server/src/messages/respresult.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'r, V> Responder<'r> for RespResult<V>
where
V: Serialize,
{
fn respond_to(self, req: &Request) -> response::Result<'r> {
let msg = ResponseMessage::<V, ()> {
success: true,
data: Some(self.data),
error: None,
};
Response::build_from... | code_fim | medium | {
"lang": "rust",
"repo": "tactical-rudeirer/rudeirer.wtf",
"path": "/server/src/messages/respresult.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tactical-rudeirer/rudeirer.wtf path: /server/src/messages/respresult.rs
use rocket::response;
use rocket::response::{Responder, Response};
use rocket::request::{Request};
use rocket_contrib::json::Json;
use serde::{Serialize};
use super::responsemessage::ResponseMessage;
#[derive(Debug)]
pub st... | code_fim | medium | {
"lang": "rust",
"repo": "tactical-rudeirer/rudeirer.wtf",
"path": "/server/src/messages/respresult.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: garfieldnate/ray_tracer_challenge path: /lib/src/pattern/gradient.rs
use crate::color::Color;
use crate::constants::black;
use crate::constants::white;
use crate::pattern::pattern::BasePattern;
use crate::pattern::pattern::Pattern;
use crate::tuple::Tuple;
#[derive(Clone, Debug, PartialEq)]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "garfieldnate/ray_tracer_challenge",
"path": "/lib/src/pattern/gradient.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::new(white(), black())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn gradient_linearly_interpolates_between_colors() {
let pattern = Gradient::default();
assert_eq!(pattern.color_at_world(point!(0, 0, 0)), white());
assert_eq!(
pat... | code_fim | hard | {
"lang": "rust",
"repo": "garfieldnate/ray_tracer_challenge",
"path": "/lib/src/pattern/gradient.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jvff/async-server path: /src/listening_server.rs
use std::io;
use std::sync::{Arc, Mutex};
use futures::{Async, Future, Poll};
use tokio_core::net::{TcpListener, TcpStream};
use tokio_proto::pipeline::ServerProto;
use tokio_service::NewService;
use super::active_server::ActiveServer;
use super... | code_fim | hard | {
"lang": "rust",
"repo": "jvff/async-server",
"path": "/src/listening_server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn service(
&mut self,
empty_service_error: AsyncServerError<S::Error, P::Error>,
) -> Result<S::Instance, AsyncServerError<S::Error, P::Error>> {
let new_service_result =
self.new_service.take().ok_or(empty_service_error)?;
new_service_result.map_err(A... | code_fim | hard | {
"lang": "rust",
"repo": "jvff/async-server",
"path": "/src/listening_server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gerrymanoim/advent_of_code path: /2021/rust/utils/src/lib.rs
use std::cmp::Ordering;
use std::io::{self, BufRead};
use std::{collections::HashMap, hash::Hash};
#[inline(always)]
pub fn stdin_to_int_vec() -> Vec<i32> {
io::stdin()
.lock()
.lines()
.map(|l| l.unwrap())... | code_fim | hard | {
"lang": "rust",
"repo": "gerrymanoim/advent_of_code",
"path": "/2021/rust/utils/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Ord for Point {
fn cmp(&self, other: &Self) -> Ordering {
// flip?
self.xy().cmp(&other.xy())
}
}
impl PartialOrd for Point {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
#[derive(Debug, Clone)]
pub struct Grid {
pub... | code_fim | hard | {
"lang": "rust",
"repo": "gerrymanoim/advent_of_code",
"path": "/2021/rust/utils/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn add_uv_sphere(
points: &mut Vec<Vec<Point3d>>,
normal2points: &mut Vec<Vec<Point3d>>,
center: f64,
rad: f64,
) {
let from = center - rad;
let step = 2_f64 * rad / (constants::SPHERE_PARTS - 1) as f64;
let mut solutions = Vec::with_capacity(constants::SPHERE_PARTS);
... | code_fim | hard | {
"lang": "rust",
"repo": "Justarone/bmstu-cg-course",
"path": "/src/lib/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> points.push(new_points);
normal2points.push(new_norm2points);
}
}
pub fn rotate_intersections(
pts: &[Point3d],
vecs_eps: &[Point3d],
step: usize,
) -> (Vec<Point3d>, Vec<Point3d>) {
let mut points = Vec::with_capacity(constants::DEGREES / step * 2);
let mut normal... | code_fim | hard | {
"lang": "rust",
"repo": "Justarone/bmstu-cg-course",
"path": "/src/lib/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Justarone/bmstu-cg-course path: /src/lib/utils.rs
use serde::{Deserialize, Serialize};
use std::env;
use std::f64;
use std::fs::File;
use std::io::BufReader;
use super::prelude::*;
pub fn solve_quad_eq(a: f64, b: f64, c: f64) -> (Option<f64>, Option<f64>) {
if relative_eq!(a, 0_f64) {
... | code_fim | hard | {
"lang": "rust",
"repo": "Justarone/bmstu-cg-course",
"path": "/src/lib/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, PartialEq)]
pub struct Field {
pub position: Pos,
pub alias: Option<Name>,
pub name: Name,
pub arguments: Vec<(Name, Value)>,
pub directives: Vec<Directive>,
pub selection_set: SelectionSet,
}
#[derive(Debug, Clone, PartialEq)]
pub struct FragmentSpread {
... | code_fim | hard | {
"lang": "rust",
"repo": "Mange/graphql-parser",
"path": "/src/query/ast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, PartialEq)]
pub enum VariableType {
NamedType(Name),
ListType(Box<VariableType>),
NonNullType(Box<VariableType>),
}
/// This represents integer number
///
/// But since there is no definition on limit of number in spec
/// (only in implemetation), we do a trick similar ... | code_fim | hard | {
"lang": "rust",
"repo": "Mange/graphql-parser",
"path": "/src/query/ast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mange/graphql-parser path: /src/query/ast.rs
//! Query Language Abstract Syntax Tree (AST)
//!
//! The types and fields here resemble official [graphql grammar] whenever it
//! makes sense for rust.
//!
//! [graphql grammar]: http://facebook.github.io/graphql/October2016/#sec-Appendix-Grammar-Su... | code_fim | hard | {
"lang": "rust",
"repo": "Mange/graphql-parser",
"path": "/src/query/ast.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nairyl/stronghold path: /stronghold-wasm/src/panic_hook/mod.rs
use wasm_bindgen::prelude::*;
use std::panic;
#[wasm_bindgen]
extern "C" {
type Error;
<|fim_suffix|>}
fn hook_impl(info: &panic::PanicInfo) {
let e = Error::new();
let stack = e.stack();
let er = js_sys::Error::... | code_fim | medium | {
"lang": "rust",
"repo": "nairyl/stronghold",
"path": "/stronghold-wasm/src/panic_hook/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn hook(info: &panic::PanicInfo) {
hook_impl(info);
}
#[inline]
pub fn set_once() {
use std::sync::Once;
static SET_HOOK: Once = Once::new();
SET_HOOK.call_once(|| {
panic::set_hook(Box::new(hook));
});
}<|fim_prefix|>// repo: nairyl/stronghold path: /stronghold-wasm/src/... | code_fim | hard | {
"lang": "rust",
"repo": "nairyl/stronghold",
"path": "/stronghold-wasm/src/panic_hook/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tailhook/trimmer path: /src/varmap.rs
use std::rc::Rc;
use std::mem::transmute;
use std::collections::HashMap;
use owning_ref::{ErasedRcRef, OwningRef, Erased};
use vars::{Variable, VarRef};
use render_error::DataError;
/// A set of variables passed to a template
//#[derive(Debug)]
pub struc... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/trimmer",
"path": "/src/varmap.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn set<'x, 'render>(ctx: &mut SubContext<'x, 'render>,
name: ErasedRcRef<str>,
value: VarRef<'render>)
{
ctx.local.insert(name, value);
}
pub fn get<'x, 'render>(ctx: &SubContext<'x, 'render>, name: &str)
-> Result<VarRef<'render>, DataError>
{
if let Some(value) = ctx.local.get(n... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/trimmer",
"path": "/src/varmap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, 'render: 'a> SubContext<'a, 'render> {
/// Create a new context by deriving (borrowing) this context
///
/// Variables can be overriden in the new context
pub fn from<'x>(parent: &'x Context<'render>) -> SubContext<'x, 'render> {
SubContext {
parent: Parent::Ro... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/trimmer",
"path": "/src/varmap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tmplt/rtic-scope path: /rtic-trace/src/tracing.rs
//! Tracing module, for use on the embedded target.
//!
//! TODO explain how it works
//!
//! Example usage:
//!
//! ```
//! #[app(device = stm32f4::stm32f401, peripherals = true, dispatchers = [EXTI1])]
//! mod app {
//! use cortex_m::asm;
/... | code_fim | hard | {
"lang": "rust",
"repo": "tmplt/rtic-scope",
"path": "/rtic-trace/src/tracing.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Assigns and consumes a DWT comparator for RTIC software task
/// tracing. The unit is indirectly utilized by [super::trace]. Any
/// changes to the unit after this function yields undefined
/// behavior, in regards to RTIC task tracing.
pub fn assign_dwt_unit(dwt: &Core::dwt::Compa... | code_fim | hard | {
"lang": "rust",
"repo": "tmplt/rtic-scope",
"path": "/rtic-trace/src/tracing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // enable tracing
dcb.enable_trace();
tpiu.set_swo_baud_rate(16_000_000, 115_200);
tpiu.set_trace_output_protocol(TraceProtocol::AsyncSWONRZ);
tpiu.enable_continuous_formatting(false); // drops ETM packets
dwt.enable_exception_tracing(true);
dwt.en... | code_fim | hard | {
"lang": "rust",
"repo": "tmplt/rtic-scope",
"path": "/rtic-trace/src/tracing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kot-Zakhar/webasm-3d-viewer path: /core/src/image.rs
on_buf = (0..width * height)
.map(|_| {
Pixel {
color: Color {
r: 0,
g: 0,
b: 0,
},
a: 255
}... | code_fim | hard | {
"lang": "rust",
"repo": "Kot-Zakhar/webasm-3d-viewer",
"path": "/core/src/image.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let model_camera_direction = camera_position - model_point;
let reflection_direction = direct_light_direction - 2. * (direct_light_direction).dot(&normal) * normal;
let mut gloss_not_powered = reflection_direction.normalize().dot(&model_camera_direction.no... | code_fim | hard | {
"lang": "rust",
"repo": "Kot-Zakhar/webasm-3d-viewer",
"path": "/core/src/image.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kot-Zakhar/webasm-3d-viewer path: /core/src/image.rs
= &[0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216];
#[wasm_bindgen]
impl Image {
pub fn new(width: u32, height: u32) -> Image {
let pixels = (0..width * height)
.map(|_| {
Pixel {
... | code_fim | hard | {
"lang": "rust",
"repo": "Kot-Zakhar/webasm-3d-viewer",
"path": "/core/src/image.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let builder = glutin::WindowBuilder::new()
.with_title("Raytracer".to_string())
.with_dimensions(1024, 768)
.with_vsync();
let (window, mut device, mut factory, main_color, main_depth)
= gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder);
... | code_fim | medium | {
"lang": "rust",
"repo": "dowoncha/canvas-rs",
"path": "/src/bin/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dowoncha/canvas-rs path: /src/bin/main.rs
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(unused_mut)]
#[macro_use]
extern crate gfx;
extern crate gfx_window_glutin;
extern crate glutin;
use gfx::Device;
pub type ColorFormat = gfx::format::Rgba8;
pub type DepthFormat = gfx::format... | code_fim | hard | {
"lang": "rust",
"repo": "dowoncha/canvas-rs",
"path": "/src/bin/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut idx: usize = 0;
loop {
let c1 = char_list[idx];
let c2 = char_list[idx+1];
if is_relevant_pair(c1, c2) {
removed_chars.push(c1);
removed_chars.push(c2);
idx += 2;
} else {
new_char_list.push(c1);
i... | code_fim | hard | {
"lang": "rust",
"repo": "Quantum-Desmond/Advent-of-Code-2018",
"path": "/src/aoc_problems/day_5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Quantum-Desmond/Advent-of-Code-2018 path: /src/aoc_problems/day_5.rs
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
extern crate chrono;
use self::chrono::prelude::*;
#[derive(Debug)]
struct GuardEvent {
dt: DateTime<Utc>,
event: String
}
impl GuardEvent {... | code_fim | hard | {
"lang": "rust",
"repo": "Quantum-Desmond/Advent-of-Code-2018",
"path": "/src/aoc_problems/day_5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use specs::Join;
for (entity, energy, ..) in (&*entities, &mut energy, &actives).join() {
energy.tick();
debug!("energy for {:?} = {}", entity, energy.current);
}
}
}<|fim_prefix|>// repo: stpyramids/stpyr path: /stpyr/src/energy.rs
use super::action::... | code_fim | hard | {
"lang": "rust",
"repo": "stpyramids/stpyr",
"path": "/stpyr/src/energy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct EnergyS;
impl<'a> System<'a> for EnergyS {
type SystemData = (
Entities<'a>,
ReadStorage<'a, ActiveFlag>,
WriteStorage<'a, Energy>,
);
fn run(&mut self, (entities, actives, mut energy): Self::SystemData) {
use specs::Join;
for (entity, ener... | code_fim | medium | {
"lang": "rust",
"repo": "stpyramids/stpyr",
"path": "/stpyr/src/energy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stpyramids/stpyr path: /stpyr/src/energy.rs
use super::action::ActiveFlag;
use specs::prelude::*;
#[derive(Component, Debug)]
#[storage(VecStorage)]
pub struct Energy {
pub per_tick: f32,
pub current: f32,
}
impl Energy {
pub fn new(per_tick: f32) -> Energy {
Energy {
... | code_fim | hard | {
"lang": "rust",
"repo": "stpyramids/stpyr",
"path": "/stpyr/src/energy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustyrazorblade/TotalRecallDB path: /src/db/mod.rs
extern crate nom;
pub mod database;
pub mod stream;
pub mod row;
pub mod server;
pub mod schema;
pub mod value;
pub mod parser;
pub mod storage;
<|fim_suffix|>pub use self::database::Database;
pub use self::schema::Schema;<|fim_middle|>mod tes... | code_fim | easy | {
"lang": "rust",
"repo": "rustyrazorblade/TotalRecallDB",
"path": "/src/db/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::database::Database;
pub use self::schema::Schema;<|fim_prefix|>// repo: rustyrazorblade/TotalRecallDB path: /src/db/mod.rs
extern crate nom;
pub mod database;
pub mod stream;
pub mod row;
pub mod server;
pub mod schema;
pub mod value;
pub mod parser;
pub mod storage;
<|fim_middle|>mod tes... | code_fim | easy | {
"lang": "rust",
"repo": "rustyrazorblade/TotalRecallDB",
"path": "/src/db/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if command.is_rand_assign() {
Command::exec_command_rand_assignee_to_pr(
pull_request_event.pull_request.number,
pull_request_event.repository,
)
.await?;
return Ok(());
}
Ok(())
}<|fim_prefix|>// repo: k-nasa/ai-chan path: /src/request... | code_fim | hard | {
"lang": "rust",
"repo": "k-nasa/ai-chan",
"path": "/src/request_handle/handle_pull_request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let parse_result = Command::parse_command(&pull_request_event.pull_request.body);
let owners = Owners::from_repository(&pull_request_event.repository.full_name).await?;
if owners.rand_assigne() && parse_result.is_err() {
Command::exec_command_rand_assignee_to_pr(
pull_req... | code_fim | hard | {
"lang": "rust",
"repo": "k-nasa/ai-chan",
"path": "/src/request_handle/handle_pull_request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: k-nasa/ai-chan path: /src/request_handle/handle_pull_request.rs
use crate::command::Command;
use crate::github::pull_request::{PullRequestAction, PullRequestEvent};
use crate::owners::Owners;
use crate::AIChannResult;
<|fim_suffix|> let owners = Owners::from_repository(&pull_request_event.re... | code_fim | hard | {
"lang": "rust",
"repo": "k-nasa/ai-chan",
"path": "/src/request_handle/handle_pull_request.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let render_pass = Arc::new(
vulkano::ordered_passes_renderpass!(
device.clone(),
attachments: {
final_color: {
load: DontCare,
store: Store,
format: swapchain_for... | code_fim | hard | {
"lang": "rust",
"repo": "dobrakmato/renderer",
"path": "/renderer/src/render/fxaa/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pipeline = Arc::new(
GraphicsPipeline::start()
.vertex_input_single_buffer::<PositionOnlyVertex>()
.vertex_shader(vs.main_entry_point(), ())
.fragment_shader(fs.main_entry_point(), ())
.triangle_list()
... | code_fim | hard | {
"lang": "rust",
"repo": "dobrakmato/renderer",
"path": "/renderer/src/render/fxaa/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dobrakmato/renderer path: /renderer/src/render/fxaa/mod.rs
//! Fast approximate anti-aliasing.
use crate::render::descriptor_set_layout;
use crate::render::vertex::PositionOnlyVertex;
use crate::resources::mesh::{create_full_screen_triangle, IndexedMesh};
use std::sync::Arc;
use vulkano::descri... | code_fim | hard | {
"lang": "rust",
"repo": "dobrakmato/renderer",
"path": "/renderer/src/render/fxaa/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 2color/prisma-engines path: /query-engine/connectors/sql-query-connector/src/database/transaction.rs
use crate::SqlError;
use crate::{database::operations::*, sql_info::SqlInfo};
use async_trait::async_trait;
use connector_interface::{
self as connector, filter::Filter, AggregationRow, Aggre... | code_fim | hard | {
"lang": "rust",
"repo": "2color/prisma-engines",
"path": "/query-engine/connectors/sql-query-connector/src/database/transaction.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn create_records(
&self,
model: &ModelRef,
args: Vec<WriteArgs>,
skip_duplicates: bool,
) -> connector::Result<usize> {
self.catch(async move {
write::create_records(
&self.inner,
SqlInfo::from(&self.connect... | code_fim | hard | {
"lang": "rust",
"repo": "2color/prisma-engines",
"path": "/query-engine/connectors/sql-query-connector/src/database/transaction.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hmahal/rust path: /compiler/rustc_passes/src/errors.rs
use rustc_errors::{Applicability, MultiSpan};
use rustc_macros::{LintDiagnostic, SessionDiagnostic};
use rustc_span::{Span, Symbol};
#[derive(LintDiagnostic)]
#[lint(passes::outer_crate_level_attr)]
pub struct OuterCrateLevelAttr;
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "hmahal/rust",
"path": "/compiler/rustc_passes/src/errors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(LintDiagnostic)]
#[lint(passes::doc_test_unknown)]
pub struct DocTestUnknown {
pub path: String,
}
#[derive(LintDiagnostic)]
#[lint(passes::doc_test_takes_list)]
pub struct DocTestTakesList;
#[derive(LintDiagnostic)]
#[lint(passes::doc_primitive)]
pub struct DocPrimitive;
#[derive(LintDiag... | code_fim | hard | {
"lang": "rust",
"repo": "hmahal/rust",
"path": "/compiler/rustc_passes/src/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ygarrot/gomoku_rst path: /src/game/rules.rs
use super::board::Board;
use super::game::Game;
use super::player::Player;
use super::r#move::Move;
use core::fmt::Debug;
#[derive(PartialEq)]
pub enum RuleType {
CONDITION,
CONSEQUENCE,
CAPTURE,
FREE_THREES,
}
pub trait... | code_fim | hard | {
"lang": "rust",
"repo": "ygarrot/gomoku_rst",
"path": "/src/game/rules.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn check_free_threes(
player_x: i64,
player_y: i64,
increment_x: i64,
increment_y: i64,
id: u8,
board: &mut Board,
) -> u8 {
let x_extremity = (player_x - increment_x * 2) as usize;
let... | code_fim | hard | {
"lang": "rust",
"repo": "ygarrot/gomoku_rst",
"path": "/src/game/rules.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TorsteinTenstad/town_sim path: /src/person.rs
use crate::bounding_box::BoundingBox;
use crate::config;
use crate::entity::Entity;
use crate::entity::ShapeType;
use crate::location_history::LocationHistory;
use crate::misc_functions;
use crate::vec2D::Vec2D;
use crate::schedule_entry::ScheduleEnt... | code_fim | hard | {
"lang": "rust",
"repo": "TorsteinTenstad/town_sim",
"path": "/src/person.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn update_health(&mut self, dt: f64, delta_risk: f64) {
let mut rng = rand::thread_rng();
if !self.sick {
self.sick_risk += delta_risk * dt;
if self.sick_risk > 1.0 {
self.sick_risk = 1.0;
}
if !self.immune && rng.gen_rang... | code_fim | hard | {
"lang": "rust",
"repo": "TorsteinTenstad/town_sim",
"path": "/src/person.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn save_monthly_budget(
&self,
m: Month,
y: Year,
monthly_budget: &MonthlyBudget,
) -> Result<(), Box<dyn Error>> {
let mut monthly_budget_path = self.base_dir.clone();
monthly_budget_path.push(FileLoader::month_year_to_filename(m, y));
... | code_fim | hard | {
"lang": "rust",
"repo": "lesurp/Moneyz",
"path": "/src/file_loader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn load_monthly_budget(&self, m: Month, y: Year) -> Result<MonthlyBudget, Box<dyn Error>> {
let mut monthly_budget_path = self.base_dir.clone();
monthly_budget_path.push(FileLoader::month_year_to_filename(m, y));
FileLoader::load_or_default(monthly_budget_path)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "lesurp/Moneyz",
"path": "/src/file_loader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lesurp/Moneyz path: /src/file_loader.rs
use crate::config::Config;
use crate::data::{BudgetCategories, Month, MonthlyBudget, Year};
use serde_json;
use std::error::Error;
use std::fs::File;
use std::io::{BufReader, BufWriter};
use std::path::{Path, PathBuf};
const BUDGET_CATEGORIES_FILE: &str =... | code_fim | hard | {
"lang": "rust",
"repo": "lesurp/Moneyz",
"path": "/src/file_loader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nwrap()))
.pass(Some(env::var("DB_PASSWORD").unwrap()));
mysql::Pool::new(builder).unwrap()
}<|fim_prefix|>// repo: CraigHarley/SixDegreesRust path: /src/pool.rs
use mysql::Pool;
use std::env;
pub fn get_pool() -> Pool {
let mut builder = mysql::OptsBuilder::new();
let _dotenv = dot... | code_fim | medium | {
"lang": "rust",
"repo": "CraigHarley/SixDegreesRust",
"path": "/src/pool.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rap()))
.db_name(Some(env::var("DB_DATABASE").unwrap()))
.user(Some(env::var("DB_USER").unwrap()))
.pass(Some(env::var("DB_PASSWORD").unwrap()));
mysql::Pool::new(builder).unwrap()
}<|fim_prefix|>// repo: CraigHarley/SixDegreesRust path: /src/pool.rs
use mysql::Pool;
use std:... | code_fim | medium | {
"lang": "rust",
"repo": "CraigHarley/SixDegreesRust",
"path": "/src/pool.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CraigHarley/SixDegreesRust path: /src/pool.rs
use mysql::Pool;
use std::env;
pub fn get_pool() -> Pool {
let mut builder = mysql::OptsBuilder::new();
let _dotenv = dotenv::dotenv();
builder
.ip_or_hostname(Some(env::var("DB_HOST").unw<|fim_suffix|>nwrap()))
.pass(So... | code_fim | medium | {
"lang": "rust",
"repo": "CraigHarley/SixDegreesRust",
"path": "/src/pool.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl InsertableUser {
pub fn new(username: String, passwd: String) -> Self {
return InsertableUser {
id: Uuid::new_v4(),
username,
passwd,
};
}
}<|fim_prefix|>// repo: raunakab/bittr path: /backend/src/models/insertable_user.rs
/* external crate... | code_fim | hard | {
"lang": "rust",
"repo": "raunakab/bittr",
"path": "/backend/src/models/insertable_user.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raunakab/bittr path: /backend/src/models/insertable_user.rs
/* external crates */
/* external uses */
use serde::{
Serialize,
Deserialize
};
use diesel::Insertable;
use uuid::Uuid;
/* internal crates */
<|fim_suffix|>impl InsertableUser {
pub fn new(username: String, passwd: Strin... | code_fim | hard | {
"lang": "rust",
"repo": "raunakab/bittr",
"path": "/backend/src/models/insertable_user.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> rocket::ignite().mount("/", routes![index, start, movement, end])
}
fn main() {
rocket().launch();
}<|fim_prefix|>// repo: McRaeAlex/RustySnake path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
// Modules
#[allow(dead_code)]
mod requests;
#[allow(dead_code)]
mod responses;
#[cfg(te... | code_fim | hard | {
"lang": "rust",
"repo": "McRaeAlex/RustySnake",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn rocket() -> rocket::Rocket {
rocket::ignite().mount("/", routes![index, start, movement, end])
}
fn main() {
rocket().launch();
}<|fim_prefix|>// repo: McRaeAlex/RustySnake path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
// Modules
#[allow(dead_code)]
mod requests;
#[allow(dea... | code_fim | hard | {
"lang": "rust",
"repo": "McRaeAlex/RustySnake",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: McRaeAlex/RustySnake path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
// Modules
#[allow(dead_code)]
mod requests;
#[allow(dead_code)]
mod responses;
#[cfg(test)]
mod test;
// External crates
#[macro_use]
extern crate rocket;
extern crate rocket_contrib;
// Uses
use rocket::http... | code_fim | medium | {
"lang": "rust",
"repo": "McRaeAlex/RustySnake",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ogrisel/tract path: /core/src/ops/nn/data_formats.rs
use crate::dim::DimLike;
use std::fmt;
use std::marker::PhantomData;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum DataFormat {
NCHW,
NHWC,
}
impl Default for DataFormat {
fn default() -> DataFormat {
<|fim_suffix|>impl DataF... | code_fim | hard | {
"lang": "rust",
"repo": "ogrisel/tract",
"path": "/core/src/ops/nn/data_formats.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn hw_rank(&self) -> usize {
self.shape.as_ref().len() - 2
}
pub fn n_axis(&self) -> usize {
0
}
pub fn c_axis(&self) -> usize {
match self.fmt {
DataFormat::NHWC => self.shape.as_ref().len() - 1,
DataFormat::NCHW => 1,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ogrisel/tract",
"path": "/core/src/ops/nn/data_formats.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn h_axis(&self) -> usize {
match self.fmt {
DataFormat::NHWC => 1,
DataFormat::NCHW => 2,
}
}
pub fn hw_axes(&self) -> ::std::ops::Range<usize> {
self.h_axis()..self.h_axis() + self.hw_rank()
}
pub fn n_dim(&self) -> D {
se... | code_fim | hard | {
"lang": "rust",
"repo": "ogrisel/tract",
"path": "/core/src/ops/nn/data_formats.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgr113/my-otus-tests path: /stages/99_stream_processing/orders_project/app/src/db/ops/update.rs
use chrono::{ NaiveDateTime, Utc };
use serde::{ Deserialize, Serialize };
use diesel::{
prelude::*,
RunQueryDsl, Insertable,
result::Error as DbError
};
<|fim_suffix|>impl OrderUpdate {
... | code_fim | hard | {
"lang": "rust",
"repo": "dgr113/my-otus-tests",
"path": "/stages/99_stream_processing/orders_project/app/src/db/ops/update.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = diesel::update( orders::table.find( order_id ) )
.set( &order_data.order )
.execute( &connection );
match res == Ok(0) {
true => Err( DbError::NotFound ), // No any records found and updated
false => Ok(())... | code_fim | hard | {
"lang": "rust",
"repo": "dgr113/my-otus-tests",
"path": "/stages/99_stream_processing/orders_project/app/src/db/ops/update.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>(
)
.
len
(
)
-
buf
.
filled
(
)
.
len
(
)
;
assert_eq
!
(
real_num_init
me
.
num_init
"
{
:
?
}
"
me
.
state
)
;
match
me
.
state
{
State
:
:
Initializing
=
>
{
buf
.
initialize_unfilled_to
(
me
.
num_init
+
2
)
;
buf
.
advance
(
1
)
;
me
.
num_init
+
=
1
;
if
me
.
num_init
=
=
24
{
me
.
state
=
State
:
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/tests/io_read_to_end.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tokio/tests/io_read_to_end.rs
#
!
[
warn
(
rust_2018_idioms
)
]
#
!
[
cfg
(
feature
=
"
full
"
)
]
use
std
:
:
pin
:
:
Pin
;
use
std
:
:
task
:
:
{
Context
Poll
}
;
use
tokio
:
:
io
:
:
{
AsyncRead
AsyncReadExt
ReadBuf
}
;
use
tokio_test
:
:
as... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/tests/io_read_to_end.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aboglioli/rwm path: /src/main.rs
mod core;
use crate::core::{window_manager::WindowManager, x::Display};
<|fim_suffix|> let windows = wm.scan()?;
println!("- Attached to {} windows.", windows);
println!("- Running...");
wm.run()?;
Ok(())
}<|fim_middle|>#[tokio::main]
async ... | code_fim | medium | {
"lang": "rust",
"repo": "aboglioli/rwm",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let windows = wm.scan()?;
println!("- Attached to {} windows.", windows);
println!("- Running...");
wm.run()?;
Ok(())
}<|fim_prefix|>// repo: aboglioli/rwm path: /src/main.rs
mod core;
use crate::core::{window_manager::WindowManager, x::Display};
#[tokio::main]
async fn main() -> R... | code_fim | medium | {
"lang": "rust",
"repo": "aboglioli/rwm",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut wm = WindowManager::new(display);
println!("[RWM]");
let windows = wm.scan()?;
println!("- Attached to {} windows.", windows);
println!("- Running...");
wm.run()?;
Ok(())
}<|fim_prefix|>// repo: aboglioli/rwm path: /src/main.rs
mod core;
use crate::core::{window_man... | code_fim | medium | {
"lang": "rust",
"repo": "aboglioli/rwm",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.