text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: sooxt98/doboom path: /src/endpoints/pagination.rs
use std::default::Default;
const DEFAULT_PER_PAGE: i32 = 10;
const DEFAULT_PAGE: i32 = 1;
pub struct Pagination {
per_page: Option<i32>,
page: Option<i32>
}
impl Default for Pagination {
fn default() -> Self {
Self {
... | code_fim | medium | {
"lang": "rust",
"repo": "sooxt98/doboom",
"path": "/src/endpoints/pagination.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_page(&self) -> i32 {
self.page.unwrap_or(DEFAULT_PAGE)
}
}<|fim_prefix|>// repo: sooxt98/doboom path: /src/endpoints/pagination.rs
use std::default::Default;
const DEFAULT_PER_PAGE: i32 = 10;
const DEFAULT_PAGE: i32 = 1;
pub struct Pagination {
per_page: Option<i32>,
... | code_fim | hard | {
"lang": "rust",
"repo": "sooxt98/doboom",
"path": "/src/endpoints/pagination.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn add_no_mreq(&mut self, _address: u16, add_ts: NonZeroU8) {
self.time += add_ts.get() as u64;
}
fn add_m1(&mut self, _address: u16) -> Self::Timestamp {
self.time += cycles::M1_CYCLE_TS as u64;
self.as_timestamp()
}
fn add_mreq(&mut self, _address: u16) -> S... | code_fim | hard | {
"lang": "rust",
"repo": "SuperTails/mega-rust",
"path": "/src/z80.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Z80Clock {
pub fn new() -> Z80Clock {
Z80Clock { time: 0 }
}
}
impl Clock for Z80Clock {
type Limit = u64;
type Timestamp = u64;
fn is_past_limit(&self, limit: Self::Limit) -> bool {
self.time > limit
}
fn add_irq(&mut self, _pc: u16) -> Self::Timestamp ... | code_fim | hard | {
"lang": "rust",
"repo": "SuperTails/mega-rust",
"path": "/src/z80.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SuperTails/mega-rust path: /src/z80.rs
use crate::bindings::context::Z80View;
use crate::cpu::address_space::AddressSpace;
use crate::cpu::instruction::Size;
use sdl2::audio::AudioCallback;
use std::cell::RefCell;
use std::num::{NonZeroU16, NonZeroU8};
use std::sync::{Arc, Mutex};
use z80emu::{h... | code_fim | hard | {
"lang": "rust",
"repo": "SuperTails/mega-rust",
"path": "/src/z80.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::env;
use std::error::Error;
use tokio::io::AsyncWriteExt;
use tokio::net::TcpStream;
#[tokio::main]
pub async fn main() -> Result<(), Box<dyn Error>> {
let message = env::args()
.nth(1)
.unwrap_or_else(|| "hello world".to_string());
let mut stream = TcpStream::connect("12... | code_fim | hard | {
"lang": "rust",
"repo": "mkindahl/tokio-examples",
"path": "/examples/sender-tcp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkindahl/tokio-examples path: /examples/sender-tcp.rs
// Copyright 2020 Mats Kindahl
//
// 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.... | code_fim | medium | {
"lang": "rust",
"repo": "mkindahl/tokio-examples",
"path": "/examples/sender-tcp.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ring::String>) -> Self {
self.inner = self.inner.next_token(inp);
self
}
pub fn set_next_token(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_next_token(input);
self
}
/// <p>T... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/cloud9/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn send(
self,
) -> std::result::Result<
crate::output::DescribeEnvironmentStatusOutput,
smithy_http::result::SdkError<crate::error::DescribeEnvironmentStatusError>,
>
where
R::Policy: smithy_client::bounds::SmithyRetryPo... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/cloud9/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/cloud9/src/client.rs
self
}
pub fn set_user_arn(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_user_arn(input);
self
}
/// <p>The type of environment member ... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/cloud9/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if st == nums[nums.len() - 1] {
ans.push(st.to_string());
} else {
ans.push(format!("{}->{}", st, nums[nums.len() - 1]));
}
ans
}
}
}<|fim_prefix|>// repo: Cheshulko/Algorithms path: /Leetcode/SummaryRanges.rs
//... | code_fim | hard | {
"lang": "rust",
"repo": "Cheshulko/Algorithms",
"path": "/Leetcode/SummaryRanges.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cheshulko/Algorithms path: /Leetcode/SummaryRanges.rs
// https://leetcode.com/problems/summary-ranges
struct Solution {}
impl Solution {
pub fn summary_ranges(nums: Vec<i32>) -> Vec<String> {
if nums.len() == 0 {
vec![]
} else {
let mut st = nums[0];... | code_fim | hard | {
"lang": "rust",
"repo": "Cheshulko/Algorithms",
"path": "/Leetcode/SummaryRanges.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aligorith/xspf_parser_jsl-rs path: /src/track_name_info.rs
/* Types and Utilities for decomposing track filenames
* to extract out all the metadata they contain
*/
//#[macro_use] extern crate lazy_static;
extern crate regex;
use self::regex::Regex;
use std::fmt;
use std::str::FromStr;
use std... | code_fim | hard | {
"lang": "rust",
"repo": "Aligorith/xspf_parser_jsl-rs",
"path": "/src/track_name_info.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("P", TrackType::Piano.shortname());
assert_eq!("P", TrackType::Piano.shortname_safe());
assert_eq!("V", TrackType::Voice.shortname());
assert_eq!("V", TrackType::Voice.shortname_safe());
}
/* Check that violin-layering filenames parse correctly ---------------------------... | code_fim | hard | {
"lang": "rust",
"repo": "Aligorith/xspf_parser_jsl-rs",
"path": "/src/track_name_info.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Riey/borrowed-thread path: /tests/tests.rs
#[test]
fn ref_mut_works() {
let mut owned = "ABC".to_owned();
let borrowed_handle = borrowed_thread::spawn(|| {
owned.push('D');
0
});
assert_eq!(0, borrowed_handle.join().expect("join err"));
assert_eq!("ABCD", ow... | code_fim | hard | {
"lang": "rust",
"repo": "Riey/borrowed-thread",
"path": "/tests/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let borrowed_handle = borrowed_thread::spawn(|| {
assert_eq!("ABC", owned);
0
});
let ret = borrowed_handle.join().expect("join err");
assert_eq!(0, ret);
}<|fim_prefix|>// repo: Riey/borrowed-thread path: /tests/tests.rs
#[test]
fn ref_mut_works() {
let mut owned = ... | code_fim | hard | {
"lang": "rust",
"repo": "Riey/borrowed-thread",
"path": "/tests/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn very_complex_attribute(input: &str) -> LibRes<&str, (&str, LibertyJson)> {
terminated(tuple((tstring, very_complex_attribute_value)), ws(tag(";")))(input)
}
pub fn group_attribute_parser(input: &str) -> LibRes<&str, (&str, LibertyJson)> {
context(
"Group Attribute Parser",
alt(... | code_fim | hard | {
"lang": "rust",
"repo": "erihsu/liberty2json",
"path": "/src/parser/attribute_parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erihsu/liberty2json path: /src/parser/attribute_parser.rs
use super::base::{
complex_attribue_value, simple_attribute_value, tstring, very_complex_attribute_value, ws,
};
use crate::{LibRes, LibertyJson};
use nom::{
branch::alt,
bytes::complete::tag,
error::context,
sequence:... | code_fim | medium | {
"lang": "rust",
"repo": "erihsu/liberty2json",
"path": "/src/parser/attribute_parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ajmwagar/rusty-editor path: /src/scene/commands/graph.rs
use crate::{
command::Command, define_node_command, get_set_swap, physics::Physics,
scene::commands::SceneContext,
};
use rg3d::{
animation::Animation,
core::{
algebra::{UnitQuaternion, Vector3},
pool::{Hand... | code_fim | hard | {
"lang": "rust",
"repo": "ajmwagar/rusty-editor",
"path": "/src/scene/commands/graph.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ticket) = self.ticket.take() {
context.scene.graph.forget_ticket(ticket)
}
}
}
#[derive(Debug)]
pub struct LoadModelCommand {
path: PathBuf,
model: Handle<Node>,
animations: Vec<Handle<Animation>>,
sub_graph: Option<SubGraph>,
animations_con... | code_fim | hard | {
"lang": "rust",
"repo": "ajmwagar/rusty-editor",
"path": "/src/scene/commands/graph.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kawashige/code_jam_2021 path: /round_1a/append_sort/src/main.rs
use std::str::FromStr;
fn read<T: FromStr>() -> T {
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).unwrap();
buf.trim().parse().ok().unwrap()
}
fn main() {
let t: usize = read();
for x in 0.... | code_fim | hard | {
"lang": "rust",
"repo": "kawashige/code_jam_2021",
"path": "/round_1a/append_sort/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 1..n {
let mut current = nums.remove(0);
let current_l = current.len();
if prev_l == current_l {
if prev >= current {
current.push(0);
count += 1;
}
} else if prev_l > ... | code_fim | hard | {
"lang": "rust",
"repo": "kawashige/code_jam_2021",
"path": "/round_1a/append_sort/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ub mod payload;
pub mod utility;
pub mod user_builders;<|fim_prefix|>// repo: lore-lml/iota-streams-lib path: /src/lib.rs
#![deny(
bad_style,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unstable_features
)]
#![cfg_attr(not(d<|fim_middle|>ebug_assertions), deny(warnings))]
pub mod channels;
p | code_fim | easy | {
"lang": "rust",
"repo": "lore-lml/iota-streams-lib",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lore-lml/iota-streams-lib path: /src/lib.rs
#![deny(
bad_style,
trivial_casts,
trivial_numeric_cas<|fim_suffix|>ebug_assertions), deny(warnings))]
pub mod channels;
pub mod payload;
pub mod utility;
pub mod user_builders;<|fim_middle|>ts,
unsafe_code,
unstable_features
)]
#![cfg_attr(not(d | code_fim | easy | {
"lang": "rust",
"repo": "lore-lml/iota-streams-lib",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ebug_assertions), deny(warnings))]
pub mod channels;
pub mod payload;
pub mod utility;
pub mod user_builders;<|fim_prefix|>// repo: lore-lml/iota-streams-lib path: /src/lib.rs
#![deny(
bad_style,
trivial_casts,
trivial_numeric_cas<|fim_middle|>ts,
unsafe_code,
unstable_features
)]
#![cfg_attr(not(d | code_fim | easy | {
"lang": "rust",
"repo": "lore-lml/iota-streams-lib",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
input! {
n: usize,
}
let mut d = vec![];
let mut x = n;
while x > 0 {
d.push(x % 10);
x /= 10;
}
let mut count = vec![0; 3];
let k = d.len();
for i in 0..k {
count[d[i] % 3] += 1;
}
let s = d.iter().sum::<usize>();
... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc182/src/bin/c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
n: usize,
}
let mut d = vec![];
let mut x = n;
while x > 0 {
d.push(x % 10);
x /= 10;
}
let mut count = vec![0; 3];
let k = d.len();
for i in 0..k {
count[d[i] % 3] += 1;
}
let s = d.iter().sum::<usize>();
let result ... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc182/src/bin/c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likr/atcoder path: /abc182/src/bin/c.rs
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
<|fim_suffix|> input! {
n: usiz... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc182/src/bin/c.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(false, ext_table.is_blocked(DigestAlgo::Md5));
assert_eq!(true, ext_table.is_md5("whl".to_string()));
assert_eq!(true, ext_table.is_md5("gz".to_string()));
assert_eq!(false, ext_table.is_md5("jar".to_string()));
assert_eq!(true, ext_table.is_blocked(DigestAlgo::Sha1));
... | code_fim | hard | {
"lang": "rust",
"repo": "versioneye/veye-checker",
"path": "/tests/configs_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: versioneye/veye-checker path: /tests/configs_test.rs
extern crate veye_checker;
use std::env;
use std::path::PathBuf;
use veye_checker::configs;
use veye_checker::digest_ext_table::{DigestAlgo, DigestExtTable};
#[test]
fn test_configs_read_api_configs_from_env(){
//set up env
env::set_... | code_fim | hard | {
"lang": "rust",
"repo": "versioneye/veye-checker",
"path": "/tests/configs_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let toml_path = PathBuf::from("./tests/fixtures/only_file_exts.toml");
let confs = configs::read_configs_from_toml(&toml_path).expect("Failed to parse `only_file_exts`");
let ext_table = confs.digests;
assert_eq!(false, ext_table.is_blocked(DigestAlgo::Md5));
assert_eq!(true, ext_tab... | code_fim | hard | {
"lang": "rust",
"repo": "versioneye/veye-checker",
"path": "/tests/configs_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: casey/intermodal path: /bin/gen/src/faq_entry.rs
use crate::common::*;
#[derive(Clone, Debug, Deserialize)]
pub(crate) struct FaqEntry <|fim_suffix|>text: String,
pub(crate) anchor: String,
}<|fim_middle|>{
pub(crate) title: String,
pub(crate) | code_fim | easy | {
"lang": "rust",
"repo": "casey/intermodal",
"path": "/bin/gen/src/faq_entry.rs",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|>text: String,
pub(crate) anchor: String,
}<|fim_prefix|>// repo: casey/intermodal path: /bin/gen/src/faq_entry.rs
use crate::common::*;
#[derive(Clone, Debu<|fim_middle|>g, Deserialize)]
pub(crate) struct FaqEntry {
pub(crate) title: String,
pub(crate) | code_fim | medium | {
"lang": "rust",
"repo": "casey/intermodal",
"path": "/bin/gen/src/faq_entry.rs",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: casey/intermodal path: /bin/gen/src/faq_entry.rs
use crate::common::*;
#[derive(Clone, Debu<|fim_suffix|>{
pub(crate) title: String,
pub(crate) text: String,
pub(crate) anchor: String,
}<|fim_middle|>g, Deserialize)]
pub(crate) struct FaqEntry | code_fim | easy | {
"lang": "rust",
"repo": "casey/intermodal",
"path": "/bin/gen/src/faq_entry.rs",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.vars.iter().flat_map(|v| v.dependencies(FDEvent::Inner)).collect()
}
}
#[cfg(test)]
mod test {
use super::*;
use kernel::*;
use kernel::Trilean::*;
use propagation::events::*;
use propagation::events::FDEvent::*;
use interval::interval::*;
use propagators::test::*;
#[test]
f... | code_fim | hard | {
"lang": "rust",
"repo": "musitdev/pcp",
"path": "/src/libpcp/propagators/distinct.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: musitdev/pcp path: /src/libpcp/propagators/distinct.rs
// Copyright 2015 Pierre Talbot (IRCAM)
// 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://www.apa... | code_fim | hard | {
"lang": "rust",
"repo": "musitdev/pcp",
"path": "/src/libpcp/propagators/distinct.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for p in &mut self.props {
if !p.propagate(store) {
return false;
}
}
true
}
}
impl<V> PropagatorDependencies<FDEvent> for Distinct<V> where
V: ViewDependencies<FDEvent> + Clone
{
fn dependencies(&self) -> Vec<(usize, FDEvent)> {
self.vars.iter().flat_map(|v| v.d... | code_fim | hard | {
"lang": "rust",
"repo": "musitdev/pcp",
"path": "/src/libpcp/propagators/distinct.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(genotype.to_string(), "0|0:13");
Ok(())
}
#[test]
fn test_try_from_fields_for_genotype() {
assert!(Genotype::try_from(Vec::new()).is_ok());
let fields = vec![Field::new(
field::Key::Genotype,
Some(field::Value::String(String... | code_fim | hard | {
"lang": "rust",
"repo": "luccasmmg/noodles",
"path": "/noodles-vcf/src/record/genotype.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luccasmmg/noodles path: /noodles-vcf/src/record/genotype.rs
//! VCF record genotype and field.
pub mod field;
pub use self::field::Field;
use std::{convert::TryFrom, error, fmt, ops::Deref};
use indexmap::IndexMap;
use super::{Format, MISSING_FIELD};
const DELIMITER: char = ':';
/// A VCF... | code_fim | hard | {
"lang": "rust",
"repo": "luccasmmg/noodles",
"path": "/noodles-vcf/src/record/genotype.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let image = raytracer::render(&scene);
let image_path = "test.png";
let mut image_file = OpenOptions::new()
.write(true).truncate(true).create(true).open(image_path).unwrap();
image.save(&mut image_file, ImageFormat::PNG).unwrap();
}<|fim_prefix|>// repo: go717franciswang/raytracer... | code_fim | hard | {
"lang": "rust",
"repo": "go717franciswang/raytracer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: go717franciswang/raytracer path: /src/main.rs
extern crate image;
extern crate raytracer;
use raytracer::scene::{Vec3, Scene, Sphere};
use std::fs::OpenOptions;
use image::ImageFormat;
<|fim_suffix|> let scene = Scene {
width: 1920,
height: 1200,
fov: 30.0,
s... | code_fim | medium | {
"lang": "rust",
"repo": "go717franciswang/raytracer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> format!("com.edgedb.edgedb-server-{}.plist", name)
}
pub fn launchd_plist_path(name: &str, system: bool)
-> anyhow::Result<PathBuf>
{
Ok(plist_dir(system)?.join(plist_name(name)))
}
fn plist_data(settings: &init::Settings)
-> anyhow::Result<String>
{
Ok(format!(r###"
<?xml version="1... | code_fim | hard | {
"lang": "rust",
"repo": "CodesInChaos/edgedb-cli",
"path": "/src/server/macos.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if system {
Ok(PathBuf::from("/Library/LaunchDaemons"))
} else {
Ok(home_dir()?.join("Library/LaunchAgents"))
}
}
fn plist_name(name: &str) -> String {
format!("com.edgedb.edgedb-server-{}.plist", name)
}
pub fn launchd_plist_path(name: &str, system: bool)
-> anyhow::R... | code_fim | hard | {
"lang": "rust",
"repo": "CodesInChaos/edgedb-cli",
"path": "/src/server/macos.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CodesInChaos/edgedb-cli path: /src/server/macos.rs
use std::fs;
use std::str;
use std::path::{Path, PathBuf};
use std::process::{exit, Command as StdCommand};
use anyhow::Context;
use async_std::task;
use serde::Serialize;
use crate::platform::{Uid, get_current_uid, home_dir};
use crate::proce... | code_fim | hard | {
"lang": "rust",
"repo": "CodesInChaos/edgedb-cli",
"path": "/src/server/macos.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tkubicz/warsztat path: /server/src/app.rs
use std::sync::Arc;
use tokio::sync::Mutex;
use tokio::time::delay_for;
use std::time::Duration;
<|fim_suffix|>impl AppState {
pub fn new() -> Arc<AppState> {
Arc::new(AppState {
state: Mutex::new(AppStateInner::new())
})... | code_fim | hard | {
"lang": "rust",
"repo": "tkubicz/warsztat",
"path": "/server/src/app.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn incrementCounter(self: &Arc<Self>) {
let mut guard = self.state.lock().await;
delay_for(Duration::from_millis(100)).await; //Sztuczne opóźnienie
(*guard).counter += 1;
}
}<|fim_prefix|>// repo: tkubicz/warsztat path: /server/src/app.rs
use std::sync... | code_fim | hard | {
"lang": "rust",
"repo": "tkubicz/warsztat",
"path": "/server/src/app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn run_macos(&self) -> Result<PreflightCheckResult> {
let (status, stdout, _) = (self.command_runner)(&vec!["sysctl", "kern.hv_support"])?;
if status.success() && stdout.trim() == "kern.hv_support: 1" {
return Ok(Success(SUCCESS_MESSAGE_MACOS.to_string()));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "yueyedeai/fuchsia",
"path": "/src/developer/ffx/plugins/platform/preflight/src/check/emu_acceleration.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let check = EmuAcceleration::new(&run_command);
let response = check.run(&PreflightConfig { system: OperatingSystem::MacOS(10, 15) }).await;
assert!(matches!(response?, PreflightCheckResult::Warning(..)));
Ok(())
}
#[fuchsia_async::run_singlethreaded(test)]
asy... | code_fim | hard | {
"lang": "rust",
"repo": "yueyedeai/fuchsia",
"path": "/src/developer/ffx/plugins/platform/preflight/src/check/emu_acceleration.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yueyedeai/fuchsia path: /src/developer/ffx/plugins/platform/preflight/src/check/emu_acceleration.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.
use {
crate::check::{Prefli... | code_fim | hard | {
"lang": "rust",
"repo": "yueyedeai/fuchsia",
"path": "/src/developer/ffx/plugins/platform/preflight/src/check/emu_acceleration.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: primetype/scaffolding path: /src/settings.rs
use std::{
any::{type_name, Any, TypeId},
collections::HashMap,
fmt,
sync::Arc,
time::Duration,
};
#[derive(Debug, Clone)]
pub struct Settings {
options: HashMap<TypeId, Arc<dyn Setting + 'static>>,
}
impl Default for Setting... | code_fim | hard | {
"lang": "rust",
"repo": "primetype/scaffolding",
"path": "/src/settings.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get<S>(&self) -> Option<Arc<S>>
where
S: Setting,
{
let any: Arc<dyn Any + Send + Sync + 'static> =
unsafe { std::mem::transmute(self.options.get(&TypeId::of::<S>()).cloned()?) };
match Arc::downcast(any) {
Ok(v) => Some(v),
#... | code_fim | hard | {
"lang": "rust",
"repo": "primetype/scaffolding",
"path": "/src/settings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match Arc::downcast(any) {
Ok(v) => Some(v),
#[cfg(feature = "type_name_of_val")]
Err(o) => {
panic!(
"failed to downcast {original} into {expected}",
original = std::any::type_name_of_val(&o),
... | code_fim | hard | {
"lang": "rust",
"repo": "primetype/scaffolding",
"path": "/src/settings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if history.is_empty() {
return;
}
while !history.is_empty() && *history.front().unwrap() < cutoff {
history.pop_front();
}
}
#[cfg(test)]
mod tests {
use std::time::{Duration, Instant};
use super::*;
#[test]
#[should_panic(expected = "Rate must be posit... | code_fim | hard | {
"lang": "rust",
"repo": "Gorthezar/blood-money",
"path": "/src/thread_throttler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while history.len() >= self.rate as usize {
let minimum_sleep = (*history.get(0).unwrap() + self.interval) - Instant::now();
let (lock_result, _) = self.cv.wait_timeout(history, minimum_sleep).unwrap();
history = lock_result;
prune_history(&mut histo... | code_fim | hard | {
"lang": "rust",
"repo": "Gorthezar/blood-money",
"path": "/src/thread_throttler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gorthezar/blood-money path: /src/thread_throttler.rs
use std::collections::VecDeque;
use std::sync::{Condvar, Mutex};
use std::time::{Duration, Instant};
/// A ThreadThrottle is used to control the rate of
/// thread progress, for example to limit the number
/// of requests sent to a web API pe... | code_fim | hard | {
"lang": "rust",
"repo": "Gorthezar/blood-money",
"path": "/src/thread_throttler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn try_receive_next_actor(mut ctx: SyncContext<String>) {
loop {
match ctx.try_receive_next() {
Ok(msg) => {
assert_eq!(msg, "Hello world");
return;
}
Err(RecvError::Empty) => continue,
Err(RecvError::Disconnected)... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/heph",
"path": "/tests/functional/sync_actor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/heph path: /tests/functional/sync_actor.rs
#![cfg(feature = "test")]
use std::future::Future;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{self, Poll};
use std::thread::sleep;
use std::time::Duration;
use heph::actor::{RecvError, SyncContext};
use heph::spawn::SyncAc... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/heph",
"path": "/tests/functional/sync_actor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (handle, _) = spawn_sync_actor(
NoSupervisor,
block_on_actor as fn(_, _) -> _,
future.clone(),
SyncActorOptions::default(),
)
.unwrap();
while !future.has_waker() {
sleep(Duration::from_millis(10));
}
future.unblock();
handle.join()... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/heph",
"path": "/tests/functional/sync_actor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
impl R {
#[doc = "Bits 0:7 - These bits read back as 0xF0"]
#[inline(always)]
pub fn uartpcellid1(&self) -> UARTPCELLID1_R {
UARTPCELLID1_R::new((self.bits & 0xff) as u8)
}
}
#[doc = "UARTPCellID1 Register
This register you can [`read`](crate::generic::Re... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/rp2040-pac",
"path": "/src/uart0/uartpcellid1.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgottschlag/rp2040-pac path: /src/uart0/uartpcellid1.rs
#[doc = "Register `UARTPCELLID1` reader"]
pub struct R(crate::R<UARTPCELLID1_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<UARTPCELLID1_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
<|fim_suffix|>Thi... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/rp2040-pac",
"path": "/src/uart0/uartpcellid1.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GyulyVGC/sniffnet path: /src/secondary_threads/write_report_file.rs
//! Module containing functions executed by the thread in charge of updating the output report every 1 second
use std::collections::HashSet;
use std::fs::File;
use std::io::{BufWriter, Seek, SeekFrom, Write};
use std::sync::{Ar... | code_fim | hard | {
"lang": "rust",
"repo": "GyulyVGC/sniffnet",
"path": "/src/secondary_threads/write_report_file.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut status = status_pair.0.lock().expect("Error acquiring mutex\n\r");
if *status == Status::Running {
drop(status);
let mut info_traffic = info_traffic_mutex
.lock()
.expect("Error acquiring mutex\n\r");
for index ... | code_fim | hard | {
"lang": "rust",
"repo": "GyulyVGC/sniffnet",
"path": "/src/secondary_threads/write_report_file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut capture_id = *current_capture_id.lock().unwrap();
let mut output =
BufWriter::new(File::create(path_report.clone()).expect("Error creating output file\n\r"));
writeln!(output, "----------------------------------------------------------------------------------------------------... | code_fim | medium | {
"lang": "rust",
"repo": "GyulyVGC/sniffnet",
"path": "/src/secondary_threads/write_report_file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn types() {
let _ = <sol!(bool)>::encode_single(&true);
let _ = B32::encode_single(&[0; 32]);
let _ = SolArrayOf::<sol!(bool)>::encode_single(&vec![true, false]);
let _ = SolTuple::encode_single(&(Address::ZERO, vec![0; 32], "hello".to_string()));
}<|fim_prefix|>// repo: roynalnar... | code_fim | medium | {
"lang": "rust",
"repo": "roynalnaruto/core",
"path": "/crates/sol-types/tests/doctests/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roynalnaruto/core path: /crates/sol-types/tests/doctests/types.rs
use alloy_primitives::Address;
use alloy_sol_types::{sol, SolType};
// Type definition: generates a new struct that implements `SolType`
sol! {
type MyType is uint256;
}
// Type aliases
type B32 = sol! { bytes32 };
// This i... | code_fim | medium | {
"lang": "rust",
"repo": "roynalnaruto/core",
"path": "/crates/sol-types/tests/doctests/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[pymethods]
impl $py_type_name {
#[getter]
/// First hyperdual part.
fn get_first_derivative(&self) -> ([f64; $m], [f64; $n]) {
(*self._data.eps1.raw_array(), *self._data.eps2.raw_array())
}
#[getter]
... | code_fim | hard | {
"lang": "rust",
"repo": "itt-ustutt/dualnum",
"path": "/src/hyperdual.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: itt-ustutt/dualnum path: /src/hyperdual.rs
use crate::dual::PyDual64;
use crate::dual2::{PyDual2Dual64, PyDual2_64};
use num_dual::*;
use pyo3::exceptions::PyTypeError;
use pyo3::number::PyNumberProtocol;
use pyo3::prelude::*;
#[pyclass(name = "HyperDual64")]
#[derive(Clone)]
/// Hyper dual num... | code_fim | hard | {
"lang": "rust",
"repo": "itt-ustutt/dualnum",
"path": "/src/hyperdual.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn blob_put(mut args: Vec<&str>, client: &mut HaretClient) -> Result<String> {
let blob = args.pop().unwrap();
let path = args.pop().unwrap();
client.blob_put(blob, path)
}
fn blob_get(mut args: Vec<&str>, client: &mut HaretClient) -> Result<String> {
let path = args.pop().unwrap();
c... | code_fim | hard | {
"lang": "rust",
"repo": "vmware-archive/haret",
"path": "/haret-cli-client/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vmware-archive/haret path: /haret-cli-client/src/main.rs
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
extern crate haret_client;
extern crate uuid;
#[macro_use]
extern crate lazy_static;
use std::env;
use std::str;
use std::env::Args;
use s... | code_fim | hard | {
"lang": "rust",
"repo": "vmware-archive/haret",
"path": "/haret-cli-client/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn queue_back(mut args: Vec<&str>, client: &mut HaretClient) -> Result<String> {
let path = args.pop().unwrap();
client.queue_back(path)
}
fn queue_len(mut args: Vec<&str>, client: &mut HaretClient) -> Result<String> {
let path = args.pop().unwrap();
client.queue_len(path)
}
fn set_inser... | code_fim | hard | {
"lang": "rust",
"repo": "vmware-archive/haret",
"path": "/haret-cli-client/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/compiler-builtins path: /testcrate/tests/div_rem.rs
#![allow(unused_macros)]
use compiler_builtins::int::sdiv::{__divmoddi4, __divmodsi4, __divmodti4};
use compiler_builtins::int::udiv::{__udivmoddi4, __udivmodsi4, __udivmodti4, u128_divide_sparc};
use testcrate::*;
// Division algor... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/compiler-builtins",
"path": "/testcrate/tests/div_rem.rs",
"mode": "psm",
"license": "NCSA",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ARM SIMD instructions always flush subnormals to zero
#[cfg(target_arch = "arm")]
if !(Float::is_subnormal(quo0) || Float::is_subnormal(quo1)) {
if !Float::eq_repr(quo0, quo1) {
panic!(
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/compiler-builtins",
"path": "/testcrate/tests/div_rem.rs",
"mode": "spm",
"license": "NCSA",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn divide_sparc() {
fuzz_2(N, |lhs, rhs| {
if rhs == 0 {
return;
}
let mut rem: u128 = 0;
let quo: u128 = u128_divide_sparc(lhs, rhs, &mut rem);
if rhs <= rem || (lhs != rhs.wrapping_mul(quo).wrapping_add(rem)) {
panic!(
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/compiler-builtins",
"path": "/testcrate/tests/div_rem.rs",
"mode": "spm",
"license": "NCSA",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(match last_read_half {
Half::First => {
if second_half_is_done {
self.channel.ifcr().write(|w| w.$ctcifX().set_bit());
self.re... | code_fim | hard | {
"lang": "rust",
"repo": "theunkn0wn1/stm32-hal",
"path": "/src/dma.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theunkn0wn1/stm32-hal path: /src/dma.rs
Clear ISR flag (Transfer Complete)
if !self.channel.in_progress() {
self.channel.ifcr().write(|w| w.$ctcifX().set_bit());
} else {
// Th... | code_fim | hard | {
"lang": "rust",
"repo": "theunkn0wn1/stm32-hal",
"path": "/src/dma.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theunkn0wn1/stm32-hal path: /src/dma.rs
ent, Half, Transfer, W};
use crate::pac::RCC;
use paste::paste;
#[allow(clippy::manual_non_exhaustive)]
pub struct Channels((), $(pub $CX),+);
$(
pub str... | code_fim | hard | {
"lang": "rust",
"repo": "theunkn0wn1/stm32-hal",
"path": "/src/dma.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thecodefactory/sapvi path: /src/old/mint.rs
use bellman::gadgets::multipack;
use bellman::groth16;
use blake2s_simd::Params as Blake2sParams;
use bls12_381::Bls12;
use ff::Field;
use group::{Curve, Group, GroupEncoding};
mod mint_contract;
use mint_contract::MintContract;
struct MintRevealedVa... | code_fim | hard | {
"lang": "rust",
"repo": "thecodefactory/sapvi",
"path": "/src/old/mint.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let revealed =
MintRevealedValues::compute(value, &randomness_value, &serial, &randomness_coin, &public);
let start = Instant::now();
let params = {
let c = MintContract {
value: None,
randomness_value: None,
serial: None,
random... | code_fim | hard | {
"lang": "rust",
"repo": "thecodefactory/sapvi",
"path": "/src/old/mint.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let start = Instant::now();
let params = {
let c = MintContract {
value: None,
randomness_value: None,
serial: None,
randomness_coin: None,
public: None,
};
groth16::generate_random_parameters::<Bls12, _, _>(c, &mu... | code_fim | hard | {
"lang": "rust",
"repo": "thecodefactory/sapvi",
"path": "/src/old/mint.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blandger/btleplug path: /src/droidplug/jni/objects.rs
b> JPeripheral<'a, 'b> {
pub fn from_env(env: &'b JNIEnv<'a>, obj: JObject<'a>) -> Result<Self> {
//Self::from_env_impl(env, obj)
//let class = env.find_class("com/nonpolynomial/btleplug/android/impl/Peripheral")?;
... | code_fim | hard | {
"lang": "rust",
"repo": "blandger/btleplug",
"path": "/src/droidplug/jni/objects.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct JBluetoothGattDescriptor<'a: 'b, 'b> {
internal: JObject<'a>,
get_uuid: JMethodID<'a>,
env: &'b JNIEnv<'a>,
}
impl<'a: 'b, 'b> JBluetoothGattDescriptor<'a, 'b> {
pub fn from_env(env: &'b JNIEnv<'a>, obj: JObject<'a>) -> Result<Self> {
let class = env.auto_local(env.find... | code_fim | hard | {
"lang": "rust",
"repo": "blandger/btleplug",
"path": "/src/droidplug/jni/objects.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let get_device =
env.get_method_id(&class, "getDevice", "()Landroid/bluetooth/BluetoothDevice;")?;
let get_scan_record = env.get_method_id(
&class,
"getScanRecord",
"()Landroid/bluetooth/le/ScanRecord;",
)?;
let get_tx_power =... | code_fim | hard | {
"lang": "rust",
"repo": "blandger/btleplug",
"path": "/src/droidplug/jni/objects.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let typ = type_name(name);
let out = &mut self.rs_buf;
// emitting struct
writeln!(out)?;
emit_doc_text(out, doc)?;
if has_lifetime {
writeln!(
out,
"pub type {}<'a> = base::StructPtr<'a, {}>;",
&t... | code_fim | hard | {
"lang": "rust",
"repo": "rtbo/rust-xcb",
"path": "/build/codegen/rs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let out = &mut self.rs_buf;
writeln!(out)?;
emit_doc_text(out, doc)?;
if doc.is_some() {
writeln!(out, "///")?;
writeln!(out, "/// parameters:")?;
writeln!(out, "///")?;
writeln!(out,... | code_fim | hard | {
"lang": "rust",
"repo": "rtbo/rust-xcb",
"path": "/build/codegen/rs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rtbo/rust-xcb path: /build/codegen/rs.rs
} else {
rs_typ.clone()
};
self.emit_rs_switch_typedef(
&rs_typ,
cname,
ccases,
... | code_fim | hard | {
"lang": "rust",
"repo": "rtbo/rust-xcb",
"path": "/build/codegen/rs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>terprise",
"integrate",
"di impatto",
"wireless",
"trasparenti",
"next-generation",
"cutting-edge",
"visionari",
"plug-and-play",
"collaborative",
"olistiche",
"ricche",
];<|fim_prefix|>// repo: PSeitz/f4ker-rs path: /src/locales/it/company/bs_adjective.rs
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/f4ker-rs",
"path": "/src/locales/it/company/bs_adjective.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PSeitz/f4ker-rs path: /src/locales/it/company/bs_adjective.rs
pub static BS_ADJECTIVE: &'static [&'static str] = &[
"valore aggiunto",
"verticalizzate",
"proattive",
"forti",
"rivoluzionari",
"scalabili",
"innovativi",
"intuitivi",
"strategici",
"e-busines... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/f4ker-rs",
"path": "/src/locales/it/company/bs_adjective.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn add_key_from_url(keyring: &mut Keyring, url: &str) -> Result<()> {
let data = match url {
_ if http::matches(url) => http::read(url)?,
_ if keybase::matches(url) => keybase::read(url)?,
_ if local::matches(url) => local::read(url)?,
_ => bail!("No way to read gpg... | code_fim | medium | {
"lang": "rust",
"repo": "lutostag/pincers",
"path": "/src/gpg/pubkeys/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lutostag/pincers path: /src/gpg/pubkeys/mod.rs
use anyhow::Result;
use gpgrv::Keyring;
use std::io::BufRead;
mod http;
mod keybase;
mod local;
fn add_key(keyring: &mut Keyring, mut from: Box<dyn BufRead>) -> Result<()> {
<|fim_suffix|>#[test]
fn it_works() {
let mut keyring = Keyring::new(... | code_fim | hard | {
"lang": "rust",
"repo": "lutostag/pincers",
"path": "/src/gpg/pubkeys/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn it_works() {
let mut keyring = Keyring::new();
add_key_from_url(&mut keyring, "keybase:lutostag").unwrap();
assert_eq!(2 + 2, 4);
}<|fim_prefix|>// repo: lutostag/pincers path: /src/gpg/pubkeys/mod.rs
use anyhow::Result;
use gpgrv::Keyring;
use std::io::BufRead;
mod http;
mod keyb... | code_fim | hard | {
"lang": "rust",
"repo": "lutostag/pincers",
"path": "/src/gpg/pubkeys/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BrokenLamp/Kepler path: /src/components/rotation.rs
use quaternion::Quaternion;
use specs::prelude::*;
<|fim_suffix|>impl Component for Rotation {
type Storage = VecStorage<Self>;
}<|fim_middle|>pub struct Rotation(Quaternion<f32>);
| code_fim | easy | {
"lang": "rust",
"repo": "BrokenLamp/Kepler",
"path": "/src/components/rotation.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Component for Rotation {
type Storage = VecStorage<Self>;
}<|fim_prefix|>// repo: BrokenLamp/Kepler path: /src/components/rotation.rs
use quaternion::Quaternion;
use specs::prelude::*;
<|fim_middle|>pub struct Rotation(Quaternion<f32>);
| code_fim | easy | {
"lang": "rust",
"repo": "BrokenLamp/Kepler",
"path": "/src/components/rotation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cache = Cache::new(ErrorTolerance::Strict);
assert_matches!(cache.load_stdlib(), Ok(_));
assert_matches!(cache.typecheck_stdlib(), Ok(_));
}<|fim_prefix|>// repo: tweag/nickel path: /core/tests/integration/stdlib_typecheck.rs
use assert_matches::assert_matches;
use nickel_lang_core::c... | code_fim | easy | {
"lang": "rust",
"repo": "tweag/nickel",
"path": "/core/tests/integration/stdlib_typecheck.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tweag/nickel path: /core/tests/integration/stdlib_typecheck.rs
use assert_matches::assert_matches;
use nickel_lang_core::cache::{Cache, ErrorTolerance};
<|fim_suffix|> let mut cache = Cache::new(ErrorTolerance::Strict);
assert_matches!(cache.load_stdlib(), Ok(_));
assert_matches!(cac... | code_fim | easy | {
"lang": "rust",
"repo": "tweag/nickel",
"path": "/core/tests/integration/stdlib_typecheck.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cfoust/byt path: /src/byt/mutators/vym/mod.rs
//! byt - vym
//!
//! Implement a mutator that mimic's vim's key layout.
//!
//! We obviously don't want to implement everything from vim here. The whole point of writing our
//! own editor is to formulate our own paradigms. For me (cfoust) vim's mov... | code_fim | hard | {
"lang": "rust",
"repo": "cfoust/byt",
"path": "/src/byt/mutators/vym/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>enum Mode {
Normal,
Insert
}
struct VymState {
mode : Mode
}
impl VymState {
pub fn new() -> VymState {
VymState {
mode : Mode::Normal
}
}
/// Change to insert mode.
pub fn insert_mode(&mut self) {
self.mode = Mode::Insert;
}
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "cfoust/byt",
"path": "/src/byt/mutators/vym/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbillingr/lisp-in-small-pieces path: /crates/common/src/lib.rs
use lisp_core::simple::Value as lcValue;
use lisp_core::{
common::{BasicLispValue, CombinedLispOps, LispError},
lexpr,
};
use rustyline::{error::ReadlineError, Editor};
use std::fmt::Display;
use std::str::FromStr;
pub fn re... | code_fim | hard | {
"lang": "rust",
"repo": "mbillingr/lisp-in-small-pieces",
"path": "/crates/common/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Error::CoreError(le)
}
}
impl From<ReadlineError> for Error {
fn from(rle: ReadlineError) -> Error {
match rle {
ReadlineError::Eof => Error::EndOfFile,
_ => Error::ReadLineError(rle),
}
}
}
impl From<lexpr::parse::error::Error> for Error {
... | code_fim | hard | {
"lang": "rust",
"repo": "mbillingr/lisp-in-small-pieces",
"path": "/crates/common/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xrf/lutario path: /src/linalg.rs
t constants following the
//! LAPACK convention. Basically, this module contains anything you would
//! otherwise obtain using `lamch`.
pub mod f32 {
pub use std::f32::EPSILON as PREC;
pub use std::f32::MANTISSA_DIGITS as T;
... | code_fim | hard | {
"lang": "rust",
"repo": "xrf/lutario",
"path": "/src/linalg.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl NormSqr for f64 {
type Real = Self;
fn norm_sqr(&self) -> Self::Real {
f64::abs(*self)
}
}
impl<T: Num + PartialOrd + Default + Clone> NormSqr for Complex<T> {
type Real = T;
fn norm_sqr(&self) -> Self::Real {
Complex::norm_sqr(self)
}
}
#[derive(Clone, Cop... | code_fim | hard | {
"lang": "rust",
"repo": "xrf/lutario",
"path": "/src/linalg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.