text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let file_path = Path::new("./gblock_logic");
let file_data: Cow<str>;
gtree! {
'checker {
// decode file
let mut file = match std::fs::File::open(&file_path) {
Ok(a) => a,
Err(e) => run_gtree!('err_load_file: e),
};
let mut buff = String::with_capacity(25);
if let Err(e) = ... | code_fim | medium | {
"lang": "rust",
"repo": "clucompany/Goto",
"path": "/examples/gtree_logics.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: at-robins/oben path: /src/evolution/protein/sensor/test_output.rs
use crate::evolution::{
helper::noop::{NoOpOutputElement, NoOpOutputSensor, NoOpReaction, NoOpState, NoOpSubstrate},
protein::SubstrateType,
};
use super::*;
#[test]
/// Tests if the function `new` correctly creates an [... | code_fim | hard | {
"lang": "rust",
"repo": "at-robins/oben",
"path": "/src/evolution/protein/sensor/test_output.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Rc::new(RefCell::new(Substrate::new((), SubstrateType::ConventionalSubstrate)))
}
fn vec_pointer_equality_optional_weak(
a: &Vec<Option<Weak<RefCell<Substrate<NoOpReaction, NoOpState, NoOpSubstrate>>>>>,
b: &Vec<Option<Weak<RefCell<Substrate<NoOpReaction, NoOpState, NoOpSubstrate>>>>>,
) -> b... | code_fim | hard | {
"lang": "rust",
"repo": "at-robins/oben",
"path": "/src/evolution/protein/sensor/test_output.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
MapOutOfBoundsClockAugmentSystemData {
map_boundary_ec,
map_unbounded_deletes,
mut out_of_bounds_delete_clocks,
}: Self::SystemData,
) {
let map_boundary_event_rid = self
.map_boundary_event_rid
.as_... | code_fim | hard | {
"lang": "rust",
"repo": "azriel91/autexousious",
"path": "/crate/map_play/src/system/map_out_of_bounds_clock_augment_system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/map_play/src/system/map_out_of_bounds_clock_augment_system.rs
use amethyst::{
ecs::{Read, ReadStorage, System, World, WriteStorage},
shred::{ResourceId, SystemData},
shrev::{EventChannel, ReaderId},
};
use derivative::Derivative;
use derive_new::new... | code_fim | hard | {
"lang": "rust",
"repo": "azriel91/autexousious",
"path": "/crate/map_play/src/system/map_out_of_bounds_clock_augment_system.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lucretiel/iqlusioninc-crates path: /bip32/src/private_key.rs
//! Trait for deriving child keys on a given type.
use crate::{Result, KEY_SIZE};
/// Bytes which represent a private key.
type KeyBytes = [u8; KEY_SIZE];
/// Trait for key types which can be derived using BIP32.
pub trait PrivateKe... | code_fim | hard | {
"lang": "rust",
"repo": "Lucretiel/iqlusioninc-crates",
"path": "/bip32/src/private_key.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn to_bytes(&self) -> KeyBytes {
k256::SecretKey::to_bytes(self).into()
}
fn derive_child(&self, derivation_key: &KeyBytes) -> Result<Self> {
let child_scalar = k256::Scalar::from_bytes_reduced(derivation_key.into());
let derived_scalar = self.secret_scalar().as_ref() ... | code_fim | hard | {
"lang": "rust",
"repo": "Lucretiel/iqlusioninc-crates",
"path": "/bip32/src/private_key.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn mandelbrot(komplexeZahl: [f64; 2]) -> i64 {
let mut cx = komplexeZahl[0];
let mut cy = komplexeZahl[1];
let mut iterationen = 0;
let mut cx2 = cx * cx;
let mut cy2 = cy * cy;
let mut cxy = cx * cy;
while iterationen < maxIterationen && cx2 + cy2 <= 4 as f64 {
cx = ... | code_fim | hard | {
"lang": "rust",
"repo": "physics3D/mandelbrot-rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return iterationen;
}
fn konvertiereIterationenZuFarbe(gezaehlteIterationen: i64) -> image::Rgb<u8> {
let ergebnis = (gezaehlteIterationen as f64 / maxIterationen as f64 * 255.0) as u8;
return image::Rgb([ergebnis, ergebnis, ergebnis]);
}
fn main() {
let mut imgbuf: image::RgbImage = ima... | code_fim | hard | {
"lang": "rust",
"repo": "physics3D/mandelbrot-rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: physics3D/mandelbrot-rust path: /src/main.rs
static bildName: &str = "mandelbrot.png";
static breite: u32 = 1920;
static hoehe: u32 = 1080;
static maxIterationen: i64 = 1000;
static realteilMittelpunkt: f64 = 0.0;
static imaginaerteilMittelpunkt: f64 = 0.0;
static zoom: i64 = 500;
<|fim_suffix|... | code_fim | hard | {
"lang": "rust",
"repo": "physics3D/mandelbrot-rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devyn/kit path: /kernel/cpu.rs
/*******************************************************************************
*
* kit/kernel/cpu.rs
*
* vim:ft=rust:ts=4:sw=4:et:tw=80
*
* Copyright (C) 2015-2021, Devyn Cairns
* Redistribution of this file is permitted under the terms of the simplified
... | code_fim | hard | {
"lang": "rust",
"repo": "devyn/kit",
"path": "/kernel/cpu.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[repr(C)]
pub struct CpuLocalData {
/// 0x00 - a guaranteed valid place for a small amount of temporary data
///
/// The syscall handler uses this in order to have a place to dump the user
/// stack pointer
scratch: [u64; 4],
/// 0x20 - pointer to current process hardware state
... | code_fim | medium | {
"lang": "rust",
"repo": "devyn/kit",
"path": "/kernel/cpu.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # If a jump to D would leave us unable to move or jump,
# (E is false and H is false), don't jump:
NOT E J # J = false if no ground at E
NOT J J # J = true if ground at E
OR H J # J = true if ground at E *or* H
# Jump if ground at E or H plus part1 conditions:
AND T J
RUN... | code_fim | hard | {
"lang": "rust",
"repo": "jsdw/advent-of-code-2019",
"path": "/src/days/day21.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jsdw/advent-of-code-2019 path: /src/days/day21.rs
use crate::error::Error;
use crate::support::{ Terminal, IntoReadIter, Uppercase };
use std::io::{ Read, sink, stdin, stdout };
pub fn both_parts(input: &str, interactive: bool) -> Result<(), Error> {
if interactive {
let mut termin... | code_fim | hard | {
"lang": "rust",
"repo": "jsdw/advent-of-code-2019",
"path": "/src/days/day21.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[test]
fn test_guid() {
use std::collections::HashMap;
let guid = GuidGen::new(0, 0);
let mut map = HashMap::new();
let mut i = 1000000;
while i > 0 {
let uuid = guid.gen(1).0;
map.insert(uuid, "");
i = i - 1;
}
assert_eq!(map.len(), 1000000);
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "GaiaWorld/pi_lib",
"path": "/guid/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::collections::HashMap;
let guid = GuidGen::new(0, 0);
let mut map = HashMap::new();
let mut i = 1000000;
while i > 0 {
let uuid = guid.gen(1).0;
map.insert(uuid, "");
i = i - 1;
}
assert_eq!(map.len(), 1000000);
}<|fim_prefix|>// repo: GaiaWorld/pi_lib path... | code_fim | hard | {
"lang": "rust",
"repo": "GaiaWorld/pi_lib",
"path": "/guid/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GaiaWorld/pi_lib path: /guid/src/lib.rs
#![feature(integer_atomics)]
/**
* 全局唯一ID, 128位
* {节点启动后的运行时间(纳秒ns)(8字节-584.9年),节点启动时间(单位s)(4字节-136年),节点编号(2字节),控制编号(2字节)}
* 同一个GuidGen分配的guid,保证time不重复
*
* 分布式系统可以利用控制编号来管理hash,进行一致hash命中
*/
extern crate time;
use std::sync::atomic::{A... | code_fim | hard | {
"lang": "rust",
"repo": "GaiaWorld/pi_lib",
"path": "/guid/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgrussell/bupstash path: /src/fmtutil.rs
pub fn format_timestamp(ts: &chrono::DateTime<chrono::Utc>, utc_timestamps: bool) -> String {
let tsfmt = "%Y/%m/%d %T";
if utc_timestamps {
ts.format(tsfmt).to_string()
} else {
chrono::DateTime::<chrono::Local>::from(*ts)
... | code_fim | hard | {
"lang": "rust",
"repo": "jgrussell/bupstash",
"path": "/src/fmtutil.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (n % 1_000_000_000) / 10_000_000
)
} else if n > 1_000_000 {
format!("{}.{:0>2}MB", n / 1_000_000, (n % 1_000_000) / 10_000)
} else if n > 1_000 {
format!("{}.{:0>2}kB", n / 1_000, (n % 1_000) / 10)
} else {
format!("{}B", n)
}
}<|fim_prefix|>// repo: jgr... | code_fim | hard | {
"lang": "rust",
"repo": "jgrussell/bupstash",
"path": "/src/fmtutil.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for word in text.split_whitespace() {
let count = map.entry(word).or_insert(0);
*count += 1;
}
println!("{:?}", map);
println!("{:?}", scores);
}<|fim_prefix|>// repo: alisyahidin/learn-rust path: /src/get_collections/mod.rs
use std::collections::HashMap;
pub fn get_vector() {
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "alisyahidin/learn-rust",
"path": "/src/get_collections/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alisyahidin/learn-rust path: /src/get_collections/mod.rs
use std::collections::HashMap;
pub fn get_vector() {
let mut vector: Vec<u8> = Vec::new();
vector.push(3);
vector.push(7);
vector.push(255);
for (pos, i) in vector.iter().enumerate() {
println!("loop vector: {} {}", pos, i)... | code_fim | medium | {
"lang": "rust",
"repo": "alisyahidin/learn-rust",
"path": "/src/get_collections/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn is_lychrel(mut n: u64) -> bool {
for i in 0..50 {
let (reverse_n, is_palindromic) = get_reverse_n(n);
if i > 0 && is_palindromic {
return false;
}
n += reverse_n;
}
// NOTE: `reverse_n` value is not needed here, so we could split the `get_reverse_... | code_fim | hard | {
"lang": "rust",
"repo": "david-sk/projecteuler",
"path": "/src/problems/0055_lychrel_numbers/v1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: david-sk/projecteuler path: /src/problems/0055_lychrel_numbers/v1.rs
//
// Lychrel numbers, v1
// https://projecteuler.net/problem=55
//
// If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
// Not all numbers produce palindromes so quickly. For example,
// 349 + 943 = 1292... | code_fim | hard | {
"lang": "rust",
"repo": "david-sk/projecteuler",
"path": "/src/problems/0055_lychrel_numbers/v1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..50 {
let (reverse_n, is_palindromic) = get_reverse_n(n);
if i > 0 && is_palindromic {
return false;
}
n += reverse_n;
}
// NOTE: `reverse_n` value is not needed here, so we could split the `get_reverse_n`
// function to only return wh... | code_fim | medium | {
"lang": "rust",
"repo": "david-sk/projecteuler",
"path": "/src/problems/0055_lychrel_numbers/v1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nabijaczleweli/tweetr path: /src/ops/queued_tweet.rs
//! Queued tweets to be posted
//!
//! Okay, so here's how this shit works.
//!
//! We do not serialise `QueuedTweet` directly, because it does ugly things to serialise `DateTime` (namely: subkeys).
//! Instead, we convert it to a `QueuedTweet... | code_fim | hard | {
"lang": "rust",
"repo": "nabijaczleweli/tweetr",
"path": "/src/ops/queued_tweet.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> QueuedTweetForSerialisation {
author: qt.author,
time: qt.time.to_rfc3339(),
content: qt.content,
time_posted: qt.time_posted.map(|dt| dt.to_rfc3339()),
id: qt.id,
}
}
}
impl Into<Result<QueuedTweet, ParseError>> for QueuedTw... | code_fim | hard | {
"lang": "rust",
"repo": "nabijaczleweli/tweetr",
"path": "/src/ops/queued_tweet.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sphere.append_translation(&Translation3 { vector: pos.coords });
let mut sphere = Sphere {
id: None,
gfx: sphere,
color,
};
sphere.set_color(color);
sphere
}
pub fn set_color(
&mut self,
color: Color,
... | code_fim | hard | {
"lang": "rust",
"repo": "dillonhicks/holodeck",
"path": "/crates/holodeck-viewer/src/world/sphere.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dillonhicks/holodeck path: /crates/holodeck-viewer/src/world/sphere.rs
use crate::{
deps::{
kiss3d::window::Window,
na::{
Point3,
Translation3,
},
},
engine::GraphicsNode,
theme::Color,
world::{
update_graphics_node,
... | code_fim | hard | {
"lang": "rust",
"repo": "dillonhicks/holodeck",
"path": "/crates/holodeck-viewer/src/world/sphere.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn encrypt(data: &[u8], key: &[u8], iv: &[u8]) -> Result<Vec<u8>, ()> {
openssl::symm::encrypt(openssl::symm::Cipher::aes_256_cbc(), key, Some(iv), data)
.map_err(|_| ())
}
pub fn decrypt(data: &[u8], key: &[u8], iv: &[u8]) -> Result<SafeVec, ()> {
openssl::symm::decrypt(openssl::symm... | code_fim | medium | {
"lang": "rust",
"repo": "conradkleinespel/rooster",
"path": "/src/aes.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn decrypt(data: &[u8], key: &[u8], iv: &[u8]) -> Result<SafeVec, ()> {
openssl::symm::decrypt(openssl::symm::Cipher::aes_256_cbc(), key, Some(iv), data)
.map_err(|_| ())
.map(|vec| SafeVec::new(vec))
}<|fim_prefix|>// repo: conradkleinespel/rooster path: /src/aes.rs
// The code i... | code_fim | medium | {
"lang": "rust",
"repo": "conradkleinespel/rooster",
"path": "/src/aes.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: conradkleinespel/rooster path: /src/aes.rs
// The code in this file is copied from the "rust-crypto" Git repository.
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/li... | code_fim | medium | {
"lang": "rust",
"repo": "conradkleinespel/rooster",
"path": "/src/aes.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let reader = load_data("examples/data/day5.txt")?;
// let examples = vec![("FBFBBFFRLR", (44, 5, 357)),("BFFFBBFRRR", (70, 7, 567)) , ("FFFBBBFRRR", (14, 7, 119)), ("BBFFBBFRLL", (102, 4, 820))];
// for (src, res) in examples.iter(){
// let decoded = decode(src);
// assert... | code_fim | hard | {
"lang": "rust",
"repo": "entangled90/aoc2020",
"path": "/examples/day5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: entangled90/aoc2020 path: /examples/day5.rs
use aoc2020::aoc::load_data;
use nom::{
bits::complete::*, branch::*, bytes::complete::*, character::complete::*, combinator::*,
multi::*, sequence::*, IResult,
};
use regex::Regex;
use std::collections::HashMap;
use std::io::BufRead;
fn binar... | code_fim | hard | {
"lang": "rust",
"repo": "entangled90/aoc2020",
"path": "/examples/day5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shunding/genco path: /src/java/constructor.rs
//! Data structure for constructors
use super::argument::Argument;
use super::modifier::Modifier;
use con_::Con::Owned;
use cons::Cons;
use element::Element;
use into_tokens::IntoTokens;
use java::Java;
use tokens::Tokens;
/// Model for Java Constr... | code_fim | hard | {
"lang": "rust",
"repo": "shunding/genco",
"path": "/src/java/constructor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_throws() {
let mut c = Constructor::new();
c.throws = Some("Exception".into());
let t: Tokens<Java> = (Cons::Borrowed("Foo"), c).into();
let s = t.to_string();
let out = s.as_ref().map(|s| s.as_str());
assert_eq!(Ok("public Foo() thr... | code_fim | hard | {
"lang": "rust",
"repo": "shunding/genco",
"path": "/src/java/constructor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (name, mut c) = self;
let args: Vec<Tokens<Java>> = c.arguments.into_iter().map(|a| a.into_tokens()).collect();
let args: Tokens<Java> = args.into_tokens();
let mut sig: Tokens<Java> = Tokens::new();
c.modifiers.sort();
sig.extend(c.modifiers.into_ite... | code_fim | hard | {
"lang": "rust",
"repo": "shunding/genco",
"path": "/src/java/constructor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: horacio/kai path: /src/clock.rs
use console::style;
use console::Term;
use crate::controls::{ctrl_pomo, Ctrl};
use indicatif::{ProgressBar, ProgressStyle};
use std::thread;
use std::time::Duration;
pub fn countdown(count_from: u64, todo_name: String) -> Result<(), ()> {
let term = Term::st... | code_fim | hard | {
"lang": "rust",
"repo": "horacio/kai",
"path": "/src/clock.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in (1..=count_from).rev() {
bar.inc(1); // Increment loader
thread::sleep(Duration::from_secs(1));
}
println!(
"{}",
style("+--------------------------------------------------------+").blue()
);
});
handle.join(... | code_fim | medium | {
"lang": "rust",
"repo": "horacio/kai",
"path": "/src/clock.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the world particle-system list. With the returned body, use
/// b2ParticleSystem::GetNext to get the next particle-system in the world
/// list. A NULL particle-system indicates the end of the list.
/// @return the head of the world particle-system list.
pub fn get_particle... | code_fim | hard | {
"lang": "rust",
"repo": "SpaceEraser/liquidfun-rust",
"path": "/src/box2d/dynamics/world.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SpaceEraser/liquidfun-rust path: /src/box2d/dynamics/world.rs
use super::body::*;
use super::world_callbacks::*;
use super::super::common::math::*;
use super::super::common::settings::*;
use super::super::particle::particle_system::*;
use super::joints;
pub enum B2World {}
extern {
... | code_fim | hard | {
"lang": "rust",
"repo": "SpaceEraser/liquidfun-rust",
"path": "/src/box2d/dynamics/world.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Construct a world object.
/// @param gravity the world gravity vector.
pub fn new(gravity: &Vec2) -> World {
unsafe { World::from_raw(b2World_New(gravity)) }
}
/// Register a contact event listener. The listener is owned by you and must
/// remain in scope.
pu... | code_fim | hard | {
"lang": "rust",
"repo": "SpaceEraser/liquidfun-rust",
"path": "/src/box2d/dynamics/world.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config = self.load_config();
let parser = Parsing::new(config);
match parser.render(&self) {
Err(e) => Err(e),
Ok(r) => Ok(r),
}
}
fn to_file(&self) -> Result<(), failure::Error> {
let config = self.load_config();
let fil... | code_fim | medium | {
"lang": "rust",
"repo": "bologer/php8-xdebug",
"path": "/generator/src/generate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn generate(&self) -> Result<String, Box<dyn failure::Fail>> {
let config = self.load_config();
let parser = Parsing::new(config);
match parser.render(&self) {
Err(e) => Err(e),
Ok(r) => Ok(r),
}
}
fn to_file(&self) -> Result<(), failure... | code_fim | hard | {
"lang": "rust",
"repo": "bologer/php8-xdebug",
"path": "/generator/src/generate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bologer/php8-xdebug path: /generator/src/generate.rs
use std::path::Path;
use std::fs;
use crate::template_parser::Parsing;
use serde::Serialize;
use std::fs::File;
use std::io::prelude::*;
use crate::structs::ContainerType;
use config::Config;
use std::collections::HashMap;
use serde::export::f... | code_fim | hard | {
"lang": "rust",
"repo": "bologer/php8-xdebug",
"path": "/generator/src/generate.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wiltonlazary/wasmer path: /lib/wasi/src/syscalls/wasm32.rs
use crate::syscalls::types::*;
use std::mem;
use wasmer::WasmCell;
pub fn platform_clock_res_get(
clock_id: __wasi_clockid_t,
resolution: WasmCell<__wasi_timestamp_t>,
) -> __wasi_errno_t {
let t_out = 1 * 1_000_000_000;
... | code_fim | medium | {
"lang": "rust",
"repo": "wiltonlazary/wasmer",
"path": "/lib/wasi/src/syscalls/wasm32.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mixalturek/spirit path: /src/bodies.rs
//! Utility body wrapper types.
//!
//! There are some problems with `Box<dyn FnOnce()>` types in Rust. The types here are less
//! convenient but actually usable types with similar function.
use std::sync::Arc;
<|fim_suffix|>}
impl<F: FnOnce(Param) -> R... | code_fim | medium | {
"lang": "rust",
"repo": "mixalturek/spirit",
"path": "/src/bodies.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A workaround type for `Box<dyn FnOnce() -> Result<(), Error>`.
///
/// Since it is not possible to use the aforementioned type in any meaningful way in Rust yet, this
/// works around the problem. The type has a [`run`][InnerBody::run] method which does the same thing.
///
/// This is passed as parame... | code_fim | hard | {
"lang": "rust",
"repo": "mixalturek/spirit",
"path": "/src/bodies.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/headers/src/util/csv.rs
use
std
:
:
fmt
;
/
/
/
Reads
a
comma
-
delimited
raw
header
into
a
Vec
.
pub
(
crate
)
fn
from_comma_delimited
<
'
i
I
T
E
>
(
values
:
&
mut
I
)
-
>
Result
<
E
:
:
Error
>
where
I
:
Iterator
<
Item
=
&
'
i
:
:
HeaderVa... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/headers/src/util/csv.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>r
mut
iter
:
impl
Iterator
<
Item
=
T
>
)
-
>
fmt
:
:
Result
{
if
let
Some
(
part
)
=
iter
.
next
(
)
{
fmt
:
:
Display
:
:
fmt
(
&
part
f
)
?
;
}
for
part
in
iter
{
f
.
write_str
(
"
"
)
?
;
fmt
:
:
Display
:
:
fmt
(
&
part
f
)
?
;
}
Ok
(
(
)
)
}<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/headers/src/util/csv.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>)
.
map
(
|
x
|
x
.
parse
(
)
.
map_err
(
|
_
|
:
:
Error
:
:
invalid
(
)
)
)
}
)
}
)
.
collect
(
)
}
/
/
/
Format
an
array
into
a
comma
-
delimited
string
.
pub
(
crate
)
fn
fmt_comma_delimited
<
T
:
fmt
:
:
Display
>
(
f
:
&
mut
fmt
:
:
Formatter
mut
iter
:
impl
Iterator
<
Item
=
T
>
)
-
>
fmt
:
:
Resul... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/headers/src/util/csv.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>add_basic_tests!(test_h160, H160);
add_basic_tests!(test_h256, H256);
add_basic_tests!(test_h512, H512);
add_basic_tests!(test_h520, H520);<|fim_prefix|>// repo: nervosnetwork/ckb path: /util/fixed-hash/core/src/tests/mod.rs
mod impls;
mod serde;
mod std_cmp;
mod std_fmt;
mod std_str;
macro_rules! add_b... | code_fim | medium | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/util/fixed-hash/core/src/tests/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nervosnetwork/ckb path: /util/fixed-hash/core/src/tests/mod.rs
mod impls;
mod serde;
mod std_cmp;
mod std_fmt;
mod std_str;
<|fim_suffix|> let zeros = crate::$type::default();
let zeros_clone = zeros.clone();
assert_eq!(zeros, zeros_clone);
}
};
}
... | code_fim | medium | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/util/fixed-hash/core/src/tests/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arnej/rmilter path: /src/milter.rs
use std::convert::{TryFrom, TryInto};
use std::io::{Read, Write};
use std::net::{TcpListener, TcpStream, ToSocketAddrs};
use crate::message_handler::MessageHandler;
use crate::milter_error::MilterError;
use crate::milter_message::{MilterMessage, MilterProtocol... | code_fim | hard | {
"lang": "rust",
"repo": "arnej/rmilter",
"path": "/src/milter.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !self.handle_message(&mut stream, &msg)? {
keep_open = false;
break;
}
if collected_bytes.len() >= std::mem::size_of::<u32>() {
... | code_fim | hard | {
"lang": "rust",
"repo": "arnej/rmilter",
"path": "/src/milter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Opens the connection to the MTA service.
///
/// - `address` defines the socket address of the MTA.
pub fn run<S: ToSocketAddrs>(&'a mut self, address: S) -> Result<(), MilterError> {
let listener = TcpListener::bind(address)?;
for stream in listener.incoming() {
... | code_fim | hard | {
"lang": "rust",
"repo": "arnej/rmilter",
"path": "/src/milter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RobDavenport/moba path: /server/src/engine/components/visible.rs
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Visible {
<|fim_suffix|>ll,
VisibleInRange,
InvisibleAll,
// TODO: Need more?
}<|fim_middle|>pub visibility: VisibilityType,
}
#[derive(Clone, Copy, Debug, Partia... | code_fim | medium | {
"lang": "rust",
"repo": "RobDavenport/moba",
"path": "/server/src/engine/components/visible.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tialEq)]
#[allow(dead_code)]
pub enum VisibilityType {
VisibleAll,
VisibleInRange,
InvisibleAll,
// TODO: Need more?
}<|fim_prefix|>// repo: RobDavenport/moba path: /server/src/engine/components/visible.rs
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Visible {
<|fim_middle|>pub... | code_fim | medium | {
"lang": "rust",
"repo": "RobDavenport/moba",
"path": "/server/src/engine/components/visible.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Handler<RoutedMessage> for SlowStartingActor {
type Result = ();
fn handle(&mut self, msg: RoutedMessage, _: &mut Self::Context) -> Self::Result {
debug!("Slow starting got routed message: {:?}", &msg);
}
}
struct SupervisorActor {
addr: RwLock<HashMap<u16, Addr<SlowStarting... | code_fim | hard | {
"lang": "rust",
"repo": "akurdyukov/test-actix-arbiter",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ctx.spawn(f);
}
}
impl Handler<RoutedMessage> for SupervisorActor {
type Result = ();
fn handle(&mut self, msg: RoutedMessage, ctx: &mut Self::Context) -> Self::Result {
debug!("Supervisor got message");
let f = self.addr.read().map(|guard| {
d... | code_fim | hard | {
"lang": "rust",
"repo": "akurdyukov/test-actix-arbiter",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akurdyukov/test-actix-arbiter path: /src/main.rs
#[macro_use]
extern crate actix;
extern crate futures;
extern crate tokio;
#[macro_use]
extern crate log;
extern crate simple_logger;
extern crate futures_locks;
extern crate rand;
use std::{thread, time};
use std::collections::HashMap;
use futu... | code_fim | hard | {
"lang": "rust",
"repo": "akurdyukov/test-actix-arbiter",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.bytes.encode(sink);
}
}
impl ComponentSection for NestedComponentSection<'_> {
fn id(&self) -> u8 {
ComponentSectionId::Component.into()
}
}<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/wasm-encoder/src/component/components.rs
use cr... | code_fim | medium | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/wasm-encoder/src/component/components.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> ComponentSectionId::Component.into()
}
}<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/wasm-encoder/src/component/components.rs
use crate::{Component, ComponentSection, ComponentSectionId, Encode};
<|fim_middle|>
#[derive(Clone, Debug)]
pub stru... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/wasm-encoder/src/component/components.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/wasm-encoder/src/component/components.rs
use crate::{Component, ComponentSection, ComponentSectionId, Encode};
<|fim_suffix|>impl ComponentSection for NestedComponentSection<'_> {
fn id(&self) -> u8 {
ComponentSect... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/wasm-encoder/src/component/components.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> config.file_source_config = if should_use_watchman() {
FileSourceKind::Watchman
} else {
FileSourceKind::WalkDir
};
config.repersist_operations = opt.repersist;
if opt.watch && !matches!(&config.file_source_config, FileSourceKind::Watchman) {
panic!(
... | code_fim | hard | {
"lang": "rust",
"repo": "josephsavona/relay",
"path": "/compiler/crates/relay-compiler/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: josephsavona/relay path: /compiler/crates/relay-compiler/src/main.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 clap::{ArgEnum, Parser};
use com... | code_fim | hard | {
"lang": "rust",
"repo": "josephsavona/relay",
"path": "/compiler/crates/relay-compiler/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hoyon/ray-tracer-challenge path: /src/tuple.rs
use crate::util;
use std::fmt;
use std::ops;
#[derive(Clone, Copy)]
pub struct Tuple {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}
impl Tuple {
pub fn point(x: f32, y: f32, z: f32) -> Self {
Tuple { x, y, z, w: 1.... | code_fim | hard | {
"lang": "rust",
"repo": "hoyon/ray-tracer-challenge",
"path": "/src/tuple.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn point_makes_point() {
let p = Tuple::point(1.3, 1.5, 45.8);
assert_eq!(p, Tuple::raw(1.3, 1.5, 45.8, 1.0))
}
#[test]
fn vector_makes_vector() {
let v = Tuple::vector(1.3, 1.5, 45.8);
assert_eq!(v, Tuple::raw(1.3, 1.5, 45.8, 0.0))
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "hoyon/ray-tracer-challenge",
"path": "/src/tuple.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = Tuple::vector(3.0, 2.0, 1.0);
let b = Tuple::vector(5.0, 6.0, 7.0);
assert_eq!(a - b, Tuple::vector(-2.0, -4.0, -6.0));
}
#[test]
fn subtracting_vector_from_zero() {
let zero = Tuple::vector(0.0, 0.0, 0.0);
let v = Tuple::vector(1.0, -2.0, 3.0);... | code_fim | hard | {
"lang": "rust",
"repo": "hoyon/ray-tracer-challenge",
"path": "/src/tuple.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn fibo_seq(n: u32) -> u128 {
let mut r = 1;
if n > 1 {
let mut m1 = 1;
let mut m2 = 1;
for _ in 1..n {
r = m1 + m2;
m2 = m1;
m1 = r;
}
}
r
}<|fim_prefix|>// repo: antoinemadec/test path: /rust/rust-lang.org/fibo/src/main... | code_fim | hard | {
"lang": "rust",
"repo": "antoinemadec/test",
"path": "/rust/rust-lang.org/fibo/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: antoinemadec/test path: /rust/rust-lang.org/fibo/src/main.rs
// https://doc.rust-lang.org/stable/book/ch03-05-control-flow.html
fn main() {
<|fim_suffix|> let mut r = 1;
if n > 1 {
let mut m1 = 1;
let mut m2 = 1;
for _ in 1..n {
r = m1 + m2;
... | code_fim | hard | {
"lang": "rust",
"repo": "antoinemadec/test",
"path": "/rust/rust-lang.org/fibo/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nevrax/puddle path: /src/core/src/vision/mod.rs
use std::ffi::CString;
use std::os::raw::c_char;
use std::path::Path;
use std::process::Command;
use std::slice;
use std::sync::{Arc, Mutex};
use grid::{Blob, Droplet, DropletId, Location, SimpleBlob};
mod transform;
use self::transform::GridTran... | code_fim | hard | {
"lang": "rust",
"repo": "nevrax/puddle",
"path": "/src/core/src/vision/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let corners = vec![
Point::new(y, x),
Point::new(y + dy, x),
Point::new(y + dy, x + dx),
Point::new(y, x + dx),
];
// the try_new constructor *assumes* the convexity of the points
ConvexPolygon::try_new(corners).unwrap()
}
// no whitespace, these are passe... | code_fim | hard | {
"lang": "rust",
"repo": "nevrax/puddle",
"path": "/src/core/src/vision/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn intersect(&self, _x: Real, _y: Real) -> bool {
false // TODO: need impl
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PathCommand {
Move([Real; 2]),
MoveRel([Real; 2]),
Line([Real; 2]),
LineRel([Real; 2]),
LineAlonX(Real),
LineAlonXRel(Real),
Lin... | code_fim | hard | {
"lang": "rust",
"repo": "exgui/exgui",
"path": "/core/src/node/shape/path.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: exgui/exgui path: /core/src/node/shape/path.rs
use crate::node::{Clip, Fill, Real, Stroke, Transform, TransformMatrix};
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Path {
pub id: Option<String>,
pub cmd: Vec<PathCommand>,
pub transparency: Real,
pub stroke: Option<Str... | code_fim | medium | {
"lang": "rust",
"repo": "exgui/exgui",
"path": "/core/src/node/shape/path.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: okdistribute/deltar path: /src/main.rs
#[macro_use]
extern crate serde;
use std::collections::BTreeMap;
use uuid::prelude::*;
use web_view::*;
fn main() {
let webview = web_view::builder()
.title("deltar")
.content(content())
.size(800, 600)
.resizable(true)... | code_fim | hard | {
"lang": "rust",
"repo": "okdistribute/deltar",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, Clone)]
struct Todo {
title: String,
done: bool,
}
#[derive(Serialize, Deserialize)]
#[serde(tag = "namespace", rename_all = "camelCase")]
pub enum Cmd {
Todo(TodoCmd),
}
#[derive(Serialize, Deserialize)]
#[serde(tag = "cmd", content = "payload", renam... | code_fim | hard | {
"lang": "rust",
"repo": "okdistribute/deltar",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Format errors from the cloudflare-rs cli for printing.
// Optionally takes an argument for providing a function that maps error code numbers to
// helpful additional information about why someone is getting an error message and how to fix it.
pub fn format_error(e: ApiFailure, err_helper: Option<&dyn F... | code_fim | hard | {
"lang": "rust",
"repo": "adaptive/wrangler",
"path": "/src/http/cf.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn cf_v4_client(user: &GlobalUser) -> Result<HttpApiClient> {
let config = HttpApiClientConfig {
http_timeout: Duration::from_secs(DEFAULT_HTTP_TIMEOUT_SECONDS),
default_headers: headers(None),
};
let environment = get_environment()?;
HttpApiClient::new(Credentials::f... | code_fim | hard | {
"lang": "rust",
"repo": "adaptive/wrangler",
"path": "/src/http/cf.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adaptive/wrangler path: /src/http/cf.rs
use std::env;
use std::time::Duration;
use cloudflare::framework::async_api;
use cloudflare::framework::auth::Credentials;
use cloudflare::framework::response::ApiFailure;
use cloudflare::framework::{Environment, HttpApiClient, HttpApiClientConfig};
use h... | code_fim | hard | {
"lang": "rust",
"repo": "adaptive/wrangler",
"path": "/src/http/cf.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anilkhandei/RustProgramming path: /raindrops/src/lib.rs
pub fn raindrops(n: u32) -> String {
let pling=n%3==0;
let plang=n%5==0;
let plong=n%7==0;
let no_sound=n.to_string();
if pling && plang && plong {
return String::from("PlingPlangPlong");
}
else if pling... | code_fim | medium | {
"lang": "rust",
"repo": "anilkhandei/RustProgramming",
"path": "/raindrops/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
else if plang{
return String::from("Plang");
}
else if plong{
return String::from("Plong");
}
else{
return no_sound;
}
}<|fim_prefix|>// repo: anilkhandei/RustProgramming path: /raindrops/src/lib.rs
pub fn raindrops(n: u32) -> String {
let pling=n%3... | code_fim | medium | {
"lang": "rust",
"repo": "anilkhandei/RustProgramming",
"path": "/raindrops/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mithril1992/rust_practice path: /src/bin/fizzbuzz.rs
extern crate getopts;
use getopts::Options;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let program = args[0].clone();
let mut opts = Options::new();
opts.reqopt("f", "from", "begining number"... | code_fim | medium | {
"lang": "rust",
"repo": "mithril1992/rust_practice",
"path": "/src/bin/fizzbuzz.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn fizzbuzz(from: usize, to: usize) {
for number in from ..= to {
if number % 15 == 0 {
println!("fizzbuzz ");
} else if number % 3 == 0 {
println!("fizz ");
} else if number % 5 == 0 {
println!("buzz ");
} else {
println!... | code_fim | hard | {
"lang": "rust",
"repo": "mithril1992/rust_practice",
"path": "/src/bin/fizzbuzz.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {s: Chars}
for i in 0..s.len() {
if (s[i].is_lowercase()) ^ (i % 2 == 0) {
println!("No");
return;
}
}
println!("Yes");
}<|fim_prefix|>// repo: hinagis/abc192 path: /src/bin/b.rs
use proconio::{input, marker::Chars};
<|fim_middle|>fn main()... | code_fim | easy | {
"lang": "rust",
"repo": "hinagis/abc192",
"path": "/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hinagis/abc192 path: /src/bin/b.rs
use proconio::{input, marker::Chars};
<|fim_suffix|> input! {s: Chars}
for i in 0..s.len() {
if (s[i].is_lowercase()) ^ (i % 2 == 0) {
println!("No");
return;
}
}
println!("Yes");
}<|fim_middle|>fn main()... | code_fim | easy | {
"lang": "rust",
"repo": "hinagis/abc192",
"path": "/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..s.len() {
if (s[i].is_lowercase()) ^ (i % 2 == 0) {
println!("No");
return;
}
}
println!("Yes");
}<|fim_prefix|>// repo: hinagis/abc192 path: /src/bin/b.rs
use proconio::{input, marker::Chars};
<|fim_middle|>fn main() {
input! {s: Chars... | code_fim | easy | {
"lang": "rust",
"repo": "hinagis/abc192",
"path": "/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wayslog/tikv path: /components/engine/src/errors.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use std::{error, result};
use tikv_util::escape;
quick_error! {
#[derive(Debug)]
pub enum Error {
// RocksDb uses plain string as the error.
RocksDb(ms... | code_fim | medium | {
"lang": "rust",
"repo": "wayslog/tikv",
"path": "/components/engine/src/errors.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Error::NotInRange(key, region_id, start_key, end_key) = err {
errorpb.mut_key_not_in_region().set_key(key);
errorpb.mut_key_not_in_region().set_region_id(region_id);
errorpb.mut_key_not_in_region().set_start_key(start_key);
errorpb.mut_key_not... | code_fim | hard | {
"lang": "rust",
"repo": "wayslog/tikv",
"path": "/components/engine/src/errors.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_errors() {
assert_eq!(format!("{}", StringError::FailedToString), "failed to convert value to string");
}
}<|fim_prefix|>// repo: phR0ze/fungus path: /src/errors/string_error.rs
use std::{error::Error as StdError, fmt};
// An error indicating that something went wrong... | code_fim | medium | {
"lang": "rust",
"repo": "phR0ze/fungus",
"path": "/src/errors/string_error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(format!("{}", StringError::FailedToString), "failed to convert value to string");
}
}<|fim_prefix|>// repo: phR0ze/fungus path: /src/errors/string_error.rs
use std::{error::Error as StdError, fmt};
// An error indicating that something went wrong with a file operation
#[derive(Clo... | code_fim | medium | {
"lang": "rust",
"repo": "phR0ze/fungus",
"path": "/src/errors/string_error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: phR0ze/fungus path: /src/errors/string_error.rs
use std::{error::Error as StdError, fmt};
// An error indicating that something went wrong with a file operation
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum StringError {
/// An error indicating a failure to convert ... | code_fim | medium | {
"lang": "rust",
"repo": "phR0ze/fungus",
"path": "/src/errors/string_error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod array;
pub mod flags;
pub mod objects;
pub mod types;
pub mod ufunc;
pub use self::array::*;
pub use self::flags::*;
pub use self::objects::*;
pub use self::types::*;
pub use self::ufunc::*;<|fim_prefix|>// repo: PyO3/rust-numpy path: /src/npyffi/mod.rs
//! Low-Level bindings for NumPy C API.
//... | code_fim | hard | {
"lang": "rust",
"repo": "PyO3/rust-numpy",
"path": "/src/npyffi/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PyO3/rust-numpy path: /src/npyffi/mod.rs
//! Low-Level bindings for NumPy C API.
//!
//! <https://numpy.org/doc/stable/reference/c-api>
#![allow(
non_camel_case_types,
missing_docs,
missing_debug_implementations,
clippy::too_many_arguments,
clippy::missing_safety_doc
)]
use ... | code_fim | hard | {
"lang": "rust",
"repo": "PyO3/rust-numpy",
"path": "/src/npyffi/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hayaoR/useful_function path: /src/lazysegtree.rs
/// 区間は0-indexed
/// eはopの単位元 op(a, e) = op(e, a) = a
/// idはmappingの恒等写像 mapping(id, a) = a
pub struct LazySegTree<T, F> {
n: usize,
dat: Vec<T>,
lazy: Vec<F>,
e: T,
id: F,
op: fn(T, T) -> T,
mapping: fn(F, T) -> T,
... | code_fim | hard | {
"lang": "rust",
"repo": "hayaoR/useful_function",
"path": "/src/lazysegtree.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.eval(k);
if r <= a || b <= l {
return self.e;
}
if a <= l && r <= b {
return self.dat[k];
} else {
let vl = self.query_inner(a, b, k * 2 + 1, l, (l + r) / 2);
let vr = self.query_inner(a, b, k * 2 + 2, (l + r) / 2... | code_fim | hard | {
"lang": "rust",
"repo": "hayaoR/useful_function",
"path": "/src/lazysegtree.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(badges) = badges {
for (k, v) in badges {
let attributes_json = serde_json::to_value(v).unwrap();
let json = json!({"badge_type": k, "attributes": attributes_json});
if serde_json::from_value::<Badge>(json).is_ok() {
... | code_fim | hard | {
"lang": "rust",
"repo": "emilio/rustc-perf",
"path": "/collector/benchmarks/crates.io/src/badge.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let json = json!({"badge_type": k, "attributes": attributes_json});
if serde_json::from_value::<Badge>(json).is_ok() {
new_badges.push(NewBadge {
crate_id: krate.id,
badge_type: &**k,
... | code_fim | hard | {
"lang": "rust",
"repo": "emilio/rustc-perf",
"path": "/collector/benchmarks/crates.io/src/badge.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emilio/rustc-perf path: /collector/benchmarks/crates.io/src/badge.rs
use krate::Crate;
use schema::badges;
use diesel::pg::Pg;
use diesel::prelude::*;
use serde_json;
use std::collections::HashMap;
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case", ta... | code_fim | hard | {
"lang": "rust",
"repo": "emilio/rustc-perf",
"path": "/collector/benchmarks/crates.io/src/badge.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cestquilepatron/aries_modified path: /src/planning/classical/heuristics.rs
use crate::planning::classical::state::{Lit, Op, Operators, State};
use crate::planning::ref_store::RefStore;
pub type Cost = u64;
const INFTY: Cost = 2 ^ 50;
pub trait ApplicableOperators {
fn applicable_operators(... | code_fim | hard | {
"lang": "rust",
"repo": "Cestquilepatron/aries_modified",
"path": "/src/planning/classical/heuristics.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> conjunction.iter().map(move |&l| self.lit_costs[l]).sum()
}
}
pub fn hadd(state: &State, ops: &Operators) -> HAddResult {
let mut op_costs = RefStore::initialized(ops.size(), INFTY);
let mut update = RefStore::initialized(ops.size(), false);
for op in ops.iter() {
if ops.p... | code_fim | hard | {
"lang": "rust",
"repo": "Cestquilepatron/aries_modified",
"path": "/src/planning/classical/heuristics.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.