text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> #[test]
fn eval_do_rep_chain() {
let code = "0 ;{ x put do } 10 rep do";
eval_helper(code, "xxxxxxxxxx");
}
#[test]
fn eval_quick_maths() {
let code = "put (9 -' ((3 +' 1) *' 2))'";
eval_helper(code, "1");
}
#[test]
fn eval_comp_ass() {
... | code_fim | hard | {
"lang": "rust",
"repo": "slerpyyy/paste-lang",
"path": "/src/eval.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slerpyyy/paste-lang path: /src/eval.rs
ap();)*
};
(@COUNT; $($var: ident),*) => {
<[()]>::len(&[$(pop_stack!(@SUBST; $var)),*])
};
(@SUBST; $_: ident) => { () };
}
impl Default for Evaluator {
fn default() -> Self {
Self::new()
}
}
impl Evaluator {
... | code_fim | hard | {
"lang": "rust",
"repo": "slerpyyy/paste-lang",
"path": "/src/eval.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// https://www.acmicpc.net/problem/3076
// 상근이의 체스판
#[test]
fn test_solve3076() {
struct TestData {
s: String,
want: String,
}
for (i, data) in vec![
TestData {
s: "2 4
2 2"
.to_string(),
want: "XX..XX..
XX..XX..
..XX..XX
..XX..XX
"
... | code_fim | hard | {
"lang": "rust",
"repo": "zrma/1d1rust",
"path": "/src/boj/p3k/p3076.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zrma/1d1rust path: /src/boj/p3k/p3076.rs
use crate::boj::p3k::p3023::read_coord;
use std::io::{BufRead, Write};
#[allow(dead_code)]
fn solve3076(reader: &mut impl BufRead, writer: &mut impl Write) {
let (r, c) = read_coord(reader);
let (a, b) = read_coord(reader);
<|fim_suffix|>// http... | code_fim | hard | {
"lang": "rust",
"repo": "zrma/1d1rust",
"path": "/src/boj/p3k/p3076.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(in crate::skk) fn request_google_suggest(
protocol: &str,
midashi: &[u8],
timeout: u64,
) -> Result<Vec<Vec<u8>>, SkkError> {
let encoded_midashi: String = url::form_urlencoded::byte_serialize(midashi).collect();
let mut result = Vec::new();
let ... | code_fim | hard | {
"lang": "rust",
"repo": "wachikun/yaskkserv2",
"path": "/src/skk/yaskkserv2/request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_google_japanese_input_result_2(
json: &json::JsonValue,
is_insert_hiragana_only_candidate: bool,
is_insert_katakana_only_candidate: bool,
is_insert_hankaku_katakana_only_candidate: bool,
) -> Vec<Vec<u8>> {
let mut result = Vec::new();
if let ... | code_fim | hard | {
"lang": "rust",
"repo": "wachikun/yaskkserv2",
"path": "/src/skk/yaskkserv2/request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wachikun/yaskkserv2 path: /src/skk/yaskkserv2/request.rs
nly_candidate && Self::is_utf8_hiragana_only(candidate) {
return false;
}
if !is_insert_katakana_only_candidate && Self::is_utf8_katakana_only(candidate) {
return false;
}... | code_fim | hard | {
"lang": "rust",
"repo": "wachikun/yaskkserv2",
"path": "/src/skk/yaskkserv2/request.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sho-1990/Scripts path: /src/bin/gizi.rs
extern crate toml;
extern crate chrono;
use chrono::Local;
use std::env;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::option::Option;
use std::process::Command;
#[derive(Debug)]
struct Config {
gizi: Gizi
}
impl Config {
pu... | code_fim | hard | {
"lang": "rust",
"repo": "sho-1990/Scripts",
"path": "/src/bin/gizi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{} create!", &file_name);
open_editor(&file_name, &config.gizi.editor);
}
fn projects_process() {
let config = read_config();
match fs::read_dir(&config.gizi.projects) {
Err(why) => println!("{:?}", why.kind()),
Ok(paths) => for path in paths {
printl... | code_fim | hard | {
"lang": "rust",
"repo": "sho-1990/Scripts",
"path": "/src/bin/gizi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Command::new(editor).arg(file_name).output().expect("Please set editor name");
}
fn latest_file(project_name: &str, config: &Config) -> Option<std::io::Result<File>> {
let dir_name = format!("{}/{}", config.gizi.projects, project_name);
let paths = fs::read_dir(&dir_name).unwrap();
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "sho-1990/Scripts",
"path": "/src/bin/gizi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paulotten/advent_of_code_2019 path: /day13/src/main.rs
mod data;
mod intcode;
use intcode::Int;
use itertools::Itertools;
use std::collections::HashMap;
const BLOCK: Int = 2;
const PADDLE: Int = 3;
const BALL: Int = 4;
fn main() {
//part1();
part2();
}
fn part1() {
let data = dat... | code_fim | hard | {
"lang": "rust",
"repo": "paulotten/advent_of_code_2019",
"path": "/day13/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if output.len() == 3 {
tiles.insert((output[0], output[1]), output[2]);
output = vec!();
let paddle_x = get_x_pos(&tiles, PADDLE);
let ball_x = get_x_pos(&tiles, BALL);
if paddle_x.is_some... | code_fim | hard | {
"lang": "rust",
"repo": "paulotten/advent_of_code_2019",
"path": "/day13/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _admin = mock(
"GET",
Matcher::Regex(
r"^/rest/api/1.0/projects/FOO/permissions/PROJECT_ADMIN/all(\?.+)?$".to_string(),
),
).with_status(200)
.with_header("content-type", "application/json")
.with_body(r#"{ "permitted": false }"#)
.create();
... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanmorley/thrash",
"path": "/tests/permission.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonathanmorley/thrash path: /tests/permission.rs
extern crate failure;
extern crate mockito;
extern crate thrash;
use failure::Error;
use mockito::{mock, Matcher};
#[test]
fn project_default_permission_none() -> Result<(), Error> {
let _read = mock(
"GET",
Matcher::Regex(
... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanmorley/thrash",
"path": "/tests/permission.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RaoulHC/AoC2018 path: /day-4/src/main.rs
use std::fs;
use std::collections::HashMap;
#[macro_use] extern crate lazy_static; // Static regular expressions
extern crate regex;
use regex::Regex;
type ID = u32;
#[derive(Debug, Clone)]
struct Entry {
minute: u32,
event: Event,
}
#[derive(... | code_fim | hard | {
"lang": "rust",
"repo": "RaoulHC/AoC2018",
"path": "/day-4/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("ID x minute: {}", sleepy_id * sleepy_minute as u32);
// day 2 stuff, need to look at the most asleep minute.
let mut max_sleep_minute: u32 = 0;
let mut max_sleep: u32 = 0;
let mut sleepy_id: u32 = 0;
for (id, sleep) in guards_sleep.clone() {
let temp_sleep = slee... | code_fim | hard | {
"lang": "rust",
"repo": "RaoulHC/AoC2018",
"path": "/day-4/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
// Read and order lines
let f = fs::read_to_string("input.txt").unwrap();
let mut f : Vec<&str> = f.lines().collect();
f.sort();
// regex to split up vectors
let guard_re: Regex =
Regex::new(r"\[.+\] Guard #(\d+) begins shift").unwrap();
// hashmap of guar... | code_fim | hard | {
"lang": "rust",
"repo": "RaoulHC/AoC2018",
"path": "/day-4/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ryanmtate/fluvio path: /src/sc-core/src/tests/fixture/mock_spu.rs
use std::sync::Arc;
use std::time::Duration;
use std::io::Error as IoError;
use log::info;
use log::debug;
use log::warn;
use log::trace;
use futures::select;
use futures::stream::StreamExt;
use futures::future::FutureExt;
use f... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/fluvio",
"path": "/src/sc-core/src/tests/fixture/mock_spu.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (mut _sink, mut stream) = socket.split();
let mut api_stream = stream.api_stream::<InternalSpuRequest, InternalSpuApi>();
loop {
select! {
_ = self.receiver.next() => {
info!("spu: received termination msg");
... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/fluvio",
"path": "/src/sc-core/src/tests/fixture/mock_spu.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matsadler/quack path: /duck_dns/src/options.rs
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
#[derive(Default)]
pub struct UpdateOptions {
pub(crate) ipv4: Option<Ipv4Addr>,
pub(crate) ipv6: Option<Ipv6Addr>,
pub(crate) verbose: bool,
}
impl UpdateOptions {
pub fn new(ipv4: Ipv4A... | code_fim | hard | {
"lang": "rust",
"repo": "matsadler/quack",
"path": "/duck_dns/src/options.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Default::default()
}
}
pub struct TxtOptions {
pub(crate) txt: String,
pub(crate) verbose: bool,
}
impl TxtOptions {
pub fn new(txt: String, verbose: bool) -> Self {
Self { txt, verbose }
}
}
impl From<&str> for TxtOptions {
fn from(val: &str) -> Self {
v... | code_fim | hard | {
"lang": "rust",
"repo": "matsadler/quack",
"path": "/duck_dns/src/options.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn anonymous_encryption() {
let bob_message = (
generate_random_vec::<u8>(10),
generate_random_vec::<i64>(100),
"Message from Bob for Alice, very secret".to_owned(),
);
let (alice_public_key, alice_secret_key) = gen_keypair();
... | code_fim | hard | {
"lang": "rust",
"repo": "Fraser999/secure_serialisation",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fraser999/secure_serialisation path: /src/lib.rs
// Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3... | code_fim | hard | {
"lang": "rust",
"repo": "Fraser999/secure_serialisation",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> shared[0];
}
// the &mut-borrow only becomes active way down here.
//
// (At least in theory; part of the reason this test fails is that
// the constructed MIR throws in extra &mut reborrows which
// flummoxes our attmpt to delay the activation point here.)
delay.push(... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs
// ignore-tidy-linelength
// revisions: nll_target
// The following revisions are disabled due to missing support from two-phase beyond autorefs
//[nll_beyond]compile-flags: -Z borrowck=mi... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn flow(&self) -> Flow {
self.flow
}
}
impl<L, P, S> Disasm<L, P, S>
where
L: Literal,
P: Mappable + Nameable,
S: Clone,
{
pub fn next_offset(&self) -> S {
self.next_offset.clone()
}
}
impl<L, P, S> Disasm<L, P, S>
where
L: Literal,
P: Mappable + N... | code_fim | hard | {
"lang": "rust",
"repo": "kmeisthax/retrogram",
"path": "/src/analysis/disasm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kmeisthax/retrogram path: /src/analysis/disasm.rs
//! Disassembly result type
use crate::analysis::{Flow, Mappable, Reference};
use crate::ast::{Directive, Instruction, Literal};
use crate::cli::Nameable;
/// Representation of a static disassembly of a valid instruction.
///
/// A `Disasm` inc... | code_fim | hard | {
"lang": "rust",
"repo": "kmeisthax/retrogram",
"path": "/src/analysis/disasm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let argv = ["lsd", "--color", "never"];
let cli = Cli::try_parse_from(argv).unwrap();
assert_eq!(Some(ColorOption::Never), ColorOption::from_cli(&cli));
}
#[test]
fn test_from_env_no_color() {
set_var("NO_COLOR", "true");
assert_eq!(Some(ColorOption::Ne... | code_fim | hard | {
"lang": "rust",
"repo": "alichtman/lsd",
"path": "/src/flags/color.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alichtman/lsd path: /src/flags/color.rs
//! This module defines the [Color]. To set it up from [Cli], a [Config] and its [Default]
//! value, use its [configure_from](Configurable::configure_from) method.
use super::Configurable;
use crate::app::Cli;
use crate::config_file::Config;
use serde:... | code_fim | hard | {
"lang": "rust",
"repo": "alichtman/lsd",
"path": "/src/flags/color.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut c = Config::with_none();
c.color = Some(config_file::Color {
when: None,
theme: Some(ThemeOption::NoLscolors),
});
assert_eq!(ThemeOption::NoLscolors, ThemeOption::from_config(&c));
}
#[test]
fn test_from_config_bad_file_flag() {... | code_fim | hard | {
"lang": "rust",
"repo": "alichtman/lsd",
"path": "/src/flags/color.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laarmen/duplicate path: /tests/utils.rs
use std::{
ffi::OsString,
fs::{DirEntry, File},
io::{BufRead, BufReader, Write},
path::Path,
};
/// Whether the `pretty_errors` feature is enabled.
pub const FEATURE_PRETTY_ERRORS: bool = cfg!(feature = "pretty_errors");
/// Whether the `module_disamb... | code_fim | hard | {
"lang": "rust",
"repo": "laarmen/duplicate",
"path": "/tests/utils.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut dest_file = File::create(dest_file_path).unwrap();
let mut dest_inline_file = File::create(dest_inline_file_path).unwrap();
for line in BufReader::new(File::open(file.path()).unwrap()).lines()
{
let line = line.unwrap();
let line = line.trim();
match line
{
"#[du... | code_fim | hard | {
"lang": "rust",
"repo": "laarmen/duplicate",
"path": "/tests/utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // For each source dir, execute action of each file
for (source_dir, actions) in self.source_dirs.iter()
{
let source_dir_path = self.dir.to_owned() + "/" + source_dir;
if let Ok(files) = std::fs::read_dir(&source_dir_path)
{
for file in files
{
if let Ok(file) = file
{
... | code_fim | hard | {
"lang": "rust",
"repo": "laarmen/duplicate",
"path": "/tests/utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bytes = vec![169, 191];
ctx.env.create_string_latin1(bytes.as_slice())
}
pub fn register_js(exports: &mut JsObject) -> Result<()> {
exports.create_named_method("concatString", concat_string)?;
exports.create_named_method("concatUTF16String", concat_utf16_string)?;
exports.create_named_metho... | code_fim | hard | {
"lang": "rust",
"repo": "napi-rs/napi-rs",
"path": "/examples/napi-compat-mode/src/string.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: napi-rs/napi-rs path: /examples/napi-compat-mode/src/string.rs
use napi::{CallContext, JsObject, JsString, Result};
#[js_function(1)]
fn concat_string(ctx: CallContext) -> Result<JsString> {
let in_string = ctx.get::<JsString>(0)?;
let out_string = format!("{} + Rust 🦀 string!", in_string.... | code_fim | hard | {
"lang": "rust",
"repo": "napi-rs/napi-rs",
"path": "/examples/napi-compat-mode/src/string.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hasp-rs/hasp path: /hasp/src/events.rs
// Copyright (c) The hasp Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::database::ConnectionCreator;
use chrono::Local;
use color_eyre::{eyre::WrapErr, Result};
use colored::Colorize;
use jod_thread::JoinHandle;
use rusqlite::params... | code_fim | hard | {
"lang": "rust",
"repo": "hasp-rs/hasp",
"path": "/hasp/src/events.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn log(&self, event_name: &'static str, data: &impl Serialize) {
// This should basically never fail, but if it does, ignore the error.
let data = match serde_json::to_string(data) {
Ok(data) => data,
Err(_) => return,
};
// Assume wr... | code_fim | hard | {
"lang": "rust",
"repo": "hasp-rs/hasp",
"path": "/hasp/src/events.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_batch_get_clone_subnode_from_root() {
println!("test_batch_get_clone_subnode_from_root");
let mut nodes_map: HashMap<i32, Node<Item4>> = HashMap::new();
let mut nodes = Nodes {
nodes_map,
size: 0,
root_id: 0,
content_size: 0,
next_id: 0,... | code_fim | hard | {
"lang": "rust",
"repo": "bradyjoestar/merklebtree",
"path": "/tests/test_branch_clone.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bradyjoestar/merklebtree path: /tests/test_branch_clone.rs
tem3>> = HashMap::new();
let mut nodes = Nodes {
nodes_map,
size: 0,
root_id: 0,
content_size: 0,
next_id: 0,
m: 0,
};
let mut tree = MerkleBTree::new_empty(3, &mut nodes);
... | code_fim | hard | {
"lang": "rust",
"repo": "bradyjoestar/merklebtree",
"path": "/tests/test_branch_clone.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_batch_insert_clone_subnode_from_root() {
let mut nodes_map: HashMap<i32, Node<Item4>> = HashMap::new();
let mut nodes = Nodes {
nodes_map,
size: 0,
root_id: 0,
content_size: 0,
next_id: 0,
m: 0,
};
let mut tree = MerkleBTree::... | code_fim | hard | {
"lang": "rust",
"repo": "bradyjoestar/merklebtree",
"path": "/tests/test_branch_clone.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_set_date_time_lsi(ta: &mut TestArgs) {
unsafe { pulse_reset_backup_domain(&mut ta.rcc, &mut ta.pwr) };
unsafe { setup_lsi(&mut ta.rcc, LsiPre::DIV1) };
test_set_date_time_with_clk(rtc::Clk::Lsi)
}
#[test]
fn test_set_date_time_hse(ta: &mut TestA... | code_fim | hard | {
"lang": "rust",
"repo": "lulf/stm32wl-hal",
"path": "/rtc-testsuite/tests/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lulf/stm32wl-hal path: /rtc-testsuite/tests/test.rs
#![no_std]
#![no_main]
use defmt::unwrap;
use defmt_rtt as _; // global logger
use panic_probe as _;
use stm32wl_hal::{
chrono::{Datelike, NaiveDate, NaiveDateTime, NaiveTime, Timelike},
pac::{self, DWT},
rcc::{self, pulse_reset_ba... | code_fim | hard | {
"lang": "rust",
"repo": "lulf/stm32wl-hal",
"path": "/rtc-testsuite/tests/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const PREAMBLE: &str = "Generated file, do not edit by hand, see `xtask/src/codegen`";
pub fn reformat(text: &str) -> Result<String> {
let stdout = cmd!("rustfmt").stdin(text).read()?;
Ok(format!("//! {}\n\n{}\n", PREAMBLE, stdout))
}
pub fn to_camel_case(s: &str) -> String {
let mut buf... | code_fim | hard | {
"lang": "rust",
"repo": "oberblastmeister/lingo",
"path": "/xtask/src/codegen/kinds_src.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn reformat(text: &str) -> Result<String> {
let stdout = cmd!("rustfmt").stdin(text).read()?;
Ok(format!("//! {}\n\n{}\n", PREAMBLE, stdout))
}
pub fn to_camel_case(s: &str) -> String {
let mut buf = String::with_capacity(s.len());
let (idx, first) = s.char_indices().next().unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "oberblastmeister/lingo",
"path": "/xtask/src/codegen/kinds_src.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oberblastmeister/lingo path: /xtask/src/codegen/kinds_src.rs
use std::{fs, path::Path};
use eyre::Result;
use proc_macro2::{Punct, Spacing};
use quote::{format_ident, quote};
use serde::{Deserialize, Serialize};
use ungrammar::Grammar;
use xshell::cmd;
use crate::utils;
#[derive(Debug, Serial... | code_fim | hard | {
"lang": "rust",
"repo": "oberblastmeister/lingo",
"path": "/xtask/src/codegen/kinds_src.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: josephtownshend/FizzBuzz_Everything path: /RUST/fizzbuzz/src/main.rs
pub fn fizzbuzz(x: usize) -> String {
if x %15 == 0 {
return String::from("FizzBuzz");
}
else if x %3 == 0 {
return String::from("Fizz");
}
else if x %5 == 0 {
return String::from... | code_fim | medium | {
"lang": "rust",
"repo": "josephtownshend/FizzBuzz_Everything",
"path": "/RUST/fizzbuzz/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_fizzbuzz_6() {
assert_eq!(fizzbuzz(10), "Buzz");
}
#[test]
fn test_fizzbuzz_7() {
assert_eq!(fizzbuzz(15), "FizzBuzz");
}
#[test]
fn test_fizzbuzz_8() {
assert_eq!(fizzbuzz(30), "FizzBuzz");
}
}<|fim_prefix|>// repo: josephtown... | code_fim | hard | {
"lang": "rust",
"repo": "josephtownshend/FizzBuzz_Everything",
"path": "/RUST/fizzbuzz/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_fizzbuzz_5() {
assert_eq!(fizzbuzz(5), "Buzz");
}
#[test]
fn test_fizzbuzz_6() {
assert_eq!(fizzbuzz(10), "Buzz");
}
#[test]
fn test_fizzbuzz_7() {
assert_eq!(fizzbuzz(15), "FizzBuzz");
}
#[test]
fn test_fizzbuzz_8() {
... | code_fim | medium | {
"lang": "rust",
"repo": "josephtownshend/FizzBuzz_Everything",
"path": "/RUST/fizzbuzz/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let request = Request::build(Command::Set)
.key(Some("hello"))
.value(Some("world"))
.cas(1024)
.finish();
println!("{:#?}", request);
}<|fim_prefix|>// repo: svartalf/rust-memcache-proto path: /examples/request_builder.rs
extern crate memcache_proto;
<|fim_middl... | code_fim | easy | {
"lang": "rust",
"repo": "svartalf/rust-memcache-proto",
"path": "/examples/request_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: svartalf/rust-memcache-proto path: /examples/request_builder.rs
extern crate memcache_proto;
use memcache_proto::{Request, Command};
fn main() {
<|fim_suffix|> println!("{:#?}", request);
}<|fim_middle|> let request = Request::build(Command::Set)
.key(Some("hello"))
.valu... | code_fim | medium | {
"lang": "rust",
"repo": "svartalf/rust-memcache-proto",
"path": "/examples/request_builder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{:#?}", request);
}<|fim_prefix|>// repo: svartalf/rust-memcache-proto path: /examples/request_builder.rs
extern crate memcache_proto;
use memcache_proto::{Request, Command};
fn main() {
<|fim_middle|> let request = Request::build(Command::Set)
.key(Some("hello"))
.valu... | code_fim | medium | {
"lang": "rust",
"repo": "svartalf/rust-memcache-proto",
"path": "/examples/request_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cql = "INSERT INTO cdrs_test.update_list_with_udt \
(id, udts_set) VALUES (?, ?)";
session
.query_with_values(cql, row_struct.clone().into_query_values())
.await
.expect("insert");
let query = session
.prepare("UPDATE cdrs_test.update_list_wi... | code_fim | hard | {
"lang": "rust",
"repo": "Jasperav/cdrs-tokio",
"path": "/tests/derive_traits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cql = "INSERT INTO cdrs_test.test_alter_udt_add \
(my_key, my_map) VALUES (?, ?)";
session
.query_with_values(cql, row_struct.clone().into_query_values())
.await
.expect("insert");
let cql = "ALTER TYPE cdrs_test.alter_udt_add_udt ADD my_timestamp ti... | code_fim | hard | {
"lang": "rust",
"repo": "Jasperav/cdrs-tokio",
"path": "/tests/derive_traits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jasperav/cdrs-tokio path: /tests/derive_traits.rs
mod common;
#[cfg(feature = "e2e-tests")]
use common::*;
#[cfg(feature = "e2e-tests")]
use cdrs_tokio::consistency::Consistency;
#[cfg(feature = "e2e-tests")]
use cdrs_tokio::frame::AsBytes;
#[cfg(feature = "e2e-tests")]
use cdrs_tokio::frame::... | code_fim | hard | {
"lang": "rust",
"repo": "Jasperav/cdrs-tokio",
"path": "/tests/derive_traits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mem.write_pc(val);
}<|fim_prefix|>// repo: eropsyren/lc3_core path: /src/instr/ops/jump/mod.rs
use crate::mem::Memory;
// TODO add ret: (return from subroutine) implementation
pub fn jmp(instr: u16, mem: &mut Memory) {
let base_r = (instr >> 6) & 0x7;
<|fim_middle|> let val = mem.read_reg(ba... | code_fim | easy | {
"lang": "rust",
"repo": "eropsyren/lc3_core",
"path": "/src/instr/ops/jump/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eropsyren/lc3_core path: /src/instr/ops/jump/mod.rs
use crate::mem::Memory;
<|fim_suffix|> let val = mem.read_reg(base_r);
mem.write_pc(val);
}<|fim_middle|>// TODO add ret: (return from subroutine) implementation
pub fn jmp(instr: u16, mem: &mut Memory) {
let base_r = (instr >> 6) ... | code_fim | medium | {
"lang": "rust",
"repo": "eropsyren/lc3_core",
"path": "/src/instr/ops/jump/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jsolon-ncp/agnes path: /src/fieldlist.rs
/*!
Type aliases and macro for handling specifications of fields in a data source.
*/
use std::marker::PhantomData;
use label::*;
/// Type alias for a field label and data type.
pub type FieldSchema<Label, DType> = Labeled<Label, PhantomData<DType>>;
/... | code_fim | hard | {
"lang": "rust",
"repo": "jsolon-ncp/agnes",
"path": "/src/fieldlist.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Macro for creating a source specification structure used to specify how to
/// extract fields from a data source. It correlates labels (defined using the
/// [tablespace](macro.tablespace.html) macro) to field / column names or indices in a
/// data source. This source specification structure is imple... | code_fim | hard | {
"lang": "rust",
"repo": "jsolon-ncp/agnes",
"path": "/src/fieldlist.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>in 0..(len - dis) {
dp[i][i + dis] = max(
piles[i] - dp[i + 1][i + dis],
piles[i + dis] - dp[i][i + dis - 1],
);
}
}
return dp[0][len-1] > 0;
}
}<|fim_prefix|>// repo: laopo001/leetcode-rust p... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/leetcode-rust",
"path": "/src/stone_game/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..len {
let mut v:Vec<i32> = vec![];
for _ in 0..len {
v.push(0);
}
dp.push(v);
dp[i][i] = piles[i];
}
for dis in 1..len {
for i in 0..(len - dis) {
dp[i][i + d... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/leetcode-rust",
"path": "/src/stone_game/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laopo001/leetcode-rust path: /src/stone_game/mod.rs
struct Solution;
use std::cmp::max;
fn run(piles: &Vec<i32>, l: usize, r: usize) -> i32 {
if l == r {
return piles[l];
}
return max(
piles[l] - run(&piles, l + 1, r),
piles[r] - run(&piles, l, r - 1),... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/leetcode-rust",
"path": "/src/stone_game/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anthonyq2/blockchain_app path: /src/lib.rs
use std::time::{SystemTime, UNIX_EPOCH};
use transaction::Transaction;
use sha2::{Sha256, Digest};
mod block;
pub mod transaction;
///
/// Returns the time elapsed since the Unix Epoch.
///
pub fn now() -> u64 {
let start = SystemTime::now();
... | code_fim | hard | {
"lang": "rust",
"repo": "anthonyq2/blockchain_app",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Flatten all transactions data into a single Vec<u8>
bytes.extend(transactions
.iter()
.flat_map(|transaction| transaction.bytes())
.collect::<Vec<u8>>(),
);
bytes.extend(pre_hash.as_bytes());
let result = Sha256::new().chain(bytes).finalize();
String::fr... | code_fim | hard | {
"lang": "rust",
"repo": "anthonyq2/blockchain_app",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lythesia/leet path: /rs/src/quests/find_peak_element.rs
/**
* [162] Find Peak Element
*
* A peak element is an element that is strictly greater than its neighbors.
Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to... | code_fim | medium | {
"lang": "rust",
"repo": "lythesia/leet",
"path": "/rs/src/quests/find_peak_element.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn find_peak_element(nums: Vec<i32>) -> i32 {
let n = nums.len();
let (mut lo, mut hi) = (0, n - 1);
if n <= 1 { return 0; }
while lo < hi {
let mi = (lo + hi)/2;
if nums[mi] > nums[mi + 1] { hi = mi; } // left part must conta... | code_fim | medium | {
"lang": "rust",
"repo": "lythesia/leet",
"path": "/rs/src/quests/find_peak_element.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>get: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None })),
filter: Some(Dictionary {
entries: Some(vec![DictionaryEntry {
key: "name".to_string(),
value: Some(Box::new(DictionaryValue::Str("diagnosti... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/tools/cmc/tests/integration_test.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /tools/cmc/tests/integration_test.rs
eProtocol {
dependency_type: Some(DependencyType::Strong),
source: Some(Ref::Parent(ParentRef {})),
source_name: Some("fuchsia.fonts.LegacyProvider".to_string()),
target_pa... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/tools/cmc/tests/integration_test.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /tools/cmc/tests/integration_test.rs
(Ref::Debug(DebugRef {})),
source_name: Some("fuchsia.log.LegacyLog".to_string()),
target_path: Some("/svc/fuchsia.log.LegacyLog".to_string()),
availability: Some(Availability::Required),
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/tools/cmc/tests/integration_test.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_parse() {
let test = "
30373
25512
65332
33549
35390
".trim();
let want: Vec<Vec<u8>> = vec![
vec![3, 0, 3, 7, 3],
vec![2, 5, 5, 1, 2],
vec![6, 5, 3, 3, 2],
vec![3, 3, 5, 4, ... | code_fim | hard | {
"lang": "rust",
"repo": "joshkunz/advent-of-code",
"path": "/2022/day8/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if puzzle[row][col] > max_up {
max_up = puzzle[row][col];
}
up.push(max_up);
if puzzle[rows-row-1][col] > max_down {
max_down = puzzle[rows-row-1][col];
}
down.push(max_... | code_fim | hard | {
"lang": "rust",
"repo": "joshkunz/advent-of-code",
"path": "/2022/day8/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joshkunz/advent-of-code path: /2022/day8/src/main.rs
use std::io::Read;
use std::io;
fn main() {
let mut input: String = String::default();
io::stdin().read_to_string(&mut input).unwrap();
println!("Part 1: {}", solve_part1(&input));
println!("Part 2: {}", solve_part2(&input));... | code_fim | hard | {
"lang": "rust",
"repo": "joshkunz/advent-of-code",
"path": "/2022/day8/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PopStateEventMethods for PopStateEvent {
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#dom-popstateevent-state
unsafe fn State(&self, _cx: *mut JSContext) -> JSVal {
self.state.get()
}
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/script/dom/popstateevent.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/style-servo/components/script/dom/popstateevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/script/dom/popstateevent.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GaloisInc/mir-verifier path: /lib/libstd/sys/sgx/args.rs
use super::abi::usercalls::{alloc, raw::ByteBuffer};
use crate::ffi::OsString;
use crate::slice;
use crate::sync::atomic::{AtomicUsize, Ordering};
use crate::sys::os_str::Buf;
use crate::sys_common::FromInner;
<|fim_suffix|> self.0... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/mir-verifier",
"path": "/lib/libstd/sys/sgx/args.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ExactSizeIterator for Args {
fn len(&self) -> usize {
self.0.len()
}
}
impl DoubleEndedIterator for Args {
fn next_back(&mut self) -> Option<OsString> {
self.0.next_back().cloned()
}
}<|fim_prefix|>// repo: GaloisInc/mir-verifier path: /lib/libstd/sys/sgx/args.rs
use... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/mir-verifier",
"path": "/lib/libstd/sys/sgx/args.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 5l1v3r1/algorithm-1 path: /src/strings/alphabet.rs
//! A data type for alphabets, for use with string-processing code
//! that must convert between an alphabet of size R and the integers
//! 0 through R-1.
//!
//! Warning: supports only the basic multilingual plane (BMP), i.e,
//! Unico... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/algorithm-1",
"path": "/src/strings/alphabet.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns true if the argument is a character in this alphabet
pub fn contains(&self, c: char) -> bool {
self.inverse.get(c as usize) != Some(&-1)
}
/// Returns the number of characters in this alphabet (the radix)
pub fn radix(&self) -> usize {
self.radix
}
... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/algorithm-1",
"path": "/src/strings/alphabet.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Self {
alphabet,
inverse,
radix,
})
}
}
impl TryFrom<u16> for Alphabet {
type Error = ();
fn try_from(radix: u16) -> Result<Self, Self::Error> {
let inverse = (0..=radix as i32).collect();
let alphabet: Vec<_> = (0..=radi... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/algorithm-1",
"path": "/src/strings/alphabet.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>im_end(), line.trim_end(), line.trim_end());
}<|fim_prefix|>// repo: hurnhu/open-kattis path: /echo/src/main.rs
fn main() {
let mut line = String::new();
let _ = std::io::stdin().read_line(&mut li<|fim_middle|>ne).unwrap();
println!("{} {} {}", line.tr | code_fim | easy | {
"lang": "rust",
"repo": "hurnhu/open-kattis",
"path": "/echo/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hurnhu/open-kattis path: /echo/src/main.rs
fn main() {
let mut line = String::new();
let _ = std::io::stdin().read_line(&mut li<|fim_suffix|>im_end(), line.trim_end(), line.trim_end());
}<|fim_middle|>ne).unwrap();
println!("{} {} {}", line.tr | code_fim | easy | {
"lang": "rust",
"repo": "hurnhu/open-kattis",
"path": "/echo/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ekicyou/pasta-rs path: /crates/shiori/src/entry.rs
use crate::shiori::SHIORI;
use shiori3::entry;
use winapi::shared::minwindef::DWORD;
use winapi::shared::minwindef::HGLOBAL;
use winapi::shared::minwindef::LPVOID;
#[no_mangle]
pub extern "C" fn load(h_dir: HGLOBAL, len: usize) -> bool {
en... | code_fim | medium | {
"lang": "rust",
"repo": "ekicyou/pasta-rs",
"path": "/crates/shiori/src/entry.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub extern "C" fn request(h: HGLOBAL, len: &mut usize) -> HGLOBAL {
entry::request(&SHIORI, h, len)
}
#[no_mangle]
pub extern "stdcall" fn DllMain(
h_inst: usize,
ul_reason_for_call: DWORD,
lp_reserved: LPVOID,
) -> bool {
match ul_reason_for_call {
entry::DLL_PRO... | code_fim | medium | {
"lang": "rust",
"repo": "ekicyou/pasta-rs",
"path": "/crates/shiori/src/entry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jasmaabox/AoC-2020-rust path: /day06/src/main.rs
use std::collections::HashSet;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() -> std::io::Result<()> {
let f = File::open("input")?;
let mut reader = BufReader::new(f);
let mut line = String::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "jasmaabox/AoC-2020-rust",
"path": "/day06/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ine(&mut line)? == 0 || line.trim().len() == 0 {
break;
}
}
all_questions_answered.push(all_questions.len());
common_questions_answered.push(common_questions.len());
line.clear();
}
println!("{}", all_questions_answered.iter().sum::<usiz... | code_fim | hard | {
"lang": "rust",
"repo": "jasmaabox/AoC-2020-rust",
"path": "/day06/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ksnz/asteroids-arena path: /rust/asteroids/src/asteroids/systems/player.rs
use glam::Vec2;
use crossbeam::channel::*;
use legion::*;
use legion::world::SubWorld;
use std::collections::HashSet;
use super::super::components::audio::*;
use super::super::components::bullet::*;
use super::super::com... | code_fim | hard | {
"lang": "rust",
"repo": "Ksnz/asteroids-arena",
"path": "/rust/asteroids/src/asteroids/systems/player.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> e: Entity,
ws: &WorldSize,
world: &mut SubWorld
) {
if let Ok(mut entry) = world.entry_mut(e) {
*entry.get_component_mut::<Player>().unwrap() = Player(false, PLAYER_FIRE_COOLDOWN);
*entry.get_component_mut::<Pos>().unwrap() = Pos(Vec2 {
x: ws.0 as f32 * 0.5,
... | code_fim | hard | {
"lang": "rust",
"repo": "Ksnz/asteroids-arena",
"path": "/rust/asteroids/src/asteroids/systems/player.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gagarin55/etcommon-rs path: /trie/src/database/mod.rs
mod memory;
use super::{SecureTrie, FixedTrie, FixedSecureTrie, Trie};
pub use self::memory::{MemoryDatabase, MemoryDatabaseGuard};
use bigint::H256;
use rlp;
use std::collections::HashMap;
use std::cell::RefCell;
pub trait Database<'a> {... | code_fim | hard | {
"lang": "rust",
"repo": "gagarin55/etcommon-rs",
"path": "/trie/src/database/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> inserted: Vec::new(),
freed: Vec::new(),
}
}
pub fn get<'b>(&'b self, hash: H256) -> Option<Vec<u8>> {
if self.cache.borrow().contains_key(&hash) {
self.cache.borrow().get(&hash).map(|v| v.clone())
} else {
let val = self.dat... | code_fim | hard | {
"lang": "rust",
"repo": "gagarin55/etcommon-rs",
"path": "/trie/src/database/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for entry in file_entries {
let stat = get_stats_for_file(&entry.path()).unwrap();
total_codes += stat.code;
total_comments = stat.comments;
total_blanks = stat.blanks;
}
Ok(SrcStats {
files: u32::try_from(file_count)?,
code: total_codes,
... | code_fim | hard | {
"lang": "rust",
"repo": "chansuke/kaiseki",
"path": "/src/stats.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some(entry) = dir_entries.pop() {
for inner_entry in fs::read_dir(&entry)? {
if let Ok(entry) = inner_entry {
if entry.path().is_dir() {
dir_entries.push(entry.path());
} else {
file_entries.push(entr... | code_fim | hard | {
"lang": "rust",
"repo": "chansuke/kaiseki",
"path": "/src/stats.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chansuke/kaiseki path: /src/stats.rs
//! calculating source logic
use std::convert::TryFrom;
// check file extension
use super::errors::StatsError;
use std::fs;
use std::fs::DirEntry;
use std::path::{Path, PathBuf};
#[derive(Debug)]
pub struct SrcStats {
// number of files
pub files: u3... | code_fim | hard | {
"lang": "rust",
"repo": "chansuke/kaiseki",
"path": "/src/stats.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonwingfield/atsamd09-rs path: /atsamd09d14a/sercom0/i2cs/ctrla/mod.rs
bool {
self.bits
}
#[doc = r" Returns `true` if the bit is clear (0)"]
#[inline]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r" Returns `true` if the bit is set (1)"]
... | code_fim | hard | {
"lang": "rust",
"repo": "jonwingfield/atsamd09-rs",
"path": "/atsamd09d14a/sercom0/i2cs/ctrla/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonwingfield/atsamd09-rs path: /atsamd09d14a/sercom0/i2cs/ctrla/mod.rs
egister"]
#[inline]
pub fn reset(&self) {
self.write(|w| w)
}
}
#[doc = r" Value of the field"]
pub struct SWRSTR {
bits: bool,
}
impl SWRSTR {
#[doc = r" Value of the field as raw bits"]
#[inl... | code_fim | hard | {
"lang": "rust",
"repo": "jonwingfield/atsamd09-rs",
"path": "/atsamd09d14a/sercom0/i2cs/ctrla/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>st MASK: bool = true;
const OFFSET: u8 = 30;
self.w.bits &= !((MASK as u32) << OFFSET);
self.w.bits |= ((value & MASK) as u32) << OFFSET;
self.w
}
}
impl R {
#[doc = r" Value of the register as raw bits"]
#[inline]
pub fn bits(&self) -> u32 {
self.bi... | code_fim | hard | {
"lang": "rust",
"repo": "jonwingfield/atsamd09-rs",
"path": "/atsamd09d14a/sercom0/i2cs/ctrla/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Haml {}
pub(crate) struct Declaration {
value: String,
}
impl Declaration {
pub fn new(value: &str) -> Declaration {
Declaration {
value: value.to_string(),
}
}
}
impl Haml for Declaration {}
pub(crate) struct Element {
name: String,
attributes... | code_fim | hard | {
"lang": "rust",
"repo": "jhartwell/haml-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jhartwell/haml-rs path: /src/lib.rs
#![allow(dead_code)]
// mod arena;
// mod formatter;
// mod parser;
// mod regex;
// use formatter::HtmlFormatter;
// use parser::Parser;
mod lex;
mod parse;
use std::collections::{BTreeSet, HashMap};
#[derive(Debug)]
pub enum Format {
Html4(),
Html5... | code_fim | hard | {
"lang": "rust",
"repo": "jhartwell/haml-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: knokko/wasmuri-components path: /src/lib.rs
mod passive;
mod button;
mod behavior;
<|fim_suffix|>:*;
pub use input::*;
pub use macros::*;<|fim_middle|>mod input;
mod macros;
pub use passive::*;
pub use button::*;
pub use behavior: | code_fim | medium | {
"lang": "rust",
"repo": "knokko/wasmuri-components",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:*;
pub use button::*;
pub use behavior::*;
pub use input::*;
pub use macros::*;<|fim_prefix|>// repo: knokko/wasmuri-components path: /src/lib.rs
mod passive;
mod button;
mod behavior;
<|fim_middle|>mod input;
mod macros;
pub use passive: | code_fim | easy | {
"lang": "rust",
"repo": "knokko/wasmuri-components",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_column_name_in_error() -> Result<()> {
use crate::{types::Type, Error};
let db = Connection::open_in_memory()?;
db.execute_batch(
"BEGIN;
CREATE TABLE foo(x INTEGER, y TEXT);
INSERT INTO foo VALUES(4, NULL);
... | code_fim | hard | {
"lang": "rust",
"repo": "Genomicsplc/rusqlite",
"path": "/src/column.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Genomicsplc/rusqlite path: /src/column.rs
use std::str;
use crate::{Error, Result, Statement};
/// Information about a column of a SQLite query.
#[derive(Debug)]
pub struct Column<'stmt> {
name: &'stmt str,
decl_type: Option<&'stmt str>,
}
impl Column<'_> {
/// Returns the name of... | code_fim | hard | {
"lang": "rust",
"repo": "Genomicsplc/rusqlite",
"path": "/src/column.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.