text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>pub const ERRNO_NOPROTOOPT: Errno = Errno(50);
pub const ERRNO_NOSPC: Errno = Errno(51);
pub const ERRNO_NOSYS: Errno = Errno(52);
pub const ERRNO_NOTCONN: Errno = Errno(53);
pub const ERRNO_NOTDIR: Errno = Errno(54);
pub const ERRNO_NOTEMPTY: Errno = Errno(55);
pub const ERRNO_NOTRECOVERABLE: Errno... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/wasi/src/lib_generated.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dcrime/Rust-snake-game path: /src/main.rs
use std::collections::VecDeque;
use minifb::{Key, KeyRepeat, WindowOptions};
use rand::random;
const WIDTH: usize = 200;
const HEIGHT: usize = 200;
const SCALE: usize = 4;
const FPS: usize = 30;
#[derive(Copy, Clone)]
struct Pos {
x: i32,
y: i... | code_fim | hard | {
"lang": "rust",
"repo": "dcrime/Rust-snake-game",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if tail.iter().any(|t| snake.collides(t.pos)) {
reset(&mut snake, &mut apple, &mut tail, &mut buffer)
}
if tail.len() > 0 {
for t in tail.iter_mut() {
draw(t.pos.x as usize, t.pos.y as usize, &mut buffer, 0xAAAAAA);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "dcrime/Rust-snake-game",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct LocalScopeDecl {
pub scope: Atom,
pub properties: Vec<Box<PropertyDecl>>,
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct EbnfBlock {
pub location: Location,
pub elements: Vec<EbnfElement>,
}
#[derive(Debug, ... | code_fim | hard | {
"lang": "rust",
"repo": "datum-lang/movable",
"path": "/typography/src/parse_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum LexerAtom {
Terminal(),
CharacterRange(),
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct VariablePattern {
pub location: Location,
pub name: Atom,
pub ebnf_suffix: Option<EbnfSuffix>,
}<|fim_prefix|>// repo... | code_fim | hard | {
"lang": "rust",
"repo": "datum-lang/movable",
"path": "/typography/src/parse_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: datum-lang/movable path: /typography/src/parse_tree.rs
use crate::location::Location;
use serde::{Deserialize, Serialize};
use string_cache::DefaultAtom as Atom;
#[derive(Debug, PartialEq)]
pub struct TypoGrammar(pub Vec<GrammarUnit>);
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub en... | code_fim | hard | {
"lang": "rust",
"repo": "datum-lang/movable",
"path": "/typography/src/parse_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wuggen/gramit path: /src/transform.rs
//! Assorted utilities for constructing 3D homogeneous transformation and projection matrices.
use super::*;
/// A builder struct for homogeneous transformation matrices.
///
/// A `Transform` is used to construct arbitrary affine transformations starting ... | code_fim | hard | {
"lang": "rust",
"repo": "wuggen/gramit",
"path": "/src/transform.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Scale by the given factors.
///
/// The scaling is performed independently per-axis, using the corresponding factor from the
/// factor vector.
#[inline(always)]
pub fn scale(self, factor: Vec3) -> Transform {
Transform {
mat: scale(factor) * self.mat,
... | code_fim | hard | {
"lang": "rust",
"repo": "wuggen/gramit",
"path": "/src/transform.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut mat = Mat4::identity();
mat.set_row(0, horiz.extend(0.0));
mat.set_row(1, cam_up.extend(0.0));
mat.set_row(2, -facing.extend(0.0));
mat[3][0] = -eye.dot(&horiz);
mat[3][1] = -eye.dot(&cam_up);
mat[3][2] = eye.dot(&facing);
mat
}
/// Build an orthographic normaliz... | code_fim | hard | {
"lang": "rust",
"repo": "wuggen/gramit",
"path": "/src/transform.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagebind/rote path: /src/modules/json.rs
use json::{self, JsonValue};
use lua;
use runtime::{Runtime, ScriptResult};
use std::error::Error;
fn parse(runtime: Runtime) -> ScriptResult {
fn push_value(runtime: &Runtime, value: &JsonValue) {
match value {
&JsonValue::Null ... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/rote",
"path": "/src/modules/json.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lua_type = runtime.state().type_of(index);
match lua_type {
Some(lua::Type::Nil) | None => Ok(JsonValue::Null),
Some(lua::Type::Boolean) => Ok(runtime.state().to_bool(index).into()),
Some(lua::Type::Number) => Ok(runtime.state().to_number(index).int... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/rote",
"path": "/src/modules/json.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[panic_handler]
fn panic(_panic: &PanicInfo<'_>) -> ! {
loop {}
}
extern "C" fn _start() {
}<|fim_prefix|>// repo: gustafla/smol-rust-binary path: /src/main.rs
#![no_std]
#![no_main]
<|fim_middle|>use core::panic::PanicInfo;
| code_fim | easy | {
"lang": "rust",
"repo": "gustafla/smol-rust-binary",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gustafla/smol-rust-binary path: /src/main.rs
#![no_std]
#![no_main]
<|fim_suffix|> loop {}
}
extern "C" fn _start() {
}<|fim_middle|>use core::panic::PanicInfo;
#[panic_handler]
fn panic(_panic: &PanicInfo<'_>) -> ! {
| code_fim | medium | {
"lang": "rust",
"repo": "gustafla/smol-rust-binary",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: turbio/rustrace path: /src/trace.rs
use ray::Ray;
use screen::Drawable;
use material::Material;
use vec2::Vec2;
<|fim_suffix|> fn intersect(&self, ray: &Ray) -> Option<Intersection>;
}<|fim_middle|>#[derive(Clone)]
pub struct Intersection<'a> {
pub distance: f64,
pub normal: Vec2,
... | code_fim | medium | {
"lang": "rust",
"repo": "turbio/rustrace",
"path": "/src/trace.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn intersect(&self, ray: &Ray) -> Option<Intersection>;
}<|fim_prefix|>// repo: turbio/rustrace path: /src/trace.rs
use ray::Ray;
use screen::Drawable;
use material::Material;
use vec2::Vec2;
<|fim_middle|>#[derive(Clone)]
pub struct Intersection<'a> {
pub distance: f64,
pub normal: Vec2,
... | code_fim | medium | {
"lang": "rust",
"repo": "turbio/rustrace",
"path": "/src/trace.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thepowersgang/rust_os path: /Kernel/Core/memory/helpers/dma_buffer.rs
// "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/helpers/dma_buffer.rs
///! Helper type for DMA accesses
#[allow(unused_imports)]
use crate::prelude::*;
use crate::arch::memory::PAddr;
use crate::PAGE_SIZE;
us... | code_fim | hard | {
"lang": "rust",
"repo": "thepowersgang/rust_os",
"path": "/Kernel/Core/memory/helpers/dma_buffer.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn update_source(&mut self) {
if self.phys != virt::get_phys(self.source_ptr) {
unimplemented!();
}
}
}
pub struct Ranges<'a>(&'a [u8]);
impl<'a> Iterator for Ranges<'a>
{
type Item = (PAddr,usize);
fn next(&mut self) -> Option<Self::Item> {
if self.0.len() == 0 {
None
}
else {
... | code_fim | hard | {
"lang": "rust",
"repo": "thepowersgang/rust_os",
"path": "/Kernel/Core/memory/helpers/dma_buffer.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Group<O: Operator>: Magma<O> + Groupoid<O> {}
pub trait AbelianGroup<O: Operator>: Group<O> + Commutative<O> {}
impl<T, O: Operator> Magma<O> for T where T: Total<O> {}
impl<T, O: Operator> UnitalMagma<O> for T where T: Magma<O> + Identity<O> {}
impl<T, O: Operator> Semigroupoid<O> for T where... | code_fim | hard | {
"lang": "rust",
"repo": "TriedWorks/fructose",
"path": "/src/algebra/group.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TriedWorks/fructose path: /src/algebra/group.rs
//!
//! Structure of traits
//!
//! ```rustn't
//! Totality─────────► Magma───────┬─────┬─────┬──────────┐
//! │ │ │ │ ▼
//! ▼ │ │ │ Semigroup───... | code_fim | hard | {
"lang": "rust",
"repo": "TriedWorks/fructose",
"path": "/src/algebra/group.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait CommutativeMonoid<O: Operator>: Monoid<O> + Commutative<O> {}
pub trait Group<O: Operator>: Magma<O> + Groupoid<O> {}
pub trait AbelianGroup<O: Operator>: Group<O> + Commutative<O> {}
impl<T, O: Operator> Magma<O> for T where T: Total<O> {}
impl<T, O: Operator> UnitalMagma<O> for T where T: M... | code_fim | hard | {
"lang": "rust",
"repo": "TriedWorks/fructose",
"path": "/src/algebra/group.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut xor: Vec<u8> = Vec::new();
for n in 0..text_bytes.len() {
xor.push(text_bytes[n] ^ final_key_as_byte[n]);
}
xor.to_vec()
}
pub fn string_count(text:String) -> usize{
let diference : usize = text.chars().count() as usize;
diference... | code_fim | hard | {
"lang": "rust",
"repo": "alitoxSB/Applied-Cryptography",
"path": "/OPT_With_PGR/encrypt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alitoxSB/Applied-Cryptography path: /OPT_With_PGR/encrypt.rs
use std::str::from_utf8;
use std::str;
use std::vec::Vec;
pub mod encrypt {
use crate::pgr::pgr::pgr_function;
use crate::decrypt::decrypt::decrypt;
pub fn encryption(text: String, key: String, text_bytes: &[u8]) -> Vec<u8... | code_fim | hard | {
"lang": "rust",
"repo": "alitoxSB/Applied-Cryptography",
"path": "/OPT_With_PGR/encrypt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let diference = text.chars().count() - key.chars().count();
let len_key = key.chars().count();
let key_chars: Vec<char> = key.chars().collect();
let key_string = pgr_function(key, text, diference);
let mut cypher_text = xor_encrypt(text_bytes, &*key_string);
... | code_fim | medium | {
"lang": "rust",
"repo": "alitoxSB/Applied-Cryptography",
"path": "/OPT_With_PGR/encrypt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AntonGepting/tmux-interface-rs path: /src/commands/clients_and_sessions/refresh_client_macro.rs
/// Structure for refreshing the current client
///
/// # Manual
///
/// tmux 3.3:
/// ```text
/// refresh-client [-cDLRSU] [-A pane:state] [-B name:what:format] [-C XxY] [-f flags]
/// [-l [target-pa... | code_fim | hard | {
"lang": "rust",
"repo": "AntonGepting/tmux-interface-rs",
"path": "/src/commands/clients_and_sessions/refresh_client_macro.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(not(feature = "cmd_alias"))]
let cmd = "refresh-client";
#[cfg(feature = "cmd_alias")]
let cmd = "refresh";
let mut s = Vec::new();
s.push(cmd);
#[cfg(feature = "tmux_2_9a")]
s.push("-c");
#[cfg(feature = "tmux_2_9a")]
s.push("-D");
#[cfg(feature = "tmux_... | code_fim | hard | {
"lang": "rust",
"repo": "AntonGepting/tmux-interface-rs",
"path": "/src/commands/clients_and_sessions/refresh_client_macro.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tomzhang/ngt-rs path: /ngt-sys/build.rs
use std::env;
use std::path::PathBuf;
fn main() {
let mut config = cmake::Config::new("NGT");
if env::var("CARGO_FEATURE_SHARED_MEM").is_ok() {
config.define("NGT_SHARED_MEMORY_ALLOCATOR", "ON");
}
if env::var("CARGO_FEATURE_LARG... | code_fim | medium | {
"lang": "rust",
"repo": "tomzhang/ngt-rs",
"path": "/ngt-sys/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bindings = bindgen::Builder::default()
.header(format!("{}/include/NGT/Capi.h", dst.display()))
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.r... | code_fim | hard | {
"lang": "rust",
"repo": "tomzhang/ngt-rs",
"path": "/ngt-sys/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/threads-sendsync/task-comm-12.rs
// run-pass
#![allow(unused_must_use)]
#![allow(unused_mut)]
// ignore-emscripten no threads support
use std::thread;
<|fim_suffix|>fn start(_task_number: isize) { println!("Started / Finished task."); }
... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/threads-sendsync/task-comm-12.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Try joining threads that have already finished.
result.join();
println!("Joined task.");
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/threads-sendsync/task-comm-12.rs
// run-pass
#![allow(unused_must_use)]
#![allow(unused_mut)]
// ignore-emscripten no t... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/threads-sendsync/task-comm-12.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dotenv::dotenv().expect("Initialize dotenv error.");
cli.run();
std::process::exit(0);
}<|fim_prefix|>// repo: chongyi/inspirer-rs path: /src/main.rs
use clap::Parser;
mod cli;
mod controller;
mod error;
mod request;
mod response;
mod route;
mod server;
mod middleware;
mod session;
mod man... | code_fim | easy | {
"lang": "rust",
"repo": "chongyi/inspirer-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chongyi/inspirer-rs path: /src/main.rs
use clap::Parser;
mod cli;
mod controller;
mod error;
mod request;
mod response;
mod route;
mod server;
mod middleware;
mod session;
mod manager;
fn main() {
let cli = cli::Cli::parse();
<|fim_suffix|> cli.run();
std::process::exit(0);
}<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "chongyi/inspirer-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cli = cli::Cli::parse();
dotenv::dotenv().expect("Initialize dotenv error.");
cli.run();
std::process::exit(0);
}<|fim_prefix|>// repo: chongyi/inspirer-rs path: /src/main.rs
use clap::Parser;
mod cli;
mod controller;
mod error;
mod request;
mod response;
mod route;
mod server;
mo... | code_fim | easy | {
"lang": "rust",
"repo": "chongyi/inspirer-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn parse_type_path(p: &TypePath) -> &Ident {
&p.path.segments.last().unwrap().ident
}
}
impl Display for TypeName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
#[derive(Debug)]
pub(crate) struct TypeDetails {
/// This ... | code_fim | hard | {
"lang": "rust",
"repo": "NeoTim/autocxx",
"path": "/engine/src/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn new(id: &str) -> Self {
let canonical_name = DEADNAME_MAP.get(id);
if let Some(canonical_name) = canonical_name {
// This is already a cxx replacement name, e.g. CxxString.
TypeName(canonical_name.into())
} else {
TypeName(id.in... | code_fim | hard | {
"lang": "rust",
"repo": "NeoTim/autocxx",
"path": "/engine/src/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NeoTim/autocxx path: /engine/src/types.rs
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LIC... | code_fim | hard | {
"lang": "rust",
"repo": "NeoTim/autocxx",
"path": "/engine/src/types.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GitNealian/nwallpaper path: /src/main.rs
mod app;
use app::App;
use gdk::EventKey;
use gdk_pixbuf::Pixbuf;
use gtk::CellAreaExt;
use gtk::{false_, prelude::*};
use std::rc::Rc;
use std::{borrow::Borrow, error::Error, fs::File, io::Write, path::Path};
mod source;
use glib::clone;
fn download_ima... | code_fim | hard | {
"lang": "rust",
"repo": "GitNealian/nwallpaper",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn main1() {
if gtk::init().is_err() {
println!("Failed to initialize GTK.");
return;
}
let glade_src =
std::fs::read_to_string("/home/nealian/desktop_new/wallpaper/src/ui/window.ui").unwrap();
// Then we call the Builder call.
let builder = gtk::Builder... | code_fim | hard | {
"lang": "rust",
"repo": "GitNealian/nwallpaper",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", 3);
} else {
println!("{}", 4);
}
}<|fim_prefix|>// repo: nannany/rust_practice path: /abc194/src/bin/a.rs
fn main() {
input! {a: i32, b: i32}
let c = a + b;
if 15 <= c && 8 <= b {
println!("{}", 1);
} else if 10 <= c <|fim_middle|>&& 3 <= b {
... | code_fim | medium | {
"lang": "rust",
"repo": "nannany/rust_practice",
"path": "/abc194/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nannany/rust_practice path: /abc194/src/bin/a.rs
fn main() {
input! {a: i32, b: i32}
let c = a + b;
if 1<|fim_suffix|>&& 3 <= b {
println!("{}", 2);
} else if 3 <= c {
println!("{}", 3);
} else {
println!("{}", 4);
}
}<|fim_middle|>5 <= c && 8 <= ... | code_fim | medium | {
"lang": "rust",
"repo": "nannany/rust_practice",
"path": "/abc194/src/bin/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Neopallium/cr-rs path: /examples/basic_guest.rs
#[macro_use]
extern crate cr;
use std::thread;
use std::time::Duration;
mod basic_state;
use basic_state::*;
use cr::cr_op::*;
cr_main!(plugin_main);
pub fn plugin_main(ctx: &mut BasicPlugin, cr_op: cr::cr_op) -> i32 {
// Test "guest" fea... | code_fim | hard | {
"lang": "rust",
"repo": "Neopallium/cr-rs",
"path": "/examples/basic_guest.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // slow down the printing.
thread::sleep(Duration::from_millis(200));
}
CR_UNLOAD => {
println!("Plugin unload. version = {}", ctx.get_version());
}
CR_CLOSE => {
println!("Plugin close. version = {}", ctx.get_version());
... | code_fim | hard | {
"lang": "rust",
"repo": "Neopallium/cr-rs",
"path": "/examples/basic_guest.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tc21/advent-of-code-2020 path: /src/bin/8-handheld-halting-part-2/main.rs
/* --- Part Two ---
After some careful analysis, you believe that exactly one instruction is corrupted.
Somewhere in the program, either a jmp is supposed to be a nop, or a nop is supposed to be a jmp. (No acc instructio... | code_fim | hard | {
"lang": "rust",
"repo": "tc21/advent-of-code-2020",
"path": "/src/bin/8-handheld-halting-part-2/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pc += 1;
}
Ok(acc)
}
#[derive(Debug, Copy, Clone)]
struct Instruction {
pub opcode: Opcode,
pub value: i32
}
#[derive(Debug, Copy, Clone)]
enum Opcode {
Nop, Acc, Jmp,
}
impl Instruction {
pub fn parse(instruction: &str) -> Self {
let mut parts = instruction.spl... | code_fim | hard | {
"lang": "rust",
"repo": "tc21/advent-of-code-2020",
"path": "/src/bin/8-handheld-halting-part-2/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: feather-rs/feather path: /feather/old/server/network/src/listener.rs
//! Listener Tokio task.
//!
//! This task listens on a `TcpListener` and accepts
//! connections, spawning worker tasks to handle them,4.
use crate::worker::run_worker;
use crate::{ListenerToServerMessage, ServerToListenerMes... | code_fim | hard | {
"lang": "rust",
"repo": "feather-rs/feather",
"path": "/feather/old/server/network/src/listener.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> log::info!("Connection received from {}", ip);
tokio::spawn(run_worker(
stream,
ip,
tx.clone(),
Arc::clone(&rx),
Arc::clone(&config_bans.0),
Arc::clone(&config_bans.1),
Arc::clone(&player_count),
... | code_fim | hard | {
"lang": "rust",
"repo": "feather-rs/feather",
"path": "/feather/old/server/network/src/listener.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tokio::spawn(run_worker(
stream,
ip,
tx.clone(),
Arc::clone(&rx),
Arc::clone(&config_bans.0),
Arc::clone(&config_bans.1),
Arc::clone(&player_count),
Arc::clone(&server_icon),
Arc::clone(&pac... | code_fim | medium | {
"lang": "rust",
"repo": "feather-rs/feather",
"path": "/feather/old/server/network/src/listener.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/unicode-segmentation/benches/graphemes.rs
use
criterion
:
:
{
black_box
criterion_group
criterion_main
Criterion
}
;
use
unicode_segmentation
;
use
std
:
:
fs
;
use
unicode_segmentation
:
:
UnicodeSegmentation
;
fn
graphemes
(
c
:
&
mut
Criteri... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/unicode-segmentation/benches/graphemes.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>)
{
graphemes
(
c
"
russian
"
"
benches
/
texts
/
russian
.
txt
"
)
;
}
fn
graphemes_source_code
(
c
:
&
mut
Criterion
)
{
graphemes
(
c
"
source_code
"
"
benches
/
texts
/
source_code
.
txt
"
)
;
}
criterion_group
!
(
benches
graphemes_arabic
graphemes_english
graphemes_hindi
graphemes_japanese
graphemes... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/unicode-segmentation/benches/graphemes.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create a frame to be sent trough serial port
///
/// This converts message to binary and adds header, footer and CRC
///
/// * `force_crc` - CRC value to be used; will be computed if not specified.
pub fn to_control_frame_with(&self, force_crc: Option<u32>) -> Vec<u8> {
... | code_fim | hard | {
"lang": "rust",
"repo": "makers-for-life/makair-telemetry",
"path": "/src/control.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let header = tag(b"\x05\x0A");
let footer = tag(b"\x50\xA0");
let mut parser = preceded(
header,
terminated(pair(consumed(parse_inner_control_message), be_u32), footer),
);
parser(input)
.map_err(nom::Err::convert)
.and_then(|(rest, ((msg_bytes, msg), e... | code_fim | hard | {
"lang": "rust",
"repo": "makers-for-life/makair-telemetry",
"path": "/src/control.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: makers-for-life/makair-telemetry path: /src/control.rs
// MakAir Telemetry
//
// Copyright: 2020, Makers For Life
// License: Public Domain License
use nom::IResult;
use std::ops::RangeInclusive;
use crate::locale::Locale;
use crate::structures::{TelemetryError, TelemetryErrorKind};
/// Speci... | code_fim | hard | {
"lang": "rust",
"repo": "makers-for-life/makair-telemetry",
"path": "/src/control.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: carloslfu/rust path: /src/libcore/error.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apac... | code_fim | medium | {
"lang": "rust",
"repo": "carloslfu/rust",
"path": "/src/libcore/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#![stable(feature = "rust1", since = "1.0.0")]
use prelude::*;
use fmt::{Debug, Display};
/// Base functionality for all errors in Rust.
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Error: Debug + Display {
/// A short description of the error.
///
/// The description should not c... | code_fim | hard | {
"lang": "rust",
"repo": "carloslfu/rust",
"path": "/src/libcore/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WuJiY/poem path: /src/route.rs
//! Route object and DSL
use std::{collections::HashMap, sync::Arc};
use http::StatusCode;
use crate::{
http::Method, route_recognizer::Router, Endpoint, EndpointExt, IntoResponse, Request, Response,
};
/// Routing object
#[derive(Default)]
pub struct Route... | code_fim | hard | {
"lang": "rust",
"repo": "WuJiY/poem",
"path": "/src/route.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn call(&self, mut req: Request) -> Self::Output {
match self
.router
.get(req.method())
.and_then(|router| router.recognize(req.uri().path()).ok())
.or_else(|| self.all_method_router.recognize(req.uri().path()).ok())
{
... | code_fim | hard | {
"lang": "rust",
"repo": "WuJiY/poem",
"path": "/src/route.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let grid = Box::new(Orientation::Horizontal, 1);
for _ in 0..10 {
let scale = Scale::new_with_range(Orientation::Vertical, 0.0, 255.0, 1.0);
grid.add(&scale);
scale.connect_value_changed(|scale| {
println!("Scale {}", scale.get_value());
});
}
... | code_fim | hard | {
"lang": "rust",
"repo": "tversteeg/VM116",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tversteeg/VM116 path: /src/main.rs
extern crate gtk;
mod dmx;
use gtk::prelude::*;
use gtk::{Box, Scale, Orientation, Button, Window, WindowType};
use std::cell::RefCell;
use std::rc::Rc;
fn main() {
if gtk::init().is_err() {
println!("Failed to initialize GTK.");
return;
... | code_fim | medium | {
"lang": "rust",
"repo": "tversteeg/VM116",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> button.connect_clicked(move |_| {
let local_dmx = &mut *captured_dmx.borrow_mut();
local_dmx.connect();
});
grid.add(&button);
window.add(&grid);
window.show_all();
window.connect_delete_event(|_, _| {
gtk::main_quit();
Inhibit(false)
});
... | code_fim | hard | {
"lang": "rust",
"repo": "tversteeg/VM116",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DianaNites/cargo-sysroot path: /src/lib.rs
/rust-lang/compiler-builtins
CompilerBuiltinsMem,
/// This enables the `c` feature of [`compiler_builtins`][1],
/// which enables compilation of `C` code and may result in more
/// optimized implementations, and fills in the rare unimpl... | code_fim | hard | {
"lang": "rust",
"repo": "DianaNites/cargo-sysroot",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Sysroot::Std => {
deps.insert(
"std".into(),
Dependency::Full(DependencyFull {
path: Some(builder.rust_src.as_ref().unwrap().join("std")),
features: if builder.featur... | code_fim | hard | {
"lang": "rust",
"repo": "DianaNites/cargo-sysroot",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The target to compile *for*. This can be a target-triple,
/// or a [JSON Target Specification][1].
///
/// By default this is `None`, and if not set when
/// [`SysrootBuilder::build`] is called, will cause an error.
///
/// [1]: https://doc.rust-lang.org/rustc/targets/custo... | code_fim | hard | {
"lang": "rust",
"repo": "DianaNites/cargo-sysroot",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: melvinfuture/dhedge-trader path: /src/main.rs
use dht::*;
use env_logger::Builder;
use log::*;
use std::collections::HashMap;
const HTTP_ENDPOINT: &str = "http://161.35.205.60:8545";
const POOL_ADDRESS: &str = "53523de8a90053ddb1d330499d3dc080b909edb9";
#[tokio::main]
async fn main() -> Result... | code_fim | hard | {
"lang": "rust",
"repo": "melvinfuture/dhedge-trader",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut dhedge = DHedge::new(HTTP_ENDPOINT, POOL_ADDRESS).await;
let all_assets: HashMap<Symbol, Asset> = dhedge.get_fund_composition().await;
let mut assets = HashMap::new();
for symbol in symbols.clone() {
let asset = all_assets.get(symbol).unwrap();
assets.insert(symbol.... | code_fim | medium | {
"lang": "rust",
"repo": "melvinfuture/dhedge-trader",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct ExclusiveSignatureState {
state: Arc<SignatureState>,
}
impl ExclusiveSignatureState {
fn new(signature_state: SignatureState) -> Self {
ExclusiveSignatureState {
state: Arc::new(signature_state),
}
}
fn open(kp_handle: Handl... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/wasi-crypto-preview",
"path": "/implementation/src/signature.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pk = WASI_CRYPTO_CTX.signature_publickey_manager.get(pk_handle)?;
let signature_verification_state = match pk {
SignaturePublicKey::ECDSA(pk) => ExclusiveSignatureVerificationState::new(
SignatureVerificationState::ECDSA(ECDSASignatureVerificationState::new(... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/wasi-crypto-preview",
"path": "/implementation/src/signature.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 5l1v3r1/wasi-crypto-preview path: /implementation/src/signature.rs
use std::sync::Arc;
use super::ecdsa::*;
use super::eddsa::*;
use super::error::*;
use super::handles::*;
use super::rsa::*;
use super::signature_keypair::*;
use super::signature_publickey::*;
use super::WASI_CRYPTO_CTX;
#[allo... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/wasi-crypto-preview",
"path": "/implementation/src/signature.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CyberEpsilon/enarx path: /sev-types/src/lib.rs
// SPDX-License-Identifier: Apache-2.0
//! The `sev-types` crate contains types that are useful with interacting with
//! a SEV-enabled environment.
//!
//! These types are described in the ["Secure Encrypted Virtualization API"](
//! htt<|fim_suff... | code_fim | hard | {
"lang": "rust",
"repo": "CyberEpsilon/enarx",
"path": "/sev-types/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>g items are correct:
//! the SEV API specification document version; the specification publication
//! date; the link to the SEV API specification.
#![no_std]
#![deny(missing_docs)]
#![deny(clippy::all)]
pub mod command;
pub mod platform;<|fim_prefix|>// repo: CyberEpsilon/enarx path: /sev-types/src/li... | code_fim | hard | {
"lang": "rust",
"repo": "CyberEpsilon/enarx",
"path": "/sev-types/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ll request. It is important that this crate remains in lockstep with the
//! API specification above.
//!
//! If this crate is updated to reflect a newer version of the AMD SEV API,
//! please update this documentation so that the following items are correct:
//! the SEV API specification document version... | code_fim | hard | {
"lang": "rust",
"repo": "CyberEpsilon/enarx",
"path": "/sev-types/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
fn main() {}<|fim_prefix|>// repo: dalcde/pyo3 path: /tests/ui/invalid_pymethod_proto_args.rs
use pyo3::prelude::*;
#[pyclass]
struct MyClass {}
<|fim_middle|>#[pymethods]
impl MyClass {
fn __truediv__(&self) -> PyResult<()> {
| code_fim | medium | {
"lang": "rust",
"repo": "dalcde/pyo3",
"path": "/tests/ui/invalid_pymethod_proto_args.rs",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dalcde/pyo3 path: /tests/ui/invalid_pymethod_proto_args.rs
use pyo3::prelude::*;
#[pyclass]
struct MyClass {}
<|fim_suffix|> Ok(())
}
}
fn main() {}<|fim_middle|>#[pymethods]
impl MyClass {
fn __truediv__(&self) -> PyResult<()> {
| code_fim | medium | {
"lang": "rust",
"repo": "dalcde/pyo3",
"path": "/tests/ui/invalid_pymethod_proto_args.rs",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jjsullivan5196/scratchpad path: /rust/hello-rk/src/main.rs
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
extern crate rocket_contrib;
use rocket_contrib::{Json};
<|fim_suffix|> let Person { ref name, ref age } = *person;
format!("Hello, {}, you are {}", name, age)
... | code_fim | medium | {
"lang": "rust",
"repo": "jjsullivan5196/scratchpad",
"path": "/rust/hello-rk/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rocket::ignite().mount("/", routes![index]).launch();
}<|fim_prefix|>// repo: jjsullivan5196/scratchpad path: /rust/hello-rk/src/main.rs
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
extern crate rocket_contrib;
use rocket_contrib::{Json};
<|fim_middle|>#[macro_use]
extern cra... | code_fim | hard | {
"lang": "rust",
"repo": "jjsullivan5196/scratchpad",
"path": "/rust/hello-rk/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<C: hyper::client::connect::Connect>TestingApi for TestingApiClient<C>
where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)]
fn tests_file_response_get(&self, ) -> Pin<Box<dyn Future<Output = Result<std::path::PathBuf, Error>>>> {
let mut req = __internal_request::Reques... | code_fim | hard | {
"lang": "rust",
"repo": "OpenAPITools/openapi-generator",
"path": "/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OpenAPITools/openapi-generator path: /samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenA... | code_fim | hard | {
"lang": "rust",
"repo": "OpenAPITools/openapi-generator",
"path": "/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RobDavenport/moba path: /server/src/engine/components/abilities.rs
#[derive(Clone, Copy, Debug, PartialEq)]
<|fim_suffix|>e Abilities as enum or key or script tags?<|fim_middle|>pub struct Abilities {
pub innate: u32,
pub abilities: [u32; 4],
}
//Stor | code_fim | medium | {
"lang": "rust",
"repo": "RobDavenport/moba",
"path": "/server/src/engine/components/abilities.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>2,
pub abilities: [u32; 4],
}
//Store Abilities as enum or key or script tags?<|fim_prefix|>// repo: RobDavenport/moba path: /server/src/engine/components/abilities.rs
#[derive(Clone, Copy, Debug, PartialEq)]
<|fim_middle|>pub struct Abilities {
pub innate: u3 | code_fim | easy | {
"lang": "rust",
"repo": "RobDavenport/moba",
"path": "/server/src/engine/components/abilities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitchmindtree/imxrt-rs path: /imxrt-ral/src/imxrt105/instances/xbarb.rs
#![allow(non_snake_case, non_upper_case_globals)]
#![allow(non_camel_case_types)]
//! Crossbar Switch
//!
//! Used by: imxrt1051, imxrt1052
#[cfg(not(feature = "nosync"))]
pub use crate::imxrt105::peripherals::xbarb::Instan... | code_fim | hard | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-ral/src/imxrt105/instances/xbarb.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Unsafely steal XBARB3
///
/// This function is similar to take() but forcibly takes the
/// Instance, marking it as taken irregardless of its previous
/// state.
#[cfg(not(feature = "nosync"))]
#[inline]
pub unsafe fn steal() -> Instance {
XBARB3_TAKEN = true;
... | code_fim | hard | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-ral/src/imxrt105/instances/xbarb.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rphsoftware/image-to-presentation path: /src/main.rs
mod color_utils;
mod framebuffer;
use std::fs::File;
use std::io::Write;
use png::ColorType::RGB;
use crate::framebuffer::FrameBuffer;
fn write_styles_xml(w: u32, h: u32) {
let z = format!("{}{}{}{}{}",
include_str!("binary/s... | code_fim | medium | {
"lang": "rust",
"repo": "rphsoftware/image-to-presentation",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut fb = FrameBuffer::new(info.width, info.height);
let mut buf = vec![0; info.buffer_size()];
reader.next_frame(&mut buf).expect("Failed reading frame");
let mut p = 4;
if info.color_type == RGB {
p = 3;
}
for x in 0..info.width {
for y in 0..info.height ... | code_fim | medium | {
"lang": "rust",
"repo": "rphsoftware/image-to-presentation",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return result;
}
fn main() {
println!("{}", solution("367436765224262147416876392821832169781285655941123648172835986213848397566284241467793119283183835972359686446876651595915734132336167171121577524691918457577129283476247264385162111539468922414495231484194262592917889386218863347344978231632... | code_fim | medium | {
"lang": "rust",
"repo": "SwiftPush/advent-of-code-2017",
"path": "/01-inverse-captcha/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SwiftPush/advent-of-code-2017 path: /01-inverse-captcha/src/main.rs
#[test]
fn example1() {
assert_eq!(solution("1122"), 3);
}
#[test]
fn example2() {
assert_eq!(solution("1234"), 0);
}
#[test]
fn example3() {
assert_eq!(solution("91212129"), 9);
}
fn solution(input: &str) ->... | code_fim | medium | {
"lang": "rust",
"repo": "SwiftPush/advent-of-code-2017",
"path": "/01-inverse-captcha/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
println!("{}", solution("3674367652242621474168763928218321697812856559411236481728359862138483975662842414677931192831838359723596864468766515959157341323361671711215775246919184575771292834762472643851621115394689224144952314841942625929178893862188633473449782316328138938985367593224673... | code_fim | hard | {
"lang": "rust",
"repo": "SwiftPush/advent-of-code-2017",
"path": "/01-inverse-captcha/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbnair/Substrate_ZeroknowledgeProof path: /bellman-verifier/src/lib.rs
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]
#[macro_use]
extern crate parity_codec_derive;
#[cfg(not(feature = "std"))]
#[macro_use]
extern crate alloc;
use pairing::{
E... | code_fim | hard | {
"lang": "rust",
"repo": "sbnair/Substrate_ZeroknowledgeProof",
"path": "/bellman-verifier/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> reader.read_exact(g1_repr.as_mut())?;
let beta_g1 = g1_repr.into_affine().map_err(|e| Err(e))?;
reader.read_exact(g2_repr.as_mut())?;
let beta_g2 = g2_repr.into_affine().map_err(|e| Err(e))?;
reader.read_exact(g2_repr.as_mut())?;
let gamma_g2 = g2_... | code_fim | hard | {
"lang": "rust",
"repo": "sbnair/Substrate_ZeroknowledgeProof",
"path": "/bellman-verifier/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(string) = serde_urlencoded::to_string(&message) {
let body = Body::from(string.into_bytes());
let _response = self.post(url, body, response_type).await?;
if let Response::CreateMessage(Some(response)) = _response {
return Ok(response);... | code_fim | hard | {
"lang": "rust",
"repo": "tarkah/nhl-notifier",
"path": "/twilio/src/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tarkah/nhl-notifier path: /twilio/src/client.rs
use crate::model::{CreateMessageRequest, CreateMessageResponse, Response, ResponseType};
use failure::{bail, Error, ResultExt};
use futures::AsyncReadExt;
use http::{Request, Uri};
use http_client::{native::NativeClient, Body, HttpClient};
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "tarkah/nhl-notifier",
"path": "/twilio/src/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/src/utils/files_to_ignore.rs
// Copyright (c) Meta Platforms, Inc. and affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use std::path::Path;
use regex::bytes::RegexSet;
... | code_fim | medium | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/utils/files_to_ignore.rs",
"mode": "psm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn should_ignore(&self, path: impl AsRef<Path>) -> bool {
let path = path.as_ref();
self.should_ignore_impl(path)
}
#[cfg(unix)]
fn should_ignore_impl(&self, path: &Path) -> bool {
use std::os::unix::ffi::OsStrExt;
let path_bytes = path.as_os_str().as_b... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/utils/files_to_ignore.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: botnana/botnana-api-rs path: /src/json_api.rs
as_str()
+ r#","channel":"#
+ channel.to_string().as_str()
+ r#",""#
+ param
+ r#"":"#
+ value.to_string().as_str()
+ r#"}}"#;
self.send_message(&msg);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "botnana/botnana-api-rs",
"path": "/src/json_api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let msg = r#"{"jsonrpc":"2.0","method":"config.axis.set","params":{"#.to_owned()
+ r#""position":"#
+ position.to_string().as_str()
+ r#",""#
+ param
+ r#"":""#
+ value
+ r#""}}"#;
self.send_message(&msg.to... | code_fim | hard | {
"lang": "rust",
"repo": "botnana/botnana-api-rs",
"path": "/src/json_api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: botnana/botnana-api-rs path: /src/json_api.rs
"#;
self.send_message(msg);
}
/// profiler.output
pub fn profiler_output(&mut self) {
let msg = r#"{"jsonrpc":"2.0","method":"profiler.output"}"#;
self.send_message(msg);
}
/// version.get
pub fn vers... | code_fim | hard | {
"lang": "rust",
"repo": "botnana/botnana-api-rs",
"path": "/src/json_api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> remaining -= 1;
if node.val == x {
return Self::find_node(&queue, remaining, y, parent);
} else if node.val == y {
return Self::find_node(&queue, remaining, x, parent);
}
if let Some(l... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0993_cousins_in_binary_tree/bfs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0993_cousins_in_binary_tree/bfs.rs
use crate::data_structures::TreeNode;
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::cell::RefCell;
use std::collection... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0993_cousins_in_binary_tree/bfs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sjinno/exercism path: /nucleotide-count/src/lib.rs
use std::collections::HashMap;
const VALID_NUCLEOTIDES: [char; 4] = ['A', 'C', 'G', 'T'];
pub fn count(nucleotide: char, dna: &str) -> Result<usize, char> {
is_valid_dna(dna)?;
is_valid_nucleotide(nucleotide)?;
let mut count = 0;
... | code_fim | hard | {
"lang": "rust",
"repo": "sjinno/exercism",
"path": "/nucleotide-count/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// // Community solution 2
// use std::collections::HashMap;
// pub fn count(nucleotide: char, dna: &str) -> Result<usize, char> {
// let nucleotide = dna
// .chars()
// .find(|c| c != &'A' && c != &'C' && c != &'G' && c != &'T')
// .unwrap_or(nucleotide);
// match nucleo... | code_fim | hard | {
"lang": "rust",
"repo": "sjinno/exercism",
"path": "/nucleotide-count/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Ok(count)
// }
// pub fn nucleotide_counts(dna: &str) -> Result<HashMap<char, usize>, char> {
// let mut count = [0, 0, 0, 0];
// for c in dna.chars() {
// let index = match c {
// 'A' => 0,
// 'C' => 1,
// 'G' => 2,
// 'T' => 3,
// ... | code_fim | hard | {
"lang": "rust",
"repo": "sjinno/exercism",
"path": "/nucleotide-count/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod preferences;
mod recent_file_item;
pub mod win;<|fim_prefix|>// repo: therustmonk/hotwire path: /src/widgets/mod.rs
pub mod comm_info_header;
pub mod comm_remote_serv<|fim_middle|>er;
mod comm_target_card;
mod headerbar_search;
mod ips_and_streams_treeview;
mod messages_treeview;
| code_fim | medium | {
"lang": "rust",
"repo": "therustmonk/hotwire",
"path": "/src/widgets/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: therustmonk/hotwire path: /src/widgets/mod.rs
pub mod comm_info_header;
pub mod comm_remote_serv<|fim_suffix|> ips_and_streams_treeview;
mod messages_treeview;
mod preferences;
mod recent_file_item;
pub mod win;<|fim_middle|>er;
mod comm_target_card;
mod headerbar_search;
mod | code_fim | easy | {
"lang": "rust",
"repo": "therustmonk/hotwire",
"path": "/src/widgets/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.