text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: pattonw/maximin path: /src/nd_array.rs
fn rusty_maximin_tree_nd(intensities: ArrayViewD<f64>) -> () {
let n_dim = intensities.ndim();
let mut node_indices = Array::<usize, _>::from_elem(intensities.raw_dim(), usize::max_value());
let mut complete: Graph<f64, f64, petgraph::Undirect... | code_fim | hard | {
"lang": "rust",
"repo": "pattonw/maximin",
"path": "/src/nd_array.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match down_index {
Some(down_index) => {
if down_index < &usize::max_value() {
let max_intensity = f64::max(*value, intensities[&down_neighbor_index]);
complete.add_edge(node_index, NodeIndex::new(*down_index),... | code_fim | hard | {
"lang": "rust",
"repo": "pattonw/maximin",
"path": "/src/nd_array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let up_index = node_indices.get(&up_neighbor_index);
let down_index = node_indices.get(&down_neighbor_index);
match up_index {
Some(up_index) => {
if up_index < &usize::max_value() {
let max_intensity = f64::m... | code_fim | hard | {
"lang": "rust",
"repo": "pattonw/maximin",
"path": "/src/nd_array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/xflags path: /xflags-macros/tests/it/src/subcommands.rs
args! {
cmd rust-analyzer {
repeated -v, --verbose
<|fim_suffix|> cmd analysis-stats
required path: PathBuf
{
optional --parallel
}
}
}<|fim_middle|> cmd server ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/xflags",
"path": "/xflags-macros/tests/it/src/subcommands.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> cmd analysis-stats
required path: PathBuf
{
optional --parallel
}
}
}<|fim_prefix|>// repo: isgasho/xflags path: /xflags-macros/tests/it/src/subcommands.rs
args! {
cmd rust-analyzer {
repeated -v, --verbose
<|fim_middle|> cmd server ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/xflags",
"path": "/xflags-macros/tests/it/src/subcommands.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wlh320/refhelper path: /src/lib.rs
use biblatex::{self, Bibliography, ChunksExt};
use futures::{stream, StreamExt};
use fuzzy_matcher::skim::SkimMatcherV2;
use indicatif::ProgressBar;
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fs::File;
use std::path::PathBuf;
use tokio... | code_fim | hard | {
"lang": "rust",
"repo": "wlh320/refhelper",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Library {
pub fn from_path(path: PathBuf) -> Result<Library, Box<dyn Error>> {
let lib = match File::open(&path) {
Ok(file) => {
let mut exist_lib: Library = serde_json::from_reader(file)?;
exist_lib.path = Some(path);
exist_lib
... | code_fim | hard | {
"lang": "rust",
"repo": "wlh320/refhelper",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn gen_bibtex(&self, id: Option<usize>) {
match id {
None => {
// gen all bibtex
for entry in self.entries.iter() {
println!("{}", entry.bibtex);
}
}
Some(i) => {
// gen ... | code_fim | hard | {
"lang": "rust",
"repo": "wlh320/refhelper",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0347_top_k_frequent_elements/quick_select.rs
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::cmp::Ordering;
use std::collections::hash_map::DefaultHasher;
u... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0347_top_k_frequent_elements/quick_select.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match i.cmp(&k) {
Ordering::Less => start = i + 1,
Ordering::Equal => break,
Ordering::Greater => end = i,
}
}
counts[..k].iter().map(|&(num, _)| num).collect()
}
}
// --------------------------------------------... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0347_top_k_frequent_elements/quick_select.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snoyberg/wasm-worker-demo path: /src/lib.rs
extern crate cfg_if;
extern crate wasm_bindgen;
#[macro_use]
extern crate serde_derive;
mod utils;
use cfg_if::cfg_if;
use wasm_bindgen::prelude::*;
use std::collections::HashMap;
use askama::Template;
<|fim_suffix|>#[derive(Deserialize, Debug)]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "snoyberg/wasm-worker-demo",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Template)]
#[template(path = "submit.html")]
struct Submit<'a> {
body: &'a str,
}
async fn respond(req: Request) -> Result<Response, Box<dyn std::error::Error>> {
let mut headers = HashMap::new();
headers.insert("Content-Type".to_string(), "text/html; charset=utf-8".to_string());
... | code_fim | medium | {
"lang": "rust",
"repo": "snoyberg/wasm-worker-demo",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn respond(req: Request) -> Result<Response, Box<dyn std::error::Error>> {
let mut headers = HashMap::new();
headers.insert("Content-Type".to_string(), "text/html; charset=utf-8".to_string());
let url: url::Url = req.url.parse()?;
let res = match url.path() {
"/" => Response ... | code_fim | hard | {
"lang": "rust",
"repo": "snoyberg/wasm-worker-demo",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let opts = HistogramOpts::new(metric_name, help);
HistogramVec::new(opts, labels).unwrap()
}
fn int_gauge(metric_name: &str, help: &str) -> IntGauge {
let opts = Opts::new(metric_name, help);
IntGauge::with_opts(opts).unwrap()
}
impl GrpcServerMetrics {
fn new(builder: &MetricsBuilde... | code_fim | hard | {
"lang": "rust",
"repo": "alastairreid/oak",
"path": "/oak_runtime/src/metrics/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alastairreid/oak path: /oak_runtime/src/metrics/mod.rs
//
// Copyright 2020 The Project Oak Authors
//
// 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
//
// http:... | code_fim | hard | {
"lang": "rust",
"repo": "alastairreid/oak",
"path": "/oak_runtime/src/metrics/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let opts = Opts::new(metric_name, help);
IntCounterVec::new(opts, labels).unwrap()
}
fn histogram_vec(metric_name: &str, labels: &[&str], help: &str) -> HistogramVec {
let opts = HistogramOpts::new(metric_name, help);
HistogramVec::new(opts, labels).unwrap()
}
fn int_gauge(metric_name: &... | code_fim | hard | {
"lang": "rust",
"repo": "alastairreid/oak",
"path": "/oak_runtime/src/metrics/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn check_and_reset_gpu_updated(&mut self) -> bool
{
let result = self.cpu.mmu.gpu.updated;
self.cpu.mmu.gpu.updated = false;
result
}
pub fn get_gpu_data<'a>(&'a self) -> &'a [u8, ..160 * 144 * 3]
{
&self.cpu.mmu.gpu.data
}
pub fn keyup(&mut self, key: KeypadKey)
{
self.cpu.mmu.key... | code_fim | medium | {
"lang": "rust",
"repo": "steveklabnik/rboy",
"path": "/src/device.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn keyup(&mut self, key: KeypadKey)
{
self.cpu.mmu.keypad.keyup(key);
}
pub fn keydown(&mut self, key: KeypadKey)
{
self.cpu.mmu.keypad.keydown(key);
}
}<|fim_prefix|>// repo: steveklabnik/rboy path: /src/device.rs
use cpu::CPU;
use keypad::KeypadKey;
pub struct Device
{
cpu: CPU,
}
imp... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/rboy",
"path": "/src/device.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steveklabnik/rboy path: /src/device.rs
use cpu::CPU;
use keypad::KeypadKey;
pub struct Device
{
cpu: CPU,
}
impl Device
{
pub fn new(romname: &str) -> Option<Device>
{
match CPU::new(romname)
{
Some(cpu) => Some(Device { cpu: cpu }),
None => None,
}
}
pub fn new_cgb(romname: ... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/rboy",
"path": "/src/device.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let parser = EventReader::new(file);
for event in parser {
match event {
Ok(XmlEvent::StartElement { attributes, .. }) => {
if let Some(id) = get_attr("id", &attributes) {
id_list.push(id.to_string());
... | code_fim | hard | {
"lang": "rust",
"repo": "grahamc/docbook-index",
"path": "/src/fileindex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: grahamc/docbook-index path: /src/fileindex.rs
use glob::glob;
use std::fs::{File};
use std::path::{Path, PathBuf};
use std::io::BufReader;
use xml::reader::{EventReader, XmlEvent};
use std::collections::HashMap;
use xml::attribute::OwnedAttribute;
pub type Map = HashMap<String, PathBuf>;
pub s... | code_fim | hard | {
"lang": "rust",
"repo": "grahamc/docbook-index",
"path": "/src/fileindex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hiroaki-yamamoto/midas path: /backend/libs/entities/src/execution.rs
use super::OrderInner;
use ::bson::oid::ObjectId;
use ::rug::Float;
use ::types::stateful_setter;
#[derive(Clone, Debug)]
pub enum ExecutionType {
Maker,
Taker,
}
<|fim_suffix|>impl ExecutionSummary {
stateful_setter!(i... | code_fim | hard | {
"lang": "rust",
"repo": "hiroaki-yamamoto/midas",
"path": "/backend/libs/entities/src/execution.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn calculate_profit(op_a: &OrderInner, op_b: &OrderInner) -> Self {
let profit = op_a.price.clone() - &op_b.price;
let profit_ratio =
op_a.qty.clone() * &op_a.price / op_b.qty.clone() * &op_b.price - 1.0;
return Self::default()
.price(Some(op_a.price.clone()))
.qty(Some... | code_fim | hard | {
"lang": "rust",
"repo": "hiroaki-yamamoto/midas",
"path": "/backend/libs/entities/src/execution.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> group
.sample_size(10)
// .measurement_time(std::time::Duration::from_secs(60))
.bench_function(
BenchmarkId::new("hashed", i),
|b| b.iter_batched(
|| (r_x.clone(), rks.clone(), s_y.clon... | code_fim | hard | {
"lang": "rust",
"repo": "remysucre/gj",
"path": "/benches/indexed.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: remysucre/gj path: /benches/indexed.rs
#![allow(unused_variables)]
use criterion::*;
use gj::util::*;
criterion_group!(benches, bench_indexed);
criterion_main!(benches);
pub fn bench_indexed(c: &mut Criterion) {
let mut group = c.benchmark_group("triangle-indexed");
static K: u32 = 10... | code_fim | hard | {
"lang": "rust",
"repo": "remysucre/gj",
"path": "/benches/indexed.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input: Vec<u64> =
vec![
35,
20,
15,
25,
47,
40,
62,
55,
65,
95,
102,
117,
... | code_fim | hard | {
"lang": "rust",
"repo": "stkent/AdventOfCode2020",
"path": "/src/day09.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stkent/AdventOfCode2020 path: /src/day09.rs
use Ordering::{Equal, Greater, Less};
use std::cmp::Ordering;
pub fn solve_part_1(input: &[u64], window_size: usize) -> u64 {
'outer: for target_index in window_size..input.len() {
let target: u64 = input[target_index];
let mut wi... | code_fim | hard | {
"lang": "rust",
"repo": "stkent/AdventOfCode2020",
"path": "/src/day09.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jpfeiffer16/TimeTracker path: /server_native/src/routes/remove_category.rs
use rocket_contrib::{Json, Value};
use super::super::types::data::Data;
use super::super::<|fim_suffix|>ry(body_data.params.unwrap(), &body_data.db);
Json(json!({
"Success": "true",
}))
}<|fim_middle|>sql;
#[post... | code_fim | medium | {
"lang": "rust",
"repo": "jpfeiffer16/TimeTracker",
"path": "/server_native/src/routes/remove_category.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ry(body_data.params.unwrap(), &body_data.db);
Json(json!({
"Success": "true",
}))
}<|fim_prefix|>// repo: jpfeiffer16/TimeTracker path: /server_native/src/routes/remove_category.rs
use rocket_contrib::{Json, Value};
use super::super::types::data::Data;
use super::super::<|fim_middle|>sql;
#[post... | code_fim | medium | {
"lang": "rust",
"repo": "jpfeiffer16/TimeTracker",
"path": "/server_native/src/routes/remove_category.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_format_duration() {
assert_eq!(format_duration(0.0), "0.00s");
assert_eq!(format_duration(55.0), "0.06s");
assert_eq!(format_duration(100.0), "0.10s");
assert_eq!(format_duration(0.99 * 1000.0), "0.99s");
assert_eq!(format_duration(1.00 * 10... | code_fim | hard | {
"lang": "rust",
"repo": "Livven/jetline",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", prompt);
}
struct GitInfo {
sha: String,
branch: Option<Branch>,
changes: usize,
}
struct Branch {
name: String,
tracking: Option<Tracking>,
}
struct Tracking {
ahead: usize,
behind: usize,
}
struct Entry {
text: String,
fg: Color,
bg: Color,
... | code_fim | hard | {
"lang": "rust",
"repo": "Livven/jetline",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Livven/jetline path: /src/main.rs
use chrono::Local;
use colored::*;
use git2::{Repository, StatusOptions};
use itertools::Itertools;
use std::env;
const TERM_BG: Color = Color::Black;
const POWERLINE_FG: Color = Color::Black;
const POWERLINE_SEP: &str = "";
fn main() {
// color detection... | code_fim | hard | {
"lang": "rust",
"repo": "Livven/jetline",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("No config found!\nEnter desired raur root dir> ");
let mut f = match File::create(path) {
Ok(file) => file,
Err(e) => panic!(e),
};
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect("failed to read line");
write!(f,... | code_fim | hard | {
"lang": "rust",
"repo": "deciduously/raur",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deciduously/raur path: /src/config.rs
use std::io;
use std::io::prelude::*;
use std::fs::File;
use std::path::*;
use toml;
pub struct Config {
pub raur_root: PathBuf,
}
<|fim_suffix|>fn generate_config(path: &PathBuf) -> File {
println!("No config found!\nEnter desired raur root dir> "... | code_fim | hard | {
"lang": "rust",
"repo": "deciduously/raur",
"path": "/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for l in reader.lines() {
let line = l.unwrap();
let instruction = line.parse::<Instruction>().unwrap();
register.execute(instruction);
}
println!("Part 1 result is {}", register.part_1_result());
println!("Part 2 result is:\n{}", register.to_string());
}<|fim_prefi... | code_fim | medium | {
"lang": "rust",
"repo": "umatbro/p-tutorials",
"path": "/rust/advent-of-code/day10/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: umatbro/p-tutorials path: /rust/advent-of-code/day10/src/main.rs
mod register;
use std::fs::File;
use std::io::{BufReader, BufRead};
use register::Instruction;
use register::Register;
<|fim_suffix|> for l in reader.lines() {
let line = l.unwrap();
let instruction = line.parse... | code_fim | medium | {
"lang": "rust",
"repo": "umatbro/p-tutorials",
"path": "/rust/advent-of-code/day10/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let deserialized: Bundle = de::from_slice(test_input).unwrap();
assert_eq!(deserialized, expected);
}<|fim_prefix|>// repo: apps4uco/serde_osc path: /tests/de/bundle.rs
use serde_osc::de;
#[test]
fn bundle() {
#[derive(Debug, PartialEq, Deserialize)]
struct Msg1 {
address: String... | code_fim | hard | {
"lang": "rust",
"repo": "apps4uco/serde_osc",
"path": "/tests/de/bundle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apps4uco/serde_osc path: /tests/de/bundle.rs
use serde_osc::de;
#[test]
fn bundle() {
#[derive(Debug, PartialEq, Deserialize)]
struct Msg1 {
address: String,
args: (i32,),
}
#[derive(Debug, PartialEq, Deserialize)]
struct Msg2 {
address: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "apps4uco/serde_osc",
"path": "/tests/de/bundle.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mange/tydra path: /src/actions/action_file.rs
use super::{validator, Page, Settings, SettingsAccumulator, ValidationError};
use std::collections::BTreeMap;
use crate::AppOptions;
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ActionFile {
#[serde(rename = "global", d... | code_fim | hard | {
"lang": "rust",
"repo": "Mange/tydra",
"path": "/src/actions/action_file.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let options = default_options();
let actions: ActionFile =
serde_yaml::from_str(include_str!("../../tests/fixtures/minimal.yml")).unwrap();
actions.validate(&options).unwrap();
}
#[test]
fn it_loads_complex_yaml() {
let options = default_options();
... | code_fim | hard | {
"lang": "rust",
"repo": "Mange/tydra",
"path": "/src/actions/action_file.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_loads_complex_yaml() {
let options = default_options();
let actions: ActionFile =
serde_yaml::from_str(include_str!("../../tests/fixtures/complex.yml")).unwrap();
actions.validate(&options).unwrap();
}
}<|fim_prefix|>// repo: Mange/tydra path:... | code_fim | hard | {
"lang": "rust",
"repo": "Mange/tydra",
"path": "/src/actions/action_file.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn test_isolate(channel: IsolateChannel<String>) {
for _ in 1..10 {
let value_out = channel.receiver.recv().unwrap();
assert_eq!("PING", value_out)
}
channel.sender.send("".to_string()).unwrap();
}<|fim_prefix|>// repo: shadowmint/rust-isolate path: /tests/001_ping_service.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "shadowmint/rust-isolate",
"path": "/tests/001_ping_service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadowmint/rust-isolate path: /tests/001_ping_service.rs
use rust_isolate::Isolate;
use rust_isolate::IsolateIdentity;
use rust_isolate::IsolateChannel;
use rust_isolate::IsolateRuntime;
use rust_isolate::IsolateRuntimeWait;
use std::thread;
use std::time::Duration;
struct PingService {}
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "shadowmint/rust-isolate",
"path": "/tests/001_ping_service.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>:{deserialize::deserialize, serialize};<|fim_prefix|>// repo: UsairimIsani/KEEV path: /src/lib.rs
pub mod log;
pub mod raft;
pub mod sql<|fim_middle|>;
pub mod store;
pub mod utils;
pub use store::{new, KeevDB};
pub use utils: | code_fim | medium | {
"lang": "rust",
"repo": "UsairimIsani/KEEV",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: UsairimIsani/KEEV path: /src/lib.rs
pub mod log;
pub mod raft;
pub mod sql<|fim_suffix|>e store::{new, KeevDB};
pub use utils::{deserialize::deserialize, serialize};<|fim_middle|>;
pub mod store;
pub mod utils;
pub us | code_fim | easy | {
"lang": "rust",
"repo": "UsairimIsani/KEEV",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: UsairimIsani/KEEV path: /src/lib.rs
pub mod log;
pub mod raft;
pub mod sql;
pub mod store;
pub mod utils;
pub us<|fim_suffix|>:{deserialize::deserialize, serialize};<|fim_middle|>e store::{new, KeevDB};
pub use utils: | code_fim | easy | {
"lang": "rust",
"repo": "UsairimIsani/KEEV",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let src: Vec<usize> = FromIterator::from_iter(0..src_len);
b.bytes = src_len as u64;
b.iter(|| {
let dst = src.clone();
assert_eq!(dst.len(), src_len);
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
});
}
#[bench]
fn bench_clone_0000(b: &mut Bencher) {
... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/mir-verifier",
"path": "/lib/liballoc/benches/vec.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn bench_from_iter_1000(b: &mut Bencher) {
do_bench_from_iter(b, 1000)
}
fn do_bench_extend(b: &mut Bencher, dst_len: usize, src_len: usize) {
let dst: Vec<_> = FromIterator::from_iter(0..dst_len);
let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len);
b.bytes = ... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/mir-verifier",
"path": "/lib/liballoc/benches/vec.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GaloisInc/mir-verifier path: /lib/liballoc/benches/vec.rs
use std::iter::{repeat, FromIterator};
use test::Bencher;
#[bench]
fn bench_new(b: &mut Bencher) {
b.iter(|| {
let v: Vec<u32> = Vec::new();
assert_eq!(v.len(), 0);
assert_eq!(v.capacity(), 0);
})
}
fn do... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/mir-verifier",
"path": "/lib/liballoc/benches/vec.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dante-signal31/cifra-rust path: /src/cipher/cryptomath.rs
/// Cryptomatrh module.
/// Rust port of code at:
/// https://www.nostarch.com/crackingcodes/ (BSD Licensed)
/// Return the GCD of a and b using Euclid's algorithm.
///
/// # Parameters:
/// * a: First integer.
/// * b: Second integer.
/... | code_fim | hard | {
"lang": "rust",
"repo": "dante-signal31/cifra-rust",
"path": "/src/cipher/cryptomath.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_gcd() {
let recovered_gcd = gcd(24,32);
assert_eq!(recovered_gcd, 8)
}
#[test]
fn test_find_mod_inverse() {
let recovered_mod_inverse = find_mod_inverse(7, 26).unwrap();
assert_eq!(recovere... | code_fim | hard | {
"lang": "rust",
"repo": "dante-signal31/cifra-rust",
"path": "/src/cipher/cryptomath.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> as_op!();
pulsed_op_to_typed_op!();
}<|fim_prefix|>// repo: dtolnay-contrib/tract path: /pulse/src/ops/slice.rs
use crate::internal::*;
use tract_pulse_opl::ops::PulsedAxisSlice;
<|fim_middle|>impl PulsedOp for PulsedAxisSlice {
fn pulsed_output_facts(&self, inputs: &[&PulsedFact]) -> TractR... | code_fim | hard | {
"lang": "rust",
"repo": "dtolnay-contrib/tract",
"path": "/pulse/src/ops/slice.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtolnay-contrib/tract path: /pulse/src/ops/slice.rs
use crate::internal::*;
use tract_pulse_opl::ops::PulsedAxisSlice;
impl PulsedOp for PulsedAxisSlice {
fn pulsed_output_facts(&self, inputs: &[&PulsedFact]) -> TractResult<TVec<PulsedFact>> {
<|fim_suffix|> as_op!();
pulsed_op_to_ty... | code_fim | medium | {
"lang": "rust",
"repo": "dtolnay-contrib/tract",
"path": "/pulse/src/ops/slice.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akhilsadam/Isovist path: /src/main.rs
use time;
const E: f64 = 2.71828182845904523536028747135;
const PI: f64 = 3.14159265358979323846264338327;
const A: f64 = -1.0;
const C: f64 = 0.97;
const LIMIT: f64 = 100.0;
fn timestamp() -> f64 {
let timespec = time::get_time();
// 1459440009.11... | code_fim | hard | {
"lang": "rust",
"repo": "akhilsadam/Isovist",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let mut area = 0.0f64;
let n = 500000;
for i in 0..n {
area += (PI/(n as f64))*raycast(2.0f64*PI*(i as f64)/(n as f64)).powi(2)
}
area
}
fn main() {
let t = timestamp();
println!("\n\t{}\t{}","Isovist Area: ", isovist());
println!("\t{}\t{}", "Time Taken: ", time... | code_fim | medium | {
"lang": "rust",
"repo": "akhilsadam/Isovist",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(target_arch = "wasm32")]
pub fn new(_font_spec: SugarloafFonts) -> Font {
let font_arc_unicode = FontArc::try_from_slice(FONT_UNICODE_FALLBACK).unwrap();
let font_arc_symbol = FontArc::try_from_slice(FONT_DEJAVU_SANS).unwrap();
Font {
text: ComposedFontAr... | code_fim | hard | {
"lang": "rust",
"repo": "raphamorim/rio",
"path": "/sugarloaf/src/font/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raphamorim/rio path: /sugarloaf/src/font/mod.rs
pub mod constants;
pub mod fonts;
use crate::font::constants::*;
use crate::font::fonts::*;
#[cfg(not(target_arch = "wasm32"))]
use font_kit::{properties::Style, source::SystemSource};
use glyph_brush::ab_glyph::FontArc;
#[cfg(not(target_arch = "w... | code_fim | hard | {
"lang": "rust",
"repo": "raphamorim/rio",
"path": "/sugarloaf/src/font/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Font {
// TODO: Refactor multiple unwraps in this code
// TODO: Use FontAttributes bold and italic
#[cfg(not(target_arch = "wasm32"))]
pub fn new(font_spec: SugarloafFonts) -> Font {
let font_arc_unicode;
let font_arc_symbol;
#[cfg(target_os = "macos")]
... | code_fim | hard | {
"lang": "rust",
"repo": "raphamorim/rio",
"path": "/sugarloaf/src/font/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theduke/rust path: /src/test/compile-fail/issue-21946.rs
// Copyright 2015 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
// h... | code_fim | medium | {
"lang": "rust",
"repo": "theduke/rust",
"path": "/src/test/compile-fail/issue-21946.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: panicbit/boggle path: /common/src/lib.rs
#[macro_use] extern crate serde_derive;
<|fim_suffix|>pub mod server {
pub mod message;
pub use self::message::Message;
}<|fim_middle|>pub mod client {
pub mod message;
pub use self::message::Message;
}
| code_fim | medium | {
"lang": "rust",
"repo": "panicbit/boggle",
"path": "/common/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod server {
pub mod message;
pub use self::message::Message;
}<|fim_prefix|>// repo: panicbit/boggle path: /common/src/lib.rs
#[macro_use] extern crate serde_derive;
<|fim_middle|>pub mod client {
pub mod message;
pub use self::message::Message;
}
| code_fim | medium | {
"lang": "rust",
"repo": "panicbit/boggle",
"path": "/common/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self: Pin<&mut Self>,
ctx: &mut Context<'_>,
buf: &[u8],
) -> Poll<io::Result<usize>> {
self.instance.0.poll_write(ctx, buf)
}
fn poll_flush(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll<io::Result<()>> {
self.instance.0.poll_flush(ctx)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "csunday95/interprocess",
"path": "/src/os/windows/named_pipe/tokio/stream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: csunday95/interprocess path: /src/os/windows/named_pipe/tokio/stream.rs
PipeStreamInternals,
};
use std::{
ffi::{OsStr, OsString},
fmt::{self, Debug, Formatter},
io,
mem::ManuallyDrop,
pin::Pin,
ptr,
sync::{
atomic::{AtomicBool, Ordering::Release},
Ar... | code_fim | hard | {
"lang": "rust",
"repo": "csunday95/interprocess",
"path": "/src/os/windows/named_pipe/tokio/stream.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.containers.push(container);
}
pub fn find_ingot_for_url(&self, url: &str) -> Option<&DynamicIngot> {
for container in self.containers.iter() {
if url.starts_with(&container.prefix) {
return Some(&container.instance);
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/ingots",
"path": "/smithy/src/engine.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagebind/ingots path: /smithy/src/engine.rs
use ingots_loader::DynamicIngot;
use std::path::PathBuf;
pub struct IngotEngine {
containers: Vec<IngotContainer>,
}
struct IngotContainer {
prefix: String,
instance: DynamicIngot,
}
impl IngotEngine {
pub fn new() -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/ingots",
"path": "/smithy/src/engine.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
pub fn local_worker_config(
worker_url: String,
untrusted_worker_port: String,
mu_ra_port: String,
) -> Config {
let mut url = worker_url.split(':');
Config::new(
Default::default(),
Default::default(),
url.next().unwrap().into(),
None,
url.next().unwrap().into(),
None,
unt... | code_fim | hard | {
"lang": "rust",
"repo": "encointer/encointer-worker",
"path": "/service/src/tests/commons.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: encointer/encointer-worker path: /service/src/tests/commons.rs
/*
Copyright 2021 Integritee AG and Supercomputing Systems AG
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 ... | code_fim | medium | {
"lang": "rust",
"repo": "encointer/encointer-worker",
"path": "/service/src/tests/commons.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>*/
use serde_derive::{Deserialize, Serialize};
use sgx_types::*;
use std::str;
#[cfg(test)]
use crate::config::Config;
#[derive(Debug, Serialize, Deserialize)]
pub struct Message {
pub account: String,
pub amount: u32,
pub sha256: sgx_sha256_hash_t,
}
#[cfg(test)]
pub fn local_worker_config(
worke... | code_fim | hard | {
"lang": "rust",
"repo": "encointer/encointer-worker",
"path": "/service/src/tests/commons.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akxl/rust_basics path: /let2.rs
// let2.rc
// learning about the assert_eq!() macro
<|fim_suffix|> let answer = 40;
assert_eq!(answer, 42); // let's get the programme to panic
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "akxl/rust_basics",
"path": "/let2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let answer = 40;
assert_eq!(answer, 42); // let's get the programme to panic
}<|fim_prefix|>// repo: akxl/rust_basics path: /let2.rs
// let2.rc
// learning about the assert_eq!() macro
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "akxl/rust_basics",
"path": "/let2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut layout = Layout::new_size(Size::new(128, 128));
layout.set_anchor(Side::Top, Anchor::parent(64));
layout.set_anchor(Side::Left, Anchor::parent(32));
layout.set_anchor(Side::Right, Anchor::parent(32));
let color_rect = gui.add_widget(gui.root(), layout, Quad:... | code_fim | hard | {
"lang": "rust",
"repo": "VulkanWorks/gristmill_rust_vulkano_game_engine_gui",
"path": "/gristmill-examples/src/bin/gui.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn update(&mut self, _window: &Window, input_system: &mut InputSystem, _delta: f64) -> bool {
input_system.dispatch_queue(&mut self.input);
let gui = &mut self.scene.1;
gui.process_input(&self.input);
let times_clicked = &mut self.times_clicked;
let old_times_c... | code_fim | hard | {
"lang": "rust",
"repo": "VulkanWorks/gristmill_rust_vulkano_game_engine_gui",
"path": "/gristmill-examples/src/bin/gui.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VulkanWorks/gristmill_rust_vulkano_game_engine_gui path: /gristmill-examples/src/bin/gui.rs
use gristmill::asset::Resources;
use gristmill::game::{Game, Window, run_game};
use gristmill_gui::{Gui, WidgetNode, GuiInputActions, event::GuiActionEvent, quad::Quad, button::ButtonClass, text::Text, la... | code_fim | hard | {
"lang": "rust",
"repo": "VulkanWorks/gristmill_rust_vulkano_game_engine_gui",
"path": "/gristmill-examples/src/bin/gui.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let id: u32 = pool
.get_conn()
.unwrap()
.exec_first("SELECT CONNECTION_ID();", ())
.unwrap()
.unwrap();
conn.query_drop(&*format!("KILL {}", id)).unwrap();
thread::sleep(Duration::from_mil... | code_fim | hard | {
"lang": "rust",
"repo": "blackbeam/rust-mysql-simple",
"path": "/src/conn/pool/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn close(&mut self, stmt: Statement) -> Result<()> {
self.conn.as_mut().unwrap().close(stmt)
}
fn exec_iter<S, P>(&mut self, stmt: S, params: P) -> Result<QueryResult<'_, '_, '_, Binary>>
where
S: AsStatement,
P: Into<Params>,
{
self.conn.as_mut().unwra... | code_fim | hard | {
"lang": "rust",
"repo": "blackbeam/rust-mysql-simple",
"path": "/src/conn/pool/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blackbeam/rust-mysql-simple path: /src/conn/pool/mod.rs
).
pub fn new<T, E>(opts: T) -> Result<Pool>
where
Opts: TryFrom<T, Error = E>,
crate::Error: From<E>,
{
Ok(Pool {
inner: Arc::new(inner::Inner::new(Opts::try_from(opts)?)?),
})
}
... | code_fim | hard | {
"lang": "rust",
"repo": "blackbeam/rust-mysql-simple",
"path": "/src/conn/pool/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct AssetInfos {
pub name: String,
pub version: String,
pub dependencies: Vec<Dependency>,
pub dev_dependencies: Vec<Dependency>,
}
#[derive(Clone, Serialize, Deserialize, Debug)]
#[serde(rename_all ... | code_fim | hard | {
"lang": "rust",
"repo": "kuroidoruido/OctoDeps",
"path": "/src/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct App {
pub name: String,
pub group: String,
// use for config file
pub asset_version_urls: Vec<String>,
// use for template
pub asset_infos: Option<Vec<AssetInfos>>,
}
#[derive(Clone, Seri... | code_fim | medium | {
"lang": "rust",
"repo": "kuroidoruido/OctoDeps",
"path": "/src/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kuroidoruido/OctoDeps path: /src/models.rs
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct ConfigFile {
pub groups: Vec<Group>,
pub apps: Vec<App>,
}
#[derive(Clone, Debug)]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "kuroidoruido/OctoDeps",
"path": "/src/models.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: K0bin/SourceRenderer path: /engine/src/asset/loaders/vpk_container.rs
use std::io::{
Cursor,
Error as IOError,
ErrorKind,
};
use std::path::Path;
use std::sync::Arc;
use regex::Regex;
use sourcerenderer_core::Platform;
use sourcerenderer_vpk::{
Package,
PackageError,
};
use... | code_fim | hard | {
"lang": "rust",
"repo": "K0bin/SourceRenderer",
"path": "/engine/src/asset/loaders/vpk_container.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let entry = self.package.find_entry(path);
entry
.and_then(|entry| self.package.read_entry(entry, false).ok())
.map(|data| AssetFile {
path: path.to_string(),
data: Cursor::new(data),
})
}
}
pub struct VPKContainerLoa... | code_fim | hard | {
"lang": "rust",
"repo": "K0bin/SourceRenderer",
"path": "/engine/src/asset/loaders/vpk_container.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mayah/puyoai.rs path: /puyoai-core/src/rensa_detector/mod.rs
#[cfg(all(target_feature = "avx2", target_fea<|fim_suffix|>lone, Copy, Debug, PartialEq)]
pub enum PurposeForFindingRensa {
ForFire,
ForKey,
}<|fim_middle|>ture = "bmi2"))]
pub mod detector;
#[derive(C | code_fim | easy | {
"lang": "rust",
"repo": "mayah/puyoai.rs",
"path": "/puyoai-core/src/rensa_detector/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>seForFindingRensa {
ForFire,
ForKey,
}<|fim_prefix|>// repo: mayah/puyoai.rs path: /puyoai-core/src/rensa_detector/mod.rs
#[cfg(all(target_feature = "avx2", target_feature = "bmi2"))]
pub mod detector;
#[derive(C<|fim_middle|>lone, Copy, Debug, PartialEq)]
pub enum Purpo | code_fim | easy | {
"lang": "rust",
"repo": "mayah/puyoai.rs",
"path": "/puyoai-core/src/rensa_detector/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> crate::mutators::match_mutation(
r#"
(module
(type (;0;) (func (param i32 f32) (result i64)))
)
"#,
AddFunctionMutator,
r#"
(module
(type (;0;) (func (param i32 f... | code_fim | hard | {
"lang": "rust",
"repo": "Horki/wasm-tools",
"path": "/crates/wasm-mutate/src/mutators/add_function.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Horki/wasm-tools path: /crates/wasm-mutate/src/mutators/add_function.rs
//! Mutator that adds new, empty functions.
use super::Mutator;
use crate::module::{PrimitiveTypeInfo, TypeInfo};
use crate::{Result, WasmMutate};
use rand::Rng;
use std::convert::TryFrom;
use wasm_encoder::{Instruction, Mo... | code_fim | hard | {
"lang": "rust",
"repo": "Horki/wasm-tools",
"path": "/crates/wasm-mutate/src/mutators/add_function.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn can_mutate<'a>(&self, config: &'a WasmMutate) -> bool {
// Note: adding a new, never-called function preserves semantics so we
// don't need to gate on whether `config.preserve_semantics` is set or
// not.
!config.reduce && config.info().num_types() > 0
}
}
#[cf... | code_fim | hard | {
"lang": "rust",
"repo": "Horki/wasm-tools",
"path": "/crates/wasm-mutate/src/mutators/add_function.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> fake_data_model()
}
#[test]
fn test_component_search() {
let model = data_model();
let search = ComponentSearchController::default();
model
.set(Components::new(vec![Component {
id: 0,
url: "foo".to_string(),
... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/security/scrutiny/lib/plugins/src/search/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvanotti/fuchsia-mirror path: /src/security/scrutiny/lib/plugins/src/search/mod.rs
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
mod controller;
use {
crate::search::contro... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/security/scrutiny/lib/plugins/src/search/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let model = data_model();
let search = ComponentSearchController::default();
model
.set(Components::new(vec![Component {
id: 0,
url: "foo".to_string(),
version: 0,
source: fake_component_src_pkg(),
... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/security/scrutiny/lib/plugins/src/search/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn apply(old: &CryptoSecretbox, diff: &CryptoSecretbox) -> Result<CryptoSecretbox> {
let old = crypto::decrypt_state(&old)?;
let diff = crypto::decrypt_state(&diff)?;
let new = apply_internal(&old, &diff)?;
Ok(crypto::encrypt_state(new)?)
}<|fim_prefix|>// repo: summerhhh/ekiden path... | code_fim | hard | {
"lang": "rust",
"repo": "summerhhh/ekiden",
"path": "/db/trusted/src/diffs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: summerhhh/ekiden path: /db/trusted/src/diffs.rs
use std;
use bsdiff;
use bzip2;
use protobuf;
use protobuf::Message;
use ekiden_common::error::Result;
use super::crypto;
use super::generated::database::{BsdiffPatch, CryptoSecretbox};
/// Diff: create a summary of changes that can be applied ... | code_fim | hard | {
"lang": "rust",
"repo": "summerhhh/ekiden",
"path": "/db/trusted/src/diffs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(crypto::encrypt_state(diff)?)
}
pub fn apply(old: &CryptoSecretbox, diff: &CryptoSecretbox) -> Result<CryptoSecretbox> {
let old = crypto::decrypt_state(&old)?;
let diff = crypto::decrypt_state(&diff)?;
let new = apply_internal(&old, &diff)?;
Ok(crypto::encrypt_state(new)?)
}<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "summerhhh/ekiden",
"path": "/db/trusted/src/diffs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Detr/Rusted path: /src/solutions/num_of_subarrays.rs
pub fn num_of_subarrays(arr: Vec<i32>) -> i32 {
let mut prev: (i32, i32) = (arr[0] & 1, !arr[0] & 1);
le<|fim_suffix|> cur.1 = prev.1 + 1;
}
prev = cur;
res = (res + prev.0) % 1000000007;
}
res
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "Detr/Rusted",
"path": "/src/solutions/num_of_subarrays.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> cur.1 = prev.1 + 1;
}
prev = cur;
res = (res + prev.0) % 1000000007;
}
res
}<|fim_prefix|>// repo: Detr/Rusted path: /src/solutions/num_of_subarrays.rs
pub fn num_of_subarrays(arr: Vec<i32>) -> i32 {
let mut prev: (i32, i32) = (arr[0] & 1, !arr[0] & 1);
le<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "Detr/Rusted",
"path": "/src/solutions/num_of_subarrays.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nickray/lpc55-pac path: /src/casper.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Contains the offsets of AB and CD in the RAM."]
pub ctrl0: CTRL0,
#[doc = "0x04 - Contains the opcode mode, iteration count, and result offset (in RAM) and also lau... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/casper.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ructure"]
impl crate::Readable for RES1 {}
#[doc = "`write(|w| ..)` method takes [res1::W](res1::W) writer structure"]
impl crate::Writable for RES1 {}
#[doc = "Result register 1"]
pub mod res1;
#[doc = "Result register 2\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::gener... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/casper.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// send a character to serial console
pub fn send(c : u32) {
while unsafe { volatile_load(UART0_LSR) } & (1 << 5) == 0 {
unsafe { llvm_asm!("nop;") };
}
unsafe {
volatile_store(UART0_THR, c as u64);
}
}<|fim_prefix|>// repo: nknk290854/baremetalisp_pine64 path: /kernel/s... | code_fim | medium | {
"lang": "rust",
"repo": "nknk290854/baremetalisp_pine64",
"path": "/kernel/src/driver/device/a64/uart.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nknk290854/baremetalisp_pine64 path: /kernel/src/driver/device/a64/uart.rs
use core::intrinsics::volatile_store;
use core::intrinsics::volatile_load;
use super::memory;
pub const SUNXI_UART0_BASE: u32 = (memory::MMIO_BASE + 0x00028000) as u32;
pub const UART0_THR: *mut u64 = (SUNXI_UART0_BASE... | code_fim | medium | {
"lang": "rust",
"repo": "nknk290854/baremetalisp_pine64",
"path": "/kernel/src/driver/device/a64/uart.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(brace::replace("ab{cd{ef}g{hi}j}",&rev),"abjhigefdc");
assert_eq!(brace::replace("ab{cd{ef}g{hij",&rev),"abhijgefdc");
assert_eq!(brace::replace("as}b{ef}",&rev),"as}bfe");
//fix test so not locked to my account
assert_eq!(brace::env_replace("h{HOME}"),"h/home/matthew");
... | code_fim | hard | {
"lang": "rust",
"repo": "storyfeet/lazyf-rs",
"path": "/src/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: storyfeet/lazyf-rs path: /src/tests.rs
use flag;
use lzlist;
use brace;
use cfg;
use get::SGetter;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
#[test]
fn args(){
let v = ["-a","60"];
let r = flag::ss_get("-a",&mut v.into_iter().map(|&a|String::from(a)));
assert_eq!(r,Some... | code_fim | medium | {
"lang": "rust",
"repo": "storyfeet/lazyf-rs",
"path": "/src/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.