text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> use Inner::*;
use Tokens::*;
let s = r#""Hello W\u{00f4}\162ld\n""#;
let moded = ModeBridge {
mode: Modes::new(s),
};
let results: Vec<Result<Tokens, ()>> = moded.collect();
let expect = vec![
Ok(OuterToken(Outer::StartString)),
Ok(InnerToken(Text)),
... | code_fim | hard | {
"lang": "rust",
"repo": "maciejhirsz/logos",
"path": "/tests/tests/lexer_modes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maciejhirsz/logos path: /tests/tests/lexer_modes.rs
use logos::Lexer;
use logos::Logos as _;
use logos_derive::Logos;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Logos)]
enum Outer {
#[token("\"")]
StartString,
#[regex(r"\p{White_Space}")]
WhiteSpace,
}
#[derive(Copy, Cl... | code_fim | hard | {
"lang": "rust",
"repo": "maciejhirsz/logos",
"path": "/tests/tests/lexer_modes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn before_draw(&mut self) -> Result<()> {
let updated = CacheValue(self.values[self.active]);
if self.textures[self.active].value != updated {
self.textures[self.active] = Self::load_char(updated, &*self.font)?;
}
Ok(())
}
pub fn extract(&self) ... | code_fim | hard | {
"lang": "rust",
"repo": "nrxus/duck_husky_wedding",
"path": "/src/duck_husky_wedding/edit_text.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nrxus/duck_husky_wedding path: /src/duck_husky_wedding/edit_text.rs
use duck_husky_wedding::hud::{AsCached, CacheValue, TextCache};
use duck_husky_wedding::flicker::Flicker;
use errors::*;
use utils::Try;
use glm;
use moho::{self, input};
use moho::renderer::{options, ColorRGBA, Font, Renderer,... | code_fim | hard | {
"lang": "rust",
"repo": "nrxus/duck_husky_wedding",
"path": "/src/duck_husky_wedding/edit_text.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn default_system_sets(&self) -> Vec<Box<dyn crate::schedule::SystemSet>> {
let set = crate::schedule::SystemTypeSet::<F>::new();
vec![Box::new(set)]
}
}
/// A trait implemented for all exclusive system functions that can be used as [`System`]s.
///
/// This trait can be useful fo... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_ecs/src/system/exclusive_function_system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bevyengine/bevy path: /crates/bevy_ecs/src/system/exclusive_function_system.rs
use crate::{
archetype::ArchetypeComponentId,
component::{ComponentId, Tick},
query::Access,
system::{
check_system_change_tick, ExclusiveSystemParam, ExclusiveSystemParamItem, In, IntoSystem,
... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_ecs/src/system/exclusive_function_system.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_last_run(&self) -> Tick {
self.system_meta.last_run
}
fn set_last_run(&mut self, last_run: Tick) {
self.system_meta.last_run = last_run;
}
#[inline]
fn apply_deferred(&mut self, _world: &mut World) {
// "pure" exclusive systems do not have any buffe... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_ecs/src/system/exclusive_function_system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: glias/dex-contracts path: /share/src/lib.rs
#![no_std]
#![feature(lang_items)]
#![feature(alloc_error_handler)]
#![feature(panic_info_message)]
<|fim_suffix|>pub mod hash;
pub mod error;<|fim_middle|>pub mod constants;
pub mod signature;
| code_fim | easy | {
"lang": "rust",
"repo": "glias/dex-contracts",
"path": "/share/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod signature;
pub mod hash;
pub mod error;<|fim_prefix|>// repo: glias/dex-contracts path: /share/src/lib.rs
#![no_std]
#![feature(lang_items)]
#![feature(alloc_error_handler)]
#![feature(panic_info_message)]
<|fim_middle|>pub mod constants;
| code_fim | easy | {
"lang": "rust",
"repo": "glias/dex-contracts",
"path": "/share/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: p0lunin/lambda-calculator path: /src/interpreter/ir.rs
use crate::syntax::ast;
pub use crate::syntax::ast::Ident;
use std::ops::Deref;
use std::fmt::{Display, Formatter};
pub fn term_to_ir(term: &ast::Term) -> Box<Term> {
Box::new(match term {
ast::Term::Lambda(l) => Term::Lambda(la... | code_fim | hard | {
"lang": "rust",
"repo": "p0lunin/lambda-calculator",
"path": "/src/interpreter/ir.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq, Clone)]
pub struct Lambda(pub Ident, pub Box<Term>);
impl Display for Lambda {
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
write!(f, "(\\{}.{})", self.0.0, self.1)
}
}
#[derive(Debug, PartialEq, Clone)]
pub struct Application(pub Box<Term>... | code_fim | hard | {
"lang": "rust",
"repo": "p0lunin/lambda-calculator",
"path": "/src/interpreter/ir.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn flush(&self) {}
}
pub fn init() -> Result<(), LogError> {
XOUS_LOGGER_CONNECTION.store(
xous::try_connect(xous::SID::from_bytes(b"xous-log-server ").unwrap())
.or(Err(LogError::NoConnection))?,
Ordering::Relaxed,
);
log::set_logger(&XOUS_LOGGER).map_err(|_| ... | code_fim | hard | {
"lang": "rust",
"repo": "betrusted-io/xous-core",
"path": "/api/xous-api-log/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: betrusted-io/xous-core path: /api/xous-api-log/src/lib.rs
#![cfg_attr(target_os = "none", no_std)]
use core::fmt::Write;
use core::sync::atomic::{AtomicU32, Ordering};
use num_traits::ToPrimitive;
pub mod api;
mod cursor;
#[derive(Debug)]
pub enum LogError {
LoggerExists,
NoConnection,... | code_fim | hard | {
"lang": "rust",
"repo": "betrusted-io/xous-core",
"path": "/api/xous-api-log/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 3for/tk-http path: /src/server/headers.rs
use std::str::from_utf8;
use std::slice::Iter as SliceIter;
#[allow(unused_imports)]
use std::ascii::AsciiExt;
use std::borrow::Cow;
use httparse::{self, EMPTY_HEADER, Request, Header};
use tk_bufstream::Buf;
use server::error::{Error, ErrorEnum};
use ... | code_fim | hard | {
"lang": "rust",
"repo": "3for/tk-http",
"path": "/src/server/headers.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut raw = Request::new(&mut headers);
let mut result = raw.parse(&buffer[..]);
if matches!(result, Err(httparse::Error::TooManyHeaders)) {
vec = vec![EMPTY_HEADER; MAX_HEADERS];
raw = Request::new(&mut vec);
result = raw.parse(&buffer[..]);
... | code_fim | hard | {
"lang": "rust",
"repo": "3for/tk-http",
"path": "/src/server/headers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (tx, rx) = mpsc::channel();
let loader = Loader::new(Batcher);
let author_loader = Arc::new(loader.cached());
// let v1 = author_loader.load(3);
// let v2 = author_loader.load(3);
let vec = vec![1, 2, 3, 4];
for val in vec {
let clone_loader = Arc::clone(&author_loa... | code_fim | medium | {
"lang": "rust",
"repo": "jayy-lmao/rust-dataloader-experiment",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jayy-lmao/rust-dataloader-experiment path: /src/main.rs
use dataloader::{BatchFn, BatchFuture, Loader};
use futures::{executor, future, FutureExt as _, TryFutureExt as _};
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
use std::thread;
struct Batcher;
<|fim_suffix|> println!("load ba... | code_fim | medium | {
"lang": "rust",
"repo": "jayy-lmao/rust-dataloader-experiment",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("load batch {:?}", keys);
future::ready(keys.into_iter().map(|v| v * 10).collect())
.unit_error()
.boxed()
}
}
// struct Loaders {
// author_loader: Loader<i32, i32, (), Batcher>,
// }
fn main() {
let (tx, rx) = mpsc::channel();
let loader ... | code_fim | medium | {
"lang": "rust",
"repo": "jayy-lmao/rust-dataloader-experiment",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn returns_expected() {
assert_close(square_area_to_circle(9.0), 7.0685834705770345, 1e-8);
assert_close(square_area_to_circle(20.0), 15.70796326794897, 1e-8);
assert_close(square_area_to_circle(3.14), 2.4661502330679874, 1e-8);
assert_close(square_area_to_circle(58.7), 46.102872191430215,... | code_fim | medium | {
"lang": "rust",
"repo": "mikikora/University",
"path": "/rust/lista1/z4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mikikora/University path: /rust/lista1/z4.rs
fn square_area_to_circle(size:f64) -> f64 {
let a:f64 = size.sqrt();
(a / 2f64) * (a / 2f64) * std::f64::consts::PI
}
<|fim_suffix|> assert_close(square_area_to_circle(9.0), 7.0685834705770345, 1e-8);
assert_close(square_area_to_circle(20... | code_fim | medium | {
"lang": "rust",
"repo": "mikikora/University",
"path": "/rust/lista1/z4.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ttiurani/automerge-rs path: /automerge-protocol/src/utility_impls/actor_id.rs
use std::{convert::TryFrom, fmt, str::FromStr};
use tinyvec::{ArrayVec, TinyVec};
use crate::{error::InvalidActorId, ActorId};
impl TryFrom<&str> for ActorId {
type Error = InvalidActorId;
fn try_from(s: &s... | code_fim | medium | {
"lang": "rust",
"repo": "ttiurani/automerge-rs",
"path": "/automerge-protocol/src/utility_impls/actor_id.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for ActorId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.to_hex_string())
}
}<|fim_prefix|>// repo: ttiurani/automerge-rs path: /automerge-protocol/src/utility_impls/actor_id.rs
use std::{convert::TryFrom, fmt, str::FromStr};
use tin... | code_fim | medium | {
"lang": "rust",
"repo": "ttiurani/automerge-rs",
"path": "/automerge-protocol/src/utility_impls/actor_id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/relay path: /compiler/crates/schema-documentation/src/combined_schema_documentation.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/relay",
"path": "/compiler/crates/schema-documentation/src/combined_schema_documentation.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
type_name: &str,
field_name: &str,
argument_name: &str,
) -> Option<&str> {
self.primary
.get_field_argument_description(type_name, field_name, argument_name)
.or_else(|| {
self.secondary
.get_fi... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/relay",
"path": "/compiler/crates/schema-documentation/src/combined_schema_documentation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wattaihei/sudoku-rs path: /src/main.rs
use actix_web::*;
use actix_cors::Cors;
use serde_json::json;
use serde::*;
use std::env;
mod core;
use crate::core::sudoku_make::make;
use crate::core::sudoku_solve::solve;
#[derive(Deserialize)]
struct RequestParam {
level : i32
}
<|fim_suffix|>#[ac... | code_fim | hard | {
"lang": "rust",
"repo": "wattaihei/sudoku-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[actix_web::main]
async fn main() -> Result<(), actix_web::Error> {
let port = env::var("PORT")
.unwrap_or_else(|_| "3000".to_string())
.parse()
.expect("PORT must be a number");
HttpServer::new(move || {
App::new()
.wrap(
Cors::new() //... | code_fim | hard | {
"lang": "rust",
"repo": "wattaihei/sudoku-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Larusso/unity-version-manager path: /uvm_move_dir/src/lib.rs
use log::*;
use std::fs;
use std::io;
use std::path::Path;
use tempfile::tempdir_in;
#[cfg(windows)]
mod win_move_file;
fn visit_dirs<P: AsRef<Path>>(
dir: P,
cb: &mut dyn for<'r> std::ops::FnMut(&'r fs::DirEntry),
) -> io::R... | code_fim | hard | {
"lang": "rust",
"repo": "Larusso/unity-version-manager",
"path": "/uvm_move_dir/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(unix)]
fs::DirBuilder::new().create(&sub)?;
#[cfg(unix)]
fs::rename(source, &sub)?;
#[cfg(windows)]
win_move_file::rename(source, &sub)?;
move_dir(&sub, destination).map_err(|err|{
match fs::rename(&... | code_fim | hard | {
"lang": "rust",
"repo": "Larusso/unity-version-manager",
"path": "/uvm_move_dir/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn vars(&self) -> &[&str] {
&self.var_map
}
pub fn var_count(&self) -> usize {
self.var_count
}
}<|fim_prefix|>// repo: svmnotn/truth-tester path: /src/parsing/tokens/mod.rs
#[cfg(feature = "tester")]
mod exper;
mod token;
pub use token::Token;
mod token_lit;
pub us... | code_fim | hard | {
"lang": "rust",
"repo": "svmnotn/truth-tester",
"path": "/src/parsing/tokens/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: svmnotn/truth-tester path: /src/parsing/tokens/mod.rs
#[cfg(feature = "tester")]
mod exper;
mod token;
pub use token::Token;
<|fim_suffix|>impl<'a> Tokens<'a> {
pub(crate) fn new(toks: Vec<Token<'a>>, var_map: Vec<&'a str>) -> Self {
Tokens {
var_count: var_map.len(),
... | code_fim | medium | {
"lang": "rust",
"repo": "svmnotn/truth-tester",
"path": "/src/parsing/tokens/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Tokens<'a> {
pub(crate) fn new(toks: Vec<Token<'a>>, var_map: Vec<&'a str>) -> Self {
Tokens {
var_count: var_map.len(),
var_map,
toks,
}
}
pub fn var_at(&self, n: usize) -> &str {
self.var_map[n]
}
pub fn vars(&sel... | code_fim | medium | {
"lang": "rust",
"repo": "svmnotn/truth-tester",
"path": "/src/parsing/tokens/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Random initial position
let cur_gen: i32 = gd.current_generation / 10;
// let water_idx = (cur_gen % (water_translator_ref.len() as i32 - 1)) as usize;
// Random initial position
let water_idx = rng.gen_range(0, water_translator_ref.len());
(0..to_create).for_each(|i| {
... | code_fim | hard | {
"lang": "rust",
"repo": "rmaugusto/mtxia",
"path": "/src/fish/creation_system.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> commands
.spawn(SpriteSheetComponents {
texture_atlas: assets.fish.clone(),
transform: transform,
sprite: TextureAtlasSprite{
index: 6,
..Default::default()
},
..Defa... | code_fim | hard | {
"lang": "rust",
"repo": "rmaugusto/mtxia",
"path": "/src/fish/creation_system.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rmaugusto/mtxia path: /src/fish/creation_system.rs
use bevy::prelude::*;
use rand::Rng;
use crate::{
ai::ai_processor_factory::create_brain,
ground::WaterTile,
sensor::SensorSet,
shared::{
config::{Config, ModeEnum},
gamedata::GameData,
},
startup::Intern... | code_fim | hard | {
"lang": "rust",
"repo": "rmaugusto/mtxia",
"path": "/src/fish/creation_system.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl CustomBuildable {
pub fn add_suffix<T: glib::IsA<gtk::Widget>>(&self, widget: &T) {
let imp = self.imp();
imp.suffixes.append(widget);
imp.suffixes.show();
}
pub fn add_prefix<T: glib::IsA<gtk::Widget>>(&self, widget: &T) {
let imp = self.imp();
im... | code_fim | medium | {
"lang": "rust",
"repo": "zecakeh/gtk4-rs",
"path": "/examples/custom_buildable/custom_buildable/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /examples/custom_buildable/custom_buildable/mod.rs
mod imp;
use gtk::glib;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
glib::wrapper! {
pub struct CustomBuildable(ObjectSubclass<imp::CustomBuildable>) @extends gtk::Widget, @implements gtk::Buildable;
}
<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "zecakeh/gtk4-rs",
"path": "/examples/custom_buildable/custom_buildable/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gjf2a/pi_calculator path: /src/main.rs
// pi = 4(1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ....)
struct PiCalculator {
total: f64,
prev_total: f64,
tolerance: f64,
num_terms: usize
}
impl PiCalculator {
fn new(tolerance: f64) -> Self {
PiCalculator { total: 1.0, prev_total... | code_fim | medium | {
"lang": "rust",
"repo": "gjf2a/pi_calculator",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tolerance = std::env::args().skip(1).next().unwrap().parse::<f64>().unwrap();
let mut calculator = PiCalculator::new(tolerance);
while !calculator.done() {
calculator.update();
}
println!("Pi: {}", calculator.current_total());
}<|fim_prefix|>// repo: gjf2a/pi_calculator pa... | code_fim | medium | {
"lang": "rust",
"repo": "gjf2a/pi_calculator",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ded API."]
pub mod fsm_era_pul;
#[doc = "Internal. Only to be used through TI provided API.\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crat... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/flash.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fy--write-api).\n\nFor information about available fields see [fraw_datal](fraw_datal) module"]
pub type FRAW_DATAL = crate::Reg<u32, _FRAW_DATAL>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _FRAW_DATAL;
#[doc = "`read()` method returns [fraw_datal::R](fraw_datal::R) reader structure"]
impl crate::R... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/flash.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeandudey/cc13x2-rs path: /src/flash.rs
API."]
pub fcfg_b5_start: FCFG_B5_START,
#[doc = "0x2428 - Internal. Only to be used through TI provided API."]
pub fcfg_b6_start: FCFG_B6_START,
#[doc = "0x242c - Internal. Only to be used through TI provided API."]
pub fcfg_b7_start: ... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/flash.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let backup_user = crate::backup::backup_user()?;
let mode = nix::sys::stat::Mode::from_bits_truncate(0o0640);
// set the correct owner/group/permissions while saving file
// owner(rw) = root, group(r)= backup
let options = CreateOptions::new()
.perm(mode)
.owner(nix::un... | code_fim | hard | {
"lang": "rust",
"repo": "pimox/proxmox-backup",
"path": "/src/config/user.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pimox/proxmox-backup path: /src/config/user.rs
use std::collections::HashMap;
use std::sync::{Arc, RwLock};
use anyhow::{bail, Error};
use lazy_static::lazy_static;
use serde::{Serialize, Deserialize};
use proxmox::api::{
api,
schema::*,
section_config::{
SectionConfig,
... | code_fim | hard | {
"lang": "rust",
"repo": "pimox/proxmox-backup",
"path": "/src/config/user.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> lazy_static! {
static ref CACHED_CONFIG: RwLock<ConfigCache> = RwLock::new(
ConfigCache { data: None, last_mtime: 0, last_mtime_nsec: 0 });
}
let stat = match nix::sys::stat::stat(USER_CFG_FILENAME) {
Ok(stat) => Some(stat),
Err(nix::Error::Sys(nix::errno::... | code_fim | hard | {
"lang": "rust",
"repo": "pimox/proxmox-backup",
"path": "/src/config/user.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vrvlive/iotedge path: /mqtt/mqtt-bridge/src/controller.rs
use futures_util::future::{self, join_all};
use serde::{Deserialize, Serialize};
use thiserror::Error;
use tokio::sync::mpsc::{self, UnboundedSender};
use tracing::{error, info, info_span};
use tracing_futures::Instrument;
use crate::{br... | code_fim | hard | {
"lang": "rust",
"repo": "vrvlive/iotedge",
"path": "/mqtt/mqtt-bridge/src/controller.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO: bridge controller will eventually listen for updates via the twin
// until this is complete we need to wait here indefinitely
// if we stop the bridge controller, our startup/shutdown logic will shut eveything down
future::pending::<()>().await;
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "vrvlive/iotedge",
"path": "/mqtt/mqtt-bridge/src/controller.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO is it possible for this to conclude that the key must be overflowed
// when it would actually fit because of prefixing?
let blkAfterKey,kloc =
if k.Length <= maxKeyInline then
st.blk, Inline
... | code_fim | hard | {
"lang": "rust",
"repo": "pythonesque/LSM",
"path": "/fs/lsm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pythonesque/LSM path: /fs/lsm.rs
let sofar =
if newPrefixLen < st.prefixLen then
// the prefixLen will change with the addition of this key,
// so we need to recalc sofar
// TODO... | code_fim | hard | {
"lang": "rust",
"repo": "pythonesque/LSM",
"path": "/fs/lsm.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let wrapMergeForLater f = async {
let g = f()
//printfn "now waiting for writeLock"
// merges go to the front of the queue
use! tx = getWriteLock true (-1) None
tx.CommitMerge g
return [ g ]
}
let critSectionBackgroundMergeJobs = obj()
let m... | code_fim | hard | {
"lang": "rust",
"repo": "pythonesque/LSM",
"path": "/fs/lsm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>4] > vec![1, 2, 3, 4]));
assert!((vec![1, 2, 3, 4] < vec![1, 2, 4, 4]));
assert!((vec![1, 2, 3] <= vec![1, 2, 3]));
assert!((vec![1, 2, 3] <= vec![1, 2, 3, 3]));
assert!((vec![1, 2, 3, 4] > vec![1, 2, 3]));
assert_eq!(vec![1, 2, 3], vec![1, 2, 3]);
assert!((vec![1, 2, 3] != vec![1,... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/seq-compare.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/seq-compare.rs
pub fn main() {
assert!(("hello".to_string() < "hellr".to_string()));
assert!(("hello ".to_string() > "hello".to_string()));
assert!(("hello".to_string() != "there".to_string()));
assert!((vec![1, 2, 3, 4] > ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/seq-compare.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VFMSUB213SD, operand1: Some(Direct(XMM28)), operand2: Some(Direct(XMM29)), operand3: Some(Direct(XMM24)), operand4: None, lock: false, rounding_mode: Some(RoundingMode::Down), merge_mode: Some(MergeMode::Zero), sae: false, mask: Some(MaskReg::K1), broadcast:... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/vfmsub213sd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/vfmsub213sd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn vfmsub213sd_1() {
r... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/vfmsub213sd.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> raw.push(c);
self.bump();
let (t, cont) = op(total, RADIX, val)?;
total = t;
if !cont {
return Ok(total);
}
prev = Some(c);
}
Ok(total)
}
fn make_legacy_octal(&mut self, start... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_parser/src/lexer/number.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_parser/src/lexer/number.rs
panic!("failed to parse {} into float using BigInt", val_str)
});
return self.make_legacy_octal(start, val).map(|value| {
Eithe... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_parser/src/lexer/number.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(raw_val, "{}", exp).unwrap();
if raw_val.contains('_') {
Cow::Owned(raw_val.replace('_', ""))
} else {
Cow::Borrowed(&*raw_val)
}
.parse()
... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_parser/src/lexer/number.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rchaser53/rust-monkey-ir path: /src/lexer/lexer.rs
use lexer::token::*;
#[derive(Debug)]
pub struct Lexer<'a> {
pub bytes: &'a [u8],
pub position: usize,
pub current_row: usize,
}
impl<'a> Lexer<'a> {
pub fn new(input: &'a str) -> Lexer {
let bytes = input.as_bytes();
... | code_fim | hard | {
"lang": "rust",
"repo": "rchaser53/rust-monkey-ir",
"path": "/src/lexer/lexer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn division_multiple() {
let mut lexer = Lexer::new(
r#"
1 / 323 * 3 / 2
"#,
);
lexer_assert(lexer.next_token().unwrap(), TokenType::Digit, "1");
lexer_assert(lexer.next_token().unwrap(), TokenType::Divide, "/");
lexer_assert(lexer.next_token().unwrap(), TokenTy... | code_fim | hard | {
"lang": "rust",
"repo": "rchaser53/rust-monkey-ir",
"path": "/src/lexer/lexer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadydealer/Rust path: /image-processing/src/ui/dialogs/open_dialog.rs
use gtk::*;
use std::path::PathBuf;
pub struct OpenDialog{
pub open_dialog: FileChooserDialog
}
impl OpenDialog {
pub fn new(path: Option<PathBuf>) -> Self {
let open_dialog = FileChooserDialog::new(
... | code_fim | hard | {
"lang": "rust",
"repo": "shadydealer/Rust",
"path": "/image-processing/src/ui/dialogs/open_dialog.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn run(&self) -> Option<PathBuf> {
if self.open_dialog.run() == ResponseType::Ok.into() {
self.open_dialog.get_filename()
} else {
None
}
}
}
impl Drop for OpenDialog {
fn drop(&mut self) { self.open_dialog.destroy(); }
}<|fim_prefix|>// rep... | code_fim | hard | {
"lang": "rust",
"repo": "shadydealer/Rust",
"path": "/image-processing/src/ui/dialogs/open_dialog.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bto/wasm-gameboy path: /wasm/src/cpu/opcode/lddi_rr_tests.rs
use super::*;
#[macro_use]
mod tests_macro;
#[test]
fn op_lddi_rr_r() {
<|fim_suffix|> // LDI (HL), A
let pc = cpu.registers.pc;
set_inst!(cpu, pc, 0x22);
cpu.registers.h = 4;
cpu.registers.l = 2;
cpu.registers... | code_fim | medium | {
"lang": "rust",
"repo": "bto/wasm-gameboy",
"path": "/wasm/src/cpu/opcode/lddi_rr_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // LDD (HL), A
let pc = cpu.registers.pc;
set_inst!(cpu, pc, 0x32);
cpu.registers.h = 5;
cpu.registers.l = 4;
cpu.registers.a = 6;
cpu.execute();
assert_eq!(cpu.registers.pc, pc + 1);
assert_eq!(cpu.mmu.byte_get(0x504), 6);
assert_eq!(cpu.registers.l, 3);
}<|fim_pre... | code_fim | hard | {
"lang": "rust",
"repo": "bto/wasm-gameboy",
"path": "/wasm/src/cpu/opcode/lddi_rr_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joone/smithay path: /examples/helpers/glium.rs
use glium;
use glium::{Frame, GlObject, Surface};
use glium::index::PrimitiveType;
use glium::texture::{MipmapsOption, Texture2d, UncompressedFloatFormat};
use smithay::backend::graphics::egl::EGLGraphicsBackend;
use smithay::backend::graphics::egl:... | code_fim | hard | {
"lang": "rust",
"repo": "joone/smithay",
"path": "/examples/helpers/glium.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> gl_Position = matrix * vec4(position, 0.0, 1.0);
v_tex_coords = tex_coords;
}
",
fragment: "
#version 100
uniform lowp sampler2D tex;
varying lowp vec2 v_tex_coords;
void main() {
lowp vec4 color = texture2D(tex, v_tex_coords);
gl_Fr... | code_fim | hard | {
"lang": "rust",
"repo": "joone/smithay",
"path": "/examples/helpers/glium.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let t: String = read();
let t: Vec<&str> = t.split(':').collect();
let m = (t[0].parse::<i32>().unwrap() * 60 + t[1].parse::<i32>().unwrap() + 5) % (24 * 60);
println!("{:02}:{:02}", m / 60, m % 60);
}<|fim_prefix|>// repo: ia7ck/competitive-programming path: /yukicoder/525.rs
use std::io... | code_fim | medium | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/yukicoder/525.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /yukicoder/525.rs
use std::io::Read;
fn read<T: std::str::FromStr>() -> T {
<|fim_suffix|> let t: String = read();
let t: Vec<&str> = t.split(':').collect();
let m = (t[0].parse::<i32>().unwrap() * 60 + t[1].parse::<i32>().unwrap() + 5) % (24 * 60)... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/yukicoder/525.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let t: String = read();
let t: Vec<&str> = t.split(':').collect();
let m = (t[0].parse::<i32>().unwrap() * 60 + t[1].parse::<i32>().unwrap() + 5) % (24 * 60);
println!("{:02}:{:02}", m / 60, m % 60);
}<|fim_prefix|>// repo: ia7ck/competitive-programming path: /yukicoder/525.rs... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/yukicoder/525.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fold(points, &insns[..1]).unique().count()
}
#[aoc(day13, part2, jorendorff)]
fn part_2((points, insns): &(Vec<(i32, i32)>, Vec<Insn>)) -> String {
let points: Vec<(i32, i32)> = fold(points, insns).collect();
let xmax = points.iter().map(|&(x, _y)| x).max().unwrap();
let ymax = points.ite... | code_fim | hard | {
"lang": "rust",
"repo": "jorendorff/advent-of-code",
"path": "/ad2021/src/day13.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
const EXAMPLE: &str = "\
6,10
0,14
9,10
0,3
10,4
4,11
6,0
6,12
4,1
0,13
10,12
3,4
3,0
8,4
1,10
2,14
8,10
9,0
fold along y=7
fold along x=5
";
#[test]
fn test_part_1() {
assert_eq!(part_1(&parse_input(EXAMPLE).unwrap()), 17);
}
#[te... | code_fim | hard | {
"lang": "rust",
"repo": "jorendorff/advent-of-code",
"path": "/ad2021/src/day13.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jorendorff/advent-of-code path: /ad2021/src/day13.rs
use aoc_runner_derive::*;
use itertools::Itertools;
#[derive(Copy, Clone)]
enum Insn {
FoldX(i32),
FoldY(i32),
}
#[aoc_generator(day13, part1, jorendorff)]
#[aoc_generator(day13, part2, jorendorff)]
fn parse_input(text: &str) -> anyh... | code_fim | hard | {
"lang": "rust",
"repo": "jorendorff/advent-of-code",
"path": "/ad2021/src/day13.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub id: Uuid,
pub name: String,
pub description: Option<String>,
}<|fim_prefix|>// repo: carrolita/shelfdb path: /server/src/admin/schema_input.rs
use uuid::Uuid;
#[derive(GraphQLInpu<|fim_middle|>tObject)]
pub struct SchemaInput {
| code_fim | easy | {
"lang": "rust",
"repo": "carrolita/shelfdb",
"path": "/server/src/admin/schema_input.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: carrolita/shelfdb path: /server/src/admin/schema_input.rs
use uuid::Uuid;
#[derive(GraphQLInpu<|fim_suffix|> pub id: Uuid,
pub name: String,
pub description: Option<String>,
}<|fim_middle|>tObject)]
pub struct SchemaInput {
| code_fim | easy | {
"lang": "rust",
"repo": "carrolita/shelfdb",
"path": "/server/src/admin/schema_input.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub description: Option<String>,
}<|fim_prefix|>// repo: carrolita/shelfdb path: /server/src/admin/schema_input.rs
use uuid::Uuid;
#[derive(GraphQLInputObject)]
pub struct SchemaInput {
<|fim_middle|> pub id: Uuid,
pub name: String,
| code_fim | easy | {
"lang": "rust",
"repo": "carrolita/shelfdb",
"path": "/server/src/admin/schema_input.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn remove_bom(file_name: &str) ->bool {
match check_bom(file_name) {
true => remove_bom_impl(file_name),
false => true
}
}<|fim_prefix|>// repo: hyqhyq3/remove-bom-rs path: /src/lib.rs
use std::fs::File;
use std::fs;
use std::io::Read;
use std::io::{Seek,SeekFrom};
use std::io... | code_fim | hard | {
"lang": "rust",
"repo": "hyqhyq3/remove-bom-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hyqhyq3/remove-bom-rs path: /src/lib.rs
use std::fs::File;
use std::fs;
use std::io::Read;
use std::io::{Seek,SeekFrom};
use std::io;
fn check_bom(file_name :&str) -> bool {
<|fim_suffix|> let mut old_file = File::open(tmpname.as_str()).unwrap();
let mut file = File::create(file_... | code_fim | hard | {
"lang": "rust",
"repo": "hyqhyq3/remove-bom-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>const W1: f32 = core::f32::consts::PI / 128.0;
const W2: f32 = core::f32::consts::PI / 4.0;
// const W2: f32 = core::f32::consts::PI / 5.0;
#[cortex_m_rt::entry]
fn main() -> ! {
rtt_init_print!(BlockIfFull, 128);
let dp = stm32::Peripherals::take().unwrap();
let cp = cortex_m::peripheral::P... | code_fim | hard | {
"lang": "rust",
"repo": "drahnr/dsp-discoveryf4-rust",
"path": "/lab4/examples/4_5_fft_calculations_microfft.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drahnr/dsp-discoveryf4-rust path: /lab4/examples/4_5_fft_calculations_microfft.rs
//! This project is used for explaining the FFT operation using ARM CMSIS-DSP
//! library functions. Here we have a digital input signal, sum of two
//! sinusoidal signals with different frequencies. The complex fo... | code_fim | medium | {
"lang": "rust",
"repo": "drahnr/dsp-discoveryf4-rust",
"path": "/lab4/examples/4_5_fft_calculations_microfft.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dp = stm32::Peripherals::take().unwrap();
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
// Set up the system clock.
let rcc = dp.RCC.constrain();
let clocks = rcc
.cfgr
.use_hse(8.mhz()) //discovery board has 8 MHz crystal for HSE
.sysclk(16... | code_fim | hard | {
"lang": "rust",
"repo": "drahnr/dsp-discoveryf4-rust",
"path": "/lab4/examples/4_5_fft_calculations_microfft.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vaheqelyan/gl-event-reducer path: /src/window.rs
extern crate glfw;
use cgmath::Matrix;
use glfw::{Action, Context, Key};
use std::sync::mpsc::{channel, Receiver, Sender};
use gl::types::*;
use std::cell::Cell;
use std::cell::RefCell;
use std::ffi::CString;
use std::mem;
use std::os::raw::c_... | code_fim | hard | {
"lang": "rust",
"repo": "vaheqelyan/gl-event-reducer",
"path": "/src/window.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
window: &mut glfw::Window,
events: &Receiver<(f64, glfw::WindowEvent)>,
) {
for (_, event) in glfw::flush_messages(events) {
match event {
glfw::WindowEvent::CursorPos(x, y) => {
self.boot.cursor.x = x as f32;
... | code_fim | hard | {
"lang": "rust",
"repo": "vaheqelyan/gl-event-reducer",
"path": "/src/window.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: greatoyster/DailySchedule path: /program-15/ex01.rs
use std::env;
fn main() {
let args: Vec<String> = env::args(<|fim_suffix|>se {
println!("You are {} miles away.", args[1]);
}
}<|fim_middle|>).collect();
let distance: i32 = 100;
if args.len() <= 1 {
println!("Yo... | code_fim | medium | {
"lang": "rust",
"repo": "greatoyster/DailySchedule",
"path": "/program-15/ex01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>se {
println!("You are {} miles away.", args[1]);
}
}<|fim_prefix|>// repo: greatoyster/DailySchedule path: /program-15/ex01.rs
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let distance: i32 = 100;
if args.len() <= 1 <|fim_middle|>{
println!("Yo... | code_fim | medium | {
"lang": "rust",
"repo": "greatoyster/DailySchedule",
"path": "/program-15/ex01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twe4ked/ansi-to-png path: /src/parser.rs
use crate::ansi::{attrs_from_sgr_parameters, Attr, Color, Colors, List, PrimaryColors, Rgb};
use std::io::Read;
pub fn parse(input: std::io::Stdin) -> Vec<Token> {
let mut handle = input.lock();
let foreground = PrimaryColors::default().foregrou... | code_fim | hard | {
"lang": "rust",
"repo": "twe4ked/ansi-to-png",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn unhook(&mut self) {}
fn osc_dispatch(&mut self, _params: &[&[u8]], _bell_terminated: bool) {}
fn csi_dispatch(&mut self, params: &[i64], _intermediates: &[u8], _ignore: bool, c: char) {
if c != 'm' {
// Not a color "CSI"
return;
}
let foregr... | code_fim | hard | {
"lang": "rust",
"repo": "twe4ked/ansi-to-png",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn csi_dispatch(&mut self, params: &[i64], _intermediates: &[u8], _ignore: bool, c: char) {
if c != 'm' {
// Not a color "CSI"
return;
}
let foreground = PrimaryColors::default().foreground;
let indexed_colors = List::from(&Colors::default());
... | code_fim | hard | {
"lang": "rust",
"repo": "twe4ked/ansi-to-png",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn random_in_unit_disk() -> Vec3 {
let mut p: Vec3;
loop {
p = 2.0 * Vec3::new(rand_f32(), rand_f32(), 0.) - Vec3::new(1.,1.,0.);
if p.dot(p) < 1. { break; }
}
p
}<|fim_prefix|>// repo: Tsarpf/rust_raytracer path: /src/camera.rs
use cgmath::Vector3;
use util;
type Vec3 = V... | code_fim | hard | {
"lang": "rust",
"repo": "Tsarpf/rust_raytracer",
"path": "/src/camera.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tsarpf/rust_raytracer path: /src/camera.rs
use cgmath::Vector3;
use util;
type Vec3 = Vector3<f32>;
use cgmath::InnerSpace;
use std::f32::consts::PI;
use super::rand_f32;
pub struct Camera {
lower_left_corner: Vec3,
horizontal: Vec3,
vertical: Vec3,
origin: Vec3,
lens_radius... | code_fim | hard | {
"lang": "rust",
"repo": "Tsarpf/rust_raytracer",
"path": "/src/camera.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uutils/coreutils path: /src/uucore/src/lib/parser/parse_time.rs
// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore (vars) NANOS numstr
//!... | code_fim | hard | {
"lang": "rust",
"repo": "uutils/coreutils",
"path": "/src/uucore/src/lib/parser/parse_time.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(from_str("12abc3s").is_err());
}
#[test]
fn test_negative() {
assert!(from_str("-1").is_err());
}
/// Test that capital letters are not allowed in suffixes.
#[test]
fn test_no_capital_letters() {
assert!(from_str("1S").is_err());
assert... | code_fim | hard | {
"lang": "rust",
"repo": "uutils/coreutils",
"path": "/src/uucore/src/lib/parser/parse_time.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Logicalshift/flowbetween path: /user_interfaces/gtk_ui/src/widgets/flo_scale_widget.rs
use super::widget::*;
use super::basic_widget::*;
use super::super::gtk_event::*;
use super::super::gtk_thread::*;
use super::super::gtk_action::*;
use super::super::gtk_event_parameter::*;
use super::super::g... | code_fim | hard | {
"lang": "rust",
"repo": "Logicalshift/flowbetween",
"path": "/user_interfaces/gtk_ui/src/widgets/flo_scale_widget.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.scale.connect_value_changed(move |widget| {
if *button_pressed.borrow() == true {
let new_value = widget.get_value();
let mut last_value = last_value.borrow_mut();
if new_value != *last... | code_fim | hard | {
"lang": "rust",
"repo": "Logicalshift/flowbetween",
"path": "/user_interfaces/gtk_ui/src/widgets/flo_scale_widget.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yblein/mcts-boardgames path: /src/ttt.rs
/// Implementation of a Tic-tac-toe game
extern crate mcts;
mod utils;
mod app;
use std::fmt::{Display, Debug, Formatter, Result};
use mcts::{Player, TwoPlayerGame};
use app::Input;
use utils::{Coords2D, draw_board};
const WIDTH: usize = 3;
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "yblein/mcts-boardgames",
"path": "/src/ttt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
pub struct Board([[Option<Token>; WIDTH]; WIDTH]);
impl Board {
pub fn new() -> Board {
Board([[None; WIDTH]; WIDTH])
}
}
impl std::ops::Index<Coords2D> for Board {
type Output = Option<Token>;
fn index<'a>(&'a self, c: Coords2D) -> &'a Option<Token> {
&self.0[c.y][c.x]
}
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "yblein/mcts-boardgames",
"path": "/src/ttt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let Move(pos) = *m;
self[pos] = Some(Token { player: p });
}
fn possible_moves_in(&self, _p: Player, moves: &mut Vec<Move>) {
if self.winner().is_some() {
return;
}
for y in 0..self.0.len() {
for x in 0..self.0.len() {
if self.0[y][x].is_none() {
moves.push(Move(Coords2D { x: ... | code_fim | hard | {
"lang": "rust",
"repo": "yblein/mcts-boardgames",
"path": "/src/ttt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: charlyx/release-me path: /src/main.rs
#[macro_use]
extern crate serde_derive;
extern crate serde;
#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate clap;
#[macro_use]
extern crate lazy_static;
extern crate openssl_probe;
mod cli;
mod repository;
mod service;
<|fim_suffix|> let... | code_fim | medium | {
"lang": "rust",
"repo": "charlyx/release-me",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if matches.is_present("dry-run") {
println!(
"---------- dry-run ---------
Changelog:
________ changelog ________
{}
_______ !changelog! _______
Repository name: {}
--------- !dry-run! --------",
changelog, repository_name,
);
return;
}
service:... | code_fim | hard | {
"lang": "rust",
"repo": "charlyx/release-me",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cidhuang/rust-actix-sailfish-starter path: /src/main.rs
use std::collections::HashMap;
use actix_http::{body::Body, Response};
use actix_web::dev::ServiceResponse;
use actix_web::http::StatusCode;
use actix_web::middleware::errhandlers::{ErrorHandlerResponse, ErrorHandlers};
use actix_web::{mid... | code_fim | hard | {
"lang": "rust",
"repo": "cidhuang/rust-actix-sailfish-starter",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[actix_web::main]
async fn main() -> std::io::Result<()> {
/*
// load ssl keys
// to create a self-signed temporary cert for testing:
// `openssl req -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365 -subj '/CN=localhost'`
let mut builder = SslAcceptor::mozilla_interme... | code_fim | hard | {
"lang": "rust",
"repo": "cidhuang/rust-actix-sailfish-starter",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn styles() -> actix_web::Result<actix_files::NamedFile> {
Ok(actix_files::NamedFile::open("./files/styles.css")?)
}
async fn about(
_query: web::Query<HashMap<String, String>>,
) -> Result<HttpResponse, Error> {
let s = AboutTemplate {
title: "About Title",
keywords: "A... | code_fim | hard | {
"lang": "rust",
"repo": "cidhuang/rust-actix-sailfish-starter",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn main() {
let body = super::get_challenge_data(1);
let data : Vec<i32> = body.split('\n').map(|x| x.parse().unwrap()).collect();
part_1(&data);
let result_2 = part_2(&data);
println!("Result part 2: {}", result_2);
}<|fim_prefix|>// repo: DavidVentura/Advent_of_code_2018 path: /... | code_fim | hard | {
"lang": "rust",
"repo": "DavidVentura/Advent_of_code_2018",
"path": "/src/aoc_1.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.