text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> rule function() -> NodeElement
= ("ABS(" / "abs(") _ e:expression() _ ")" { node("abs", vec![e]) }
/ ("RND(" / "rnd(") _ e:expression() _ ")" { node("rnd", vec![e]) }
/ ("SIN(" / "sin(") _ e:expression() _ ")" { node("sin", vec![e]) }
/ ("COS(" / "co... | code_fim | hard | {
"lang": "rust",
"repo": "fazibear/fazic",
"path": "/fazic_mono/src/fazic/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jessfraz/hubcaps path: /examples/hooks.rs
use hubcaps::hooks::{HookCreateOptions, WebHookContentType};
use hubcaps::{Credentials, Github};
use std::env;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
pretty_env_lo<|fim_suffix|>= github.repo("softprops"... | code_fim | hard | {
"lang": "rust",
"repo": "jessfraz/hubcaps",
"path": "/examples/hooks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ntentType::Json)
.build(),
)
.await;
println!("{:#?}", hook);
let hooks = repo.hooks();
for hook in hooks.list().await? {
println!("{:#?}", hook)
}
Ok(())
}<|fim_prefix|>// repo: jessfraz/hubcaps path: /examples/hooks.rs
use hubcaps::hooks::{Hoo... | code_fim | hard | {
"lang": "rust",
"repo": "jessfraz/hubcaps",
"path": "/examples/hooks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut case1 = Solution::generate_parenthesis(3);
case1.sort();
assert_eq!(
case1,
vec!["((()))", "(()())", "(())()", "()(())", "()()()"]
);
assert_eq!(Solution::generate_parenthesis(1), vec!["()"]);
}
}<|fim_prefix|>// repo: liaowang11/... | code_fim | hard | {
"lang": "rust",
"repo": "liaowang11/effective-leetcode",
"path": "/rust/solutions/src/p22_generate_parentheses.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liaowang11/effective-leetcode path: /rust/solutions/src/p22_generate_parentheses.rs
use std::collections::HashMap;
struct Solution {}
impl Solution {
pub fn generate_parenthesis(n: i32) -> Vec<String> {
let mut cache = HashMap::with_capacity(8);
Self::generate(n, &mut cache... | code_fim | hard | {
"lang": "rust",
"repo": "liaowang11/effective-leetcode",
"path": "/rust/solutions/src/p22_generate_parentheses.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: garro95/dsp path: /examples/spectrum/src/main.rs
extern crate gnuplot;
extern crate num_complex;
extern crate dsp;
use gnuplot::{Figure, Color, Caption};
use dsp::generators::{chirp};
use dsp::fft::{ForwardFFT};
const SAMPLE_RATE: usize = 44100;
const SAMPLE_SIZE: usize = 2048;
<|fim_suffix... | code_fim | medium | {
"lang": "rust",
"repo": "garro95/dsp",
"path": "/examples/spectrum/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let points = (0..SAMPLE_RATE).map(|x| (x as f64)/(SAMPLE_RATE as f64)).collect();
let signal = chirp(110.0, 880.0, 1.0).generate(points);
let mut ft = ForwardFFT::new(SAMPLE_SIZE);
// Calculate FFT every 1/10th of the second
let ps: Vec<f64> = (0..100).map(|i| {
let start_pos ... | code_fim | medium | {
"lang": "rust",
"repo": "garro95/dsp",
"path": "/examples/spectrum/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let points = (0..SAMPLE_RATE).map(|x| (x as f64)/(SAMPLE_RATE as f64)).collect();
let signal = chirp(110.0, 880.0, 1.0).generate(points);
let mut ft = ForwardFFT::new(SAMPLE_SIZE);
// Calculate FFT every 1/10th of the second
let ps: Vec<f64> = (0..100).map(|i| {
le... | code_fim | medium | {
"lang": "rust",
"repo": "garro95/dsp",
"path": "/examples/spectrum/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c = (self.f)(self.client.get(), x);
self.client.update(|old| *old = c);
}
pub fn get(&self) -> C {
self.client.get()
}
}
impl<C: Clone, D, F: Fn(C, D) -> C> HasConfig<C> for ComposeConfig<C, D, F> {
fn get(&self) -> &C {
&self.config.config
}
}
pu... | code_fim | hard | {
"lang": "rust",
"repo": "rosofo/rsynth",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rosofo/rsynth path: /src/config.rs
use std::{
convert::TryInto,
marker::PhantomData,
sync::mpsc::{self, Sender},
};
pub struct Config<C> {
receiver: mpsc::Receiver<C>,
client: Option<ConfigClient<C>>,
pub config: C,
}
pub struct ConfigClient<C> {
sender: Sender<C>,
... | code_fim | hard | {
"lang": "rust",
"repo": "rosofo/rsynth",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* void addChild (in nsIDocShellTreeItem child); */
Method {
name: "addChild",
abi: "C",
params: &[Param { name: "child", ty: "*const nsIDocShellTreeItem" }],
ret: "nsres... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/bt/nsIDocShellTreeItem.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /bt/nsIDocShellTreeItem.rs
//
// DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIDocShellTreeItem.idl
//
{static D: &'static [Interface] = &[
Interface {
name: "nsIDocShellTreeItem",
base: Some("nsISupports"),
... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/bt/nsIDocShellTreeItem.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(clippy::many_single_char_names)]
pub fn dijkstra(g: &[Vec<Edge>], s: usize) -> Vec<Option<u64>> {
use std::cmp::Reverse;
use std::collections::BinaryHeap;
let n = g.len();
let mut dist = vec![None; n];
let mut q = BinaryHeap::new();
dist[s] = Some(0);
q.push((Reverse(0)... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/ABC204/e/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy, Clone, Debug)]
pub struct Edge {
to: usize,
c: u64,
d: u64,
}
#[allow(clippy::many_single_char_names)]
pub fn dijkstra(g: &[Vec<Edge>], s: usize) -> Vec<Option<u64>> {
use std::cmp::Reverse;
use std::collections::BinaryHeap;
let n = g.len();
let mut dist = vec![... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/ABC204/e/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/ABC204/e/src/main.rs
use floor_sqrt::floor_sqrt;
use procon_reader::ProconReader;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let n: usize = rd.get();
let m: usize = rd.get();
let mut g... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/ABC204/e/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// A trait to listen to cucumber execution events
/// that can be safely shared between multiple threads.
pub trait SyncEventListener: EventListener + Sync {}
impl<T: EventListener + Sync> SyncEventListener for T {}
#[cfg(test)]
mod tests {
use super::*;
fn assert_sync<T: Sync>() {}
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "mmitteregger/cuke-runner",
"path": "/core/lib/src/api/event.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmitteregger/cuke-runner path: /core/lib/src/api/event.rs
use std::fmt::Debug;
use std::time::SystemTime;
use gherkin::ast::{Feature, Background, Scenario};
use gherkin::cuke::Cuke;
use crate::api::{TestCase, TestStep, TestResult};
/// An execution event that is generated by cucumber.
#[deriv... | code_fim | hard | {
"lang": "rust",
"repo": "mmitteregger/cuke-runner",
"path": "/core/lib/src/api/event.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Tile {
pub fn new<P: PaletteRam>(
vram: &Ram,
cram: &Ram,
palette: &P,
pos: &SpritePosition,
config: &SpriteConfig,
mapper: &dyn Mapper
) -> Self {
let block_id = get_block_id(pos);
let tile_id = get_tile_id(&vram, pos, config);
let attr = get_attribute(&vram, ... | code_fim | medium | {
"lang": "rust",
"repo": "196Ikuchil/nes_emulator",
"path": "/src/nes/ppu/tile.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 196Ikuchil/nes_emulator path: /src/nes/ppu/tile.rs
use self::super::palette::*;
use self::super::sprite_utils::*;
use self::super::Ram;
use self::super::Mapper;
<|fim_suffix|>impl Tile {
pub fn new<P: PaletteRam>(
vram: &Ram,
cram: &Ram,
palette: &P,
pos: &SpritePosition,
... | code_fim | medium | {
"lang": "rust",
"repo": "196Ikuchil/nes_emulator",
"path": "/src/nes/ppu/tile.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: go717franciswang/exercism path: /rust/react/src/lib.rs
#[allow(unused_variables)]
// Because these are passed without & to some functions,
// it will probably be necessary for these two types to be Copy.
pub type CellID = (usize, usize);
pub type CallbackID = (usize, usize, usize);
enum Cell<'... | code_fim | hard | {
"lang": "rust",
"repo": "go717franciswang/exercism",
"path": "/rust/react/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Removes the specified callback, using an ID returned from add_callback.
//
// Return an Err (and you can change the error type) if either the cell or callback
// does not exist.
//
// A removed callback should no longer be called.
pub fn remove_callback(&mut self, cell: Cell... | code_fim | hard | {
"lang": "rust",
"repo": "go717franciswang/exercism",
"path": "/rust/react/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(valid_braces("()"), true);
assert_eq!(valid_braces("[(])"), false);
}<|fim_prefix|>// repo: light4/codewars path: /valid_braces/src/lib.rs
fn valid_braces(s: &str) -> bool {
let data = vec!["{}", "()", "[]"];
if !data.iter().any(|&x| s.contains(x)) {
return false;
}
let mut bra... | code_fim | easy | {
"lang": "rust",
"repo": "light4/codewars",
"path": "/valid_braces/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: light4/codewars path: /valid_braces/src/lib.rs
fn valid_braces(s: &str) -> bool {
let data = vec!["{}", "()", "[]"];
if !data.iter().any(|&x| s.contains(x)) {
return false;
}
let mut braces = "";
for b in data {
if s.contains(b) {
braces = b;
break;
}
}
if s... | code_fim | easy | {
"lang": "rust",
"repo": "light4/codewars",
"path": "/valid_braces/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Deserialization codes
pub const DESERIALIZE_CONTEXT: OpCode = Self::new_op_code(100);
pub const DESERIALIZE_REGISTER: OpCode = Self::new_op_code(101); // Block codes
pub const VAL_DEF: OpCode = Self::new_op_code(102);
pub const FUN_DEF: OpCode = Self::new_op_code(103);
pub const... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergotree-ir/src/serialization/op_code.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ergoplatform/sigma-rust path: /ergotree-ir/src/serialization/op_code.rs
#![allow(dead_code)]
#![allow(missing_docs)]
use crate::serialization::{
sigma_byte_reader::SigmaByteRead, SigmaParsingError, SigmaSerializable, SigmaSerializeResult,
};
use super::sigma_byte_writer::SigmaByteWrite;
#... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergotree-ir/src/serialization/op_code.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TianyiShi2001/nom-pdb path: /scripts/modres/modres.rs
Self::Th5 => Some(AminoAcid::Thr),
Self::Lp6 => Some(AminoAcid::Lys),
Self::Psw => Some(AminoAcid::Sec),
Self::Ynm => Some(AminoAcid::Tyr),
Self::Na8 => Some(AminoAcid::Ala),
Se... | code_fim | hard | {
"lang": "rust",
"repo": "TianyiShi2001/nom-pdb",
"path": "/scripts/modres/modres.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "API" => Ok(Self::Api),
"FTY" => Ok(Self::Fty),
"OAR" => Ok(Self::Oar),
"THR" => Ok(Self::Thr),
"DBB" => Ok(Self::Dbb),
"TRN" => Ok(Self::Trn),
"FGL" => Ok(Self::Fgl),
"BHD" => Ok(Self::Bhd),
"ALN" =>... | code_fim | hard | {
"lang": "rust",
"repo": "TianyiShi2001/nom-pdb",
"path": "/scripts/modres/modres.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "BAL" => Ok(Self::Bal),
"TRW" => Ok(Self::Trw),
"FGP" => Ok(Self::Fgp),
"DMK" => Ok(Self::Dmk),
"DMH" => Ok(Self::Dmh),
"AHB" => Ok(Self::Ahb),
"HTI" => Ok(Self::Hti),
"SMF" => Ok(Self::Smf),
"B2V" => Ok(Self:... | code_fim | hard | {
"lang": "rust",
"repo": "TianyiShi2001/nom-pdb",
"path": "/scripts/modres/modres.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = 1;
let a = embedded::migrations::runner();
a.run(&mut self.conn);
//let b = a.run(& mut self.conn);
// embedded::migrations::runner()
// .run(&mut self.conn)
// .unwrap();
Ok(r)
}
}
impl Handler<CreateUser> for ... | code_fim | hard | {
"lang": "rust",
"repo": "xunilrj/sandbox",
"path": "/sources/rust/actix/src/db/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // embedded::migrations::runner()
// .run(&mut self.conn)
// .unwrap();
Ok(r)
}
}
impl Handler<CreateUser> for DbActor
{
type Result = Result<String, String>;
fn handle(&mut self, msg: CreateUser, _: &mut Self::Context) -> Self::Result
{
le... | code_fim | hard | {
"lang": "rust",
"repo": "xunilrj/sandbox",
"path": "/sources/rust/actix/src/db/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xunilrj/sandbox path: /sources/rust/actix/src/db/mod.rs
use actix::prelude::*;
use actix::{Actor, Message, Handler};
use diesel::prelude::*;
use diesel::pg::PgConnection;
use diesel::result::Error::DatabaseError;
use url::{Url};
use log::{trace};
pub mod embedded
{
//use refinery::embed_mig... | code_fim | hard | {
"lang": "rust",
"repo": "xunilrj/sandbox",
"path": "/sources/rust/actix/src/db/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danshiovitz/adventofcode path: /2022/day23/src/main.rs
use std::collections::{HashMap, HashSet};
extern crate common;
use common::framework::{parse_grid, run_day, BaseDay, InputReader};
use common::grid::{add_direction, eight_neighbors, print_grid, Coord, Direction, Grid};
struct Day23 {
... | code_fim | hard | {
"lang": "rust",
"repo": "danshiovitz/adventofcode",
"path": "/2022/day23/src/main.rs",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn pt1(&mut self) -> String {
let (elves, _) = walk_grid(&self.grid, 10, &get_check_dirs());
return compute_score(&elves).to_string();
}
fn pt2(&mut self) -> String {
let (_, rounds) = walk_grid(&self.grid, i32::MAX, &get_check_dirs());
return rounds.to_string(... | code_fim | hard | {
"lang": "rust",
"repo": "danshiovitz/adventofcode",
"path": "/2022/day23/src/main.rs",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut nums2 = vec![5, 4, 3, 2, 1];
println!("Before sort: {:?}", nums2);
select_sort(&mut nums2);
println!("After sort: {:?}\n", nums2);
assert_eq!(nums2, vec![1, 2, 3, 4, 5]);
let mut nums3 = vec![1,2,3,4,5,6];
println!("Before sort: {:?}", nums3... | code_fim | hard | {
"lang": "rust",
"repo": "Itanq/examples",
"path": "/sort/src/select_sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Itanq/examples path: /sort/src/select_sort.rs
// 每一轮找到一个无序列表中的最小位置,每此交换最小位置
fn select_sort<T: Ord>(arr: &mut [T]) {
for i in 0..arr.len() {
let mut idx = i;
for j in i..arr.len() {
if arr[j] < arr[idx] {
idx = j;
}
}
ar... | code_fim | hard | {
"lang": "rust",
"repo": "Itanq/examples",
"path": "/sort/src/select_sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut nums = vec![9, 3, 67, 4, 1, 89, -234, 5, -345, 56, 123, 8, 1, 9, 55];
println!("Before sort: {:?}", nums);
select_sort(&mut nums);
println!("After sort: {:?}\n", nums);
assert_eq!(nums, vec![-345, -234, 1, 1, 3, 4, 5, 8, 9, 9, 55, 56, 67, 89, 123]);
... | code_fim | medium | {
"lang": "rust",
"repo": "Itanq/examples",
"path": "/sort/src/select_sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/sesv2/src/error.rs
.fmt(f)
}
CreateConfigurationSetErrorKind::LimitExceededException(_inner) => _inner.fmt(f),
CreateConfigurationSetErrorKind::NotFoundException(_inner) => _inner.fmt(f),
CreateConfigurationSetErrorKi... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/sesv2/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imlyzh/sexpr_ir path: /src/gast/list.rs
use std::fmt::Display;
use serde::{Serialize, Deserialize};
use super::GAst;
#[derive(Debug, Clone, PartialEq)]
#[derive(Serialize, Deserialize)]
pub struct List(pub Vec<GAst>, pub Option<GAst>);
<|fim_suffix|> let list = self.0.iter();
... | code_fim | medium | {
"lang": "rust",
"repo": "imlyzh/sexpr_ir",
"path": "/src/gast/list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Display for List {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let list = self.0.iter();
let str_list: Vec<String> = list.map(GAst::to_string).collect();
let str_pair_right = if let Some(x) = self.1.clone() {
format!(" . {}", x)
... | code_fim | medium | {
"lang": "rust",
"repo": "imlyzh/sexpr_ir",
"path": "/src/gast/list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let trainees = vec![
Trainee::new("Bohdan Porokhnavets", 0, 1),
Trainee::new("Artem Dmytriv", 1, 2),
Trainee::new("Liubomyr Kotias", 2, 3),
Trainee::new("Kateryna Dubska", 3, 4),
Trainee::new("Petro Bratash", 0, 4),
];
let handles: Vec<_> = trainees.int... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewHubchak/rust-learning",
"path": "/dining_philosophers/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> thread::spawn(move || {
p.eat(&table);
})
}).collect();
for h in handles {
h.join().unwrap();
}
}
//
// fn new(name: String) -> Trainee {
//
// if we had name: String that we would have to do like this
// which looks worth
//
// in our case extra copy ... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewHubchak/rust-learning",
"path": "/dining_philosophers/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndrewHubchak/rust-learning path: /dining_philosophers/src/main.rs
use std::time;
use std::thread;
use std::sync::{Mutex, Arc};
struct Table {
forks: Vec<Mutex<()>>,
}
struct Trainee {
name: String,
left: usize,
right: usize,
}
impl Trainee {
fn new(name: &str, left: usize... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewHubchak/rust-learning",
"path": "/dining_philosophers/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tomcumming/pga2d path: /src/direction/unit.rs
use std::convert::TryFrom;
use super::Direction;
use crate::point::Point;
/// Unit direction with an ideal norm of 1
#[derive(Debug, Copy, Clone)]
pub struct UnitDirection(Direction);
impl From<UnitDirection> for Point {
fn from(UnitDirection(... | code_fim | medium | {
"lang": "rust",
"repo": "tomcumming/pga2d",
"path": "/src/direction/unit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = Point::from(d).ideal_norm();
let ud = d * (1f32 / n);
if Point::from(ud).is_finite() {
Ok(UnitDirection(ud))
} else {
Err(())
}
}
}<|fim_prefix|>// repo: tomcumming/pga2d path: /src/direction/unit.rs
use std::convert::TryFrom;
u... | code_fim | medium | {
"lang": "rust",
"repo": "tomcumming/pga2d",
"path": "/src/direction/unit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..5 {
cards_raw_player.push(scan.token::<String>());
}
let mut cards_player = Vec::new();
for i in 0..5 {
cards_player.push(convert_card(&cards_raw_player[i]));
}
cards_player.sort();
let hand_player = Hand::new(
[
cards_player[... | code_fim | hard | {
"lang": "rust",
"repo": "utilForever/BOJ",
"path": "/Rust/3525 - Hands of Poker.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: utilForever/BOJ path: /Rust/3525 - Hands of Poker.rs
HighCard(Hand),
OnePair(Rank, Rank, Rank, Rank),
TwoPair(Rank, Rank, Rank),
ThreeOfAKind(Rank, Rank, Rank),
Straight(Rank),
Flush(Hand),
FullHouse(Rank, Rank),
FourOfAKind(Rank, Rank),
StraightFlush(Rank),
... | code_fim | hard | {
"lang": "rust",
"repo": "utilForever/BOJ",
"path": "/Rust/3525 - Hands of Poker.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let hand_player = Hand::new(
[
cards_player[0].clone(),
cards_player[1].clone(),
cards_player[2].clone(),
cards_player[3].clone(),
cards_player[4].clone(),
]
.to_vec(),
);
let category = hand_player.get_catego... | code_fim | hard | {
"lang": "rust",
"repo": "utilForever/BOJ",
"path": "/Rust/3525 - Hands of Poker.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data.data.update(&data.world, true); // true to say we should dispatch running
Trans::None
}
}
*/
fn main() -> amethyst::Result<()> {
amethyst::start_logger(Default::default());
// this will be the directory the 'Cargo.toml' is defined in.
let app_root = application_root_d... | code_fim | hard | {
"lang": "rust",
"repo": "Lightnet/rame",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let binding_path = app_root.join("config").join("bindings.ron");
//#[allow(unused_variables)]
// user input
let input_bundle = InputBundle::<StringBindings>::new()
.with_bindings_from_file(binding_path)?;
// other assets ('*.ron' files, '*.png' textures, '*.ogg' audio files, ui pre... | code_fim | hard | {
"lang": "rust",
"repo": "Lightnet/rame",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lightnet/rame path: /src/main.rs
/*
Proejct Name: Rame
Rust
Amethyst
Module
Engine
Created by: Lightnet
License: MIT
Information:
Work in progress prototype build.
working on the module setup.
*/
//#[allow(unused_imports)]
// #[allow(c... | code_fim | hard | {
"lang": "rust",
"repo": "Lightnet/rame",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Api {
pub(crate) fn typename(&self) -> TypeName {
TypeName::new(&self.ns, &self.id.to_string())
}
pub(crate) fn typename_for_allowlist(&self) -> TypeName {
let id_for_allowlist = match &self.id_for_allowlist {
None => match &self.use_stmt {
Use... | code_fim | hard | {
"lang": "rust",
"repo": "npajkovsky/autocxx",
"path": "/engine/src/conversion/api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: npajkovsky/autocxx path: /engine/src/conversion/api.rs
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org... | code_fim | hard | {
"lang": "rust",
"repo": "npajkovsky/autocxx",
"path": "/engine/src/conversion/api.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niveau0/ci-dashboard path: /src/lib.rs
extern crate cfg_if;
extern crate wasm_bindgen;
use cfg_if::cfg_if;
use futures::future;
use futures::TryFutureExt;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use std::sync::Mutex;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use w... | code_fim | hard | {
"lang": "rust",
"repo": "niveau0/ci-dashboard",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let gitlab = Arc::new(gitlab::GitLab::new(config));
let future = gitlab.request_projects().and_then(move |projects| {
let guard = state.lock();
match guard {
Ok(mut state) => state.set_projects(projects.clone()),
Err(err) => console::log_1(&JsValue::from(for... | code_fim | hard | {
"lang": "rust",
"repo": "niveau0/ci-dashboard",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for project in projects {
let gitlab = gitlab.clone();
let document = document.clone();
let future = gitlab
.request_pipelines(project.id)
.and_then(move |pipelines| {
if pipelines.len() > 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "niveau0/ci-dashboard",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ngtkana/aribook path: /crates/chap3_2/jessicas_reading_problem/src/main.rs
// ordtools {{{
#[allow(dead_code)]
mod ordtools {
pub trait Ordtools: PartialOrd + Sized {
fn change_min(&mut self, mut rhs: Self) {
if self > &mut rhs {
*self = rhs;
}... | code_fim | hard | {
"lang": "rust",
"repo": "ngtkana/aribook",
"path": "/crates/chap3_2/jessicas_reading_problem/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn is_nonneg(&self) -> bool {*self >= 0}
fn to_bytes(&self) -> Vec<u8> {
let mut res: Vec<u8> = Vec::with_capacity(4);
let mut x = *self;
for _ in 0..4 {
res.push((x & 255) as u8);
x >>= 8;
}
res
}
fn to_big_scalar(x: &[i32]) ... | code_fim | hard | {
"lang": "rust",
"repo": "vuonghy2442/zknet",
"path": "/src/scalar.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vuonghy2442/zknet path: /src/scalar.rs
use curve25519_dalek::scalar::Scalar as BigScalar;
use std::fmt::Debug;
pub fn to_scalar(val: i32) -> BigScalar {
if val < 0 {
-BigScalar::from((-val) as u32)
} else {
BigScalar::from(val as u32)
}
}
pub fn slice_to_scalar(dat... | code_fim | hard | {
"lang": "rust",
"repo": "vuonghy2442/zknet",
"path": "/src/scalar.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chyyuu/zCore path: /kernel-hal/src/dummy.rs
use super::*;
use crate::vdso::VdsoConstants;
use acpi::Acpi;
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::future::Future;
use core::ops::FnOnce;
use core::pin::Pin;
use core::time::Duration;
type ThreadId = usize;
/// The error type which i... | code_fim | hard | {
"lang": "rust",
"repo": "chyyuu/zCore",
"path": "/kernel-hal/src/dummy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn map_many(
&mut self,
mut vaddr: VirtAddr,
paddrs: &[PhysAddr],
flags: MMUFlags,
) -> Result<()> {
for &paddr in paddrs {
self.map(vaddr, paddr, flags)?;
vaddr += PAGE_SIZE;
}
Ok(())
}
fn map_cont(
... | code_fim | hard | {
"lang": "rust",
"repo": "chyyuu/zCore",
"path": "/kernel-hal/src/dummy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PhysFrame {
#[linkage = "weak"]
#[export_name = "hal_frame_alloc"]
pub fn alloc() -> Option<Self> {
unimplemented!()
}
#[linkage = "weak"]
#[export_name = "hal_frame_alloc_contiguous"]
pub fn alloc_contiguous_base(_size: usize, _align_log2: usize) -> Option<PhysAd... | code_fim | hard | {
"lang": "rust",
"repo": "chyyuu/zCore",
"path": "/kernel-hal/src/dummy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: torkeldanielsson/rust-cef path: /cef/src/lib.rs
extern crate cef_sys;
mod app;
mod browser;
mod browser_host;
mod client;
mod frame;
mod platform;
mod ptr;
mod settings;
mod thread;
mod types;
mod window;
use crate::types::string::CefString;
pub use app::*;
pub use browser::*;
pub use browser_... | code_fim | hard | {
"lang": "rust",
"repo": "torkeldanielsson/rust-cef",
"path": "/cef/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn initialize<TApp: App>(
settings: Settings,
application: &Arc<TApp>,
// application: *mut cef_sys::cef_app_t,
// windows_sandbox_info: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int {
let args = platform::default_args();
unsafe {
cef_sys::cef_initialize... | code_fim | hard | {
"lang": "rust",
"repo": "torkeldanielsson/rust-cef",
"path": "/cef/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theduke/lunatic path: /uptown_funk/uptown_funk_macro/src/wasmtime_method.rs
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use syn::{ImplItemMethod, LitStr};
use crate::signature::transform;
pub fn wrap(namespace: &LitStr, method: &ImplItemMethod) ... | code_fim | hard | {
"lang": "rust",
"repo": "theduke/lunatic",
"path": "/uptown_funk/uptown_funk_macro/src/wasmtime_method.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = quote! {
let state_wrapper = state.clone();
let closure = move |#guest_signature_input| -> Result<#guest_signature_return, wasmtime::Trap> {
let memory = state_wrapper.memory();
#from_guest_input_transformations
let result = {
... | code_fim | hard | {
"lang": "rust",
"repo": "theduke/lunatic",
"path": "/uptown_funk/uptown_funk_macro/src/wasmtime_method.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (
guest_signature_input,
guest_signature_return,
from_guest_input_transformations,
host_call_signature,
from_host_return_transformations,
) = match transform(&signature) {
Ok(result) => result,
Err(error) => return Err(error),
};
... | code_fim | hard | {
"lang": "rust",
"repo": "theduke/lunatic",
"path": "/uptown_funk/uptown_funk_macro/src/wasmtime_method.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32h7/src/stm32h747cm7/ethernet_dma/dmadsr.rs
#[doc = "Reader of register DMADSR"]
pub type R = crate::R<u32, super::DMADSR>;
#[doc = "Writer for register DMADSR"]
pub type W = crate::W<u32, super::DMADSR>;
#[doc = "Register DMADSR `reset()`'s with value... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32h7/src/stm32h747cm7/ethernet_dma/dmadsr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> RPS0_R {
RPS0_R::new(((self.bits >> 8) & 0x0f) as u8)
}
#[doc = "Bit 0 - AHB Master Write Channel"]
#[inline(always)]
pub fn axwhsts(&self) -> AXWHSTS_R {
AXWHSTS_R::new((self.bits & 0x01) != 0)
}
}
impl W {
#[doc = "Bits 12:15 - DMA Channel Transmit Process State"... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32h7/src/stm32h747cm7/ethernet_dma/dmadsr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PistonDevelopers/freetype-sys path: /src/tt_tables.rs
ALAYALAM: FT_UShort = 72;
pub const TT_MAC_LANGID_KANNADA: FT_UShort = 73;
pub const TT_MAC_LANGID_TAMIL: FT_UShort = 74;
pub const TT_MAC_LANGID_TELUGU: FT_UShort = 75;
pub const TT_MAC_LANGID_SINHALESE: FT_UShort = 76;
pub const TT_MAC_LANG... | code_fim | hard | {
"lang": "rust",
"repo": "PistonDevelopers/freetype-sys",
"path": "/src/tt_tables.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const TT_MS_LANGID_ARABIC_SAUDI_ARABIA: FT_UShort = 0x0401;
pub const TT_MS_LANGID_ARABIC_IRAQ: FT_UShort = 0x0801;
pub const TT_MS_LANGID_ARABIC_EGYPT: FT_UShort = 0x0C01;
pub const TT_MS_LANGID_ARABIC_LIBYA: FT_UShort = 0x1001;
pub const TT_MS_LANGID_ARABIC_ALGERIA: FT_UShort = 0x1401;
pub const TT_... | code_fim | hard | {
"lang": "rust",
"repo": "PistonDevelopers/freetype-sys",
"path": "/src/tt_tables.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = "./tests/fixtures/parser/ftl/junk/04-multiline.ftl";
let source = read_file(path).expect("Failed to read");
match parse(&source) {
Ok(_) => panic!("Expected junk in the file"),
Err((res, errors)) => {
assert_eq!(1, errors.len());
assert_eq!(3,... | code_fim | hard | {
"lang": "rust",
"repo": "nvzqz/fluent-rs",
"path": "/tests/syntax/junk.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nvzqz/fluent-rs path: /tests/syntax/junk.rs
extern crate fluent;
use std::io::prelude::*;
use std::fs::File;
use std::io;
use self::fluent::syntax::parse;
fn read_file(path: &str) -> Result<String, io::Error> {
let mut f = try!(File::open(path));
let mut s = String::new();
try!(f.... | code_fim | hard | {
"lang": "rust",
"repo": "nvzqz/fluent-rs",
"path": "/tests/syntax/junk.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn multiline_junk() {
let path = "./tests/fixtures/parser/ftl/junk/04-multiline.ftl";
let source = read_file(path).expect("Failed to read");
match parse(&source) {
Ok(_) => panic!("Expected junk in the file"),
Err((res, errors)) => {
assert_eq!(1, errors.len... | code_fim | hard | {
"lang": "rust",
"repo": "nvzqz/fluent-rs",
"path": "/tests/syntax/junk.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Hide cursor display | demonstration.
fn hide_cursor() {
let cursor = cursor();
cursor.hide();
}
/// Show cursor display | demonstration.
fn show_cursor() {
let cursor = cursor();
cursor.show();
}
/// Show cursor display, only works on certain terminals.| demonstration
fn blink_cursor... | code_fim | hard | {
"lang": "rust",
"repo": "andersk/crossterm",
"path": "/crossterm_cursor/examples/cc_cursor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andersk/crossterm path: /crossterm_cursor/examples/cc_cursor.rs
//!
//! Examples of actions that could be performed with the cursor.
//!
#![allow(unused_must_use, dead_code)]
use std::io::Write;
use std::time::Instant;
use crossterm_cursor::{cursor, queue, Goto, Hide, Output, QueueableCommand}... | code_fim | hard | {
"lang": "rust",
"repo": "andersk/crossterm",
"path": "/crossterm_cursor/examples/cc_cursor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cursor = cursor();
cursor.blink(false);
cursor.blink(false);
}
fn benchmark_cursor_goto() -> f32 {
let mut stdout = ::std::io::stdout();
let instant1 = Instant::now();
for _ in 0..10 {
for x in 0..200 {
for y in 0..50 {
queue!(stdout, Goto(... | code_fim | hard | {
"lang": "rust",
"repo": "andersk/crossterm",
"path": "/crossterm_cursor/examples/cc_cursor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![ ( simd_bounds.extract_hull( num_children ), index as i32 ) ]
} else { // Discard the node (So it has `t` children, where `t < cutsize`)
// Find optimal `i`. Being the number of children the left-child has. The right child has `t-i` children.
let i_min = find_i( bvh, memo, node_... | code_fim | hard | {
"lang": "rust",
"repo": "sourcedennis/wasm-pathtracer",
"path": "/src/graphics/bvh4.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Returns `Some(..)` if the bounds for `node_i` contain the bounds of its children;
/// and this is recursively true for their children.
fn verify_bvh_bounds( shapes : &[Rc< dyn Tracable >], num_infinite : usize, bvh : &Vec< BVHNode4 >, bounds : AABB, i : i32 ) -> Option< AABB > {
if i >= 0 {
//... | code_fim | hard | {
"lang": "rust",
"repo": "sourcedennis/wasm-pathtracer",
"path": "/src/graphics/bvh4.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sourcedennis/wasm-pathtracer path: /src/graphics/bvh4.rs
// External imports
use std::f32::INFINITY;
use std::i32;
use std::rc::Rc;
use std::fmt;
// Local imports
use crate::graphics::bvh::BVHNode;
use crate::graphics::{AABB, AABBx4};
use crate::graphics::ray::Tracable;
/// A node in a 4-way BV... | code_fim | hard | {
"lang": "rust",
"repo": "sourcedennis/wasm-pathtracer",
"path": "/src/graphics/bvh4.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: extraymond/activity_tracker path: /src/elements/dashboard/view.rs
use afterglow::prelude::*;
#[derive(Default)]
pub struct View;
impl View {
const STYLE: &'static str = r#"
min-height: 100%;
max-height: 100%;
min-width: 100%;
max-width: 100%;
"#;
c... | code_fim | hard | {
"lang": "rust",
"repo": "extraymond/activity_tracker",
"path": "/src/elements/dashboard/view.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let activites = target
.activities
.iter()
.enumerate()
.map(|(idx, activity)| {
let selected = if let Some(id) = target.selected {
if id == idx {
"transition: margin-left 0.5s; margin-left:... | code_fim | hard | {
"lang": "rust",
"repo": "extraymond/activity_tracker",
"path": "/src/elements/dashboard/view.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: q231950/paper path: /src/resource/account_resource.rs
use crate::model::SessionToken;
use crate::model::AccountInfo;
use crate::resource::Resource;
use crate::xml::AccountInfoXmlParser;
use std::io::Read;
<|fim_suffix|> let parser = AccountInfoXmlParser::new();
parser.account_in... | code_fim | medium | {
"lang": "rust",
"repo": "q231950/paper",
"path": "/src/resource/account_resource.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn request_body(&self) -> String {
format!(
r#"<?xml version='1.0' encoding='utf-8'?>
<soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'>
... | code_fim | medium | {
"lang": "rust",
"repo": "q231950/paper",
"path": "/src/resource/account_resource.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Resource<AccountInfo> for AccountInfoResource {
fn parse(&self, bytes: impl Read) -> Result<AccountInfo, &'static str> {
let parser = AccountInfoXmlParser::new();
parser.account_info_from_xml(bytes)
}
fn request_body(&self) -> String {
format!(
r#"<?... | code_fim | medium | {
"lang": "rust",
"repo": "q231950/paper",
"path": "/src/resource/account_resource.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Actual methods implementation for non-test purposes.
#[cfg(not(test))]
mod parameters_impl {
// Built-in deps.
use std::time::Duration;
// Workspace deps
use models::config_options::parse_env;
/// Name of the environment variable responsible for the `gas_price_limit` renewing inter... | code_fim | hard | {
"lang": "rust",
"repo": "intech-id/collexi-rollup",
"path": "/core/server/src/eth_sender/gas_adjuster/parameters.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: intech-id/collexi-rollup path: /core/server/src/eth_sender/gas_adjuster/parameters.rs
//! `parameters` module provides methods to get configurable parameters of `GasAdjuster`.
//!
//! Currently the following types of parameters are provided:
//! - Maximum gas price renewal interval: interval bet... | code_fim | hard | {
"lang": "rust",
"repo": "intech-id/collexi-rollup",
"path": "/core/server/src/eth_sender/gas_adjuster/parameters.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Hard-coded implementation for tests.
#[cfg(test)]
mod parameters_impl {
// Built-in deps.
use std::time::Duration;
/// `limit_update_interval` version for tests not looking for an environment variable value
/// but using a zero interval instead.
pub fn limit_update_interval() -> Du... | code_fim | hard | {
"lang": "rust",
"repo": "intech-id/collexi-rollup",
"path": "/core/server/src/eth_sender/gas_adjuster/parameters.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ragmentId>().zip(value.typed_ref::<Value>()).and_then(
|(fragment_id, value)| {
UtxoPointer::new(fragment_id, output_index as u8, value).rptr().jptr(&env)
}
)
})
.jresult(&env)
}<|fim_prefix|>// repo: Emurgo/react-native-chain-libs path: /rust/src/android/utxo_pointer.rs
use s... | code_fim | hard | {
"lang": "rust",
"repo": "Emurgo/react-native-chain-libs",
"path": "/rust/src/android/utxo_pointer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Emurgo/react-native-chain-libs path: /rust/src/android/utxo_pointer.rs
use super::ptr_j::*;
use super::result::ToJniResult;
use crate::panic::{handle_exception_result, Zip};
use crate::ptr::RPtrRepresentable;
use jni::objects::JObject;
use jni::sys::{jint, jobject};
use jni::<|fim_suffix|>ent_id... | code_fim | hard | {
"lang": "rust",
"repo": "Emurgo/react-native-chain-libs",
"path": "/rust/src/android/utxo_pointer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ent_id: JRPtr, output_index: jint, value: JRPtr
) -> jobject {
handle_exception_result(|| {
let fragment_id = fragment_id.rptr(&env)?;
let value = value.rptr(&env)?;
fragment_id.typed_ref::<FragmentId>().zip(value.typed_ref::<Value>()).and_then(
|(fragment_id, value)| {
UtxoPoi... | code_fim | hard | {
"lang": "rust",
"repo": "Emurgo/react-native-chain-libs",
"path": "/rust/src/android/utxo_pointer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n == 0 { 0 }
else {
let p = popcount(n);
1 + f(n % p)
}
}
fn popcount(n: usize) -> usize {
if n == 0 { 0 }
else { n % 2 + popcount(n/2) }
}
#[allow(dead_code)]
fn get_line() -> String {
let mut s = String::new();
match stdin().read_line(&mut s){
Ok(... | code_fim | hard | {
"lang": "rust",
"repo": "seiyab/atcoder",
"path": "/else/aising/2020/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
fn vec_min(xs: &Vec<i64>) -> i64 {
xs.iter().map(|&x|x).fold(std::i64::MAX, std::cmp::min)
}
#[allow(dead_code)]
fn vec_max(xs: &Vec<i64>) -> i64 {
xs.iter().map(|&x|x).fold(std::i64::MIN, std::cmp::max)
}
#[allow(dead_code)]
fn vec_sum(xs: &Vec<i64>) -> i64 {
xs.iter().f... | code_fim | hard | {
"lang": "rust",
"repo": "seiyab/atcoder",
"path": "/else/aising/2020/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seiyab/atcoder path: /else/aising/2020/d.rs
use std::io::stdin;
use std::str::FromStr;
fn main(){
let _n: usize = get_one();
let mut s = get_chars();
s.reverse();
let m = s.iter().fold(0, |acc, &c| if c == '1' {acc + 1} else {acc});
let mut z: Vec<Vec<usize>> = Vec::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "seiyab/atcoder",
"path": "/else/aising/2020/d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tremor-rs/tremor-runtime path: /tremor-script/src/deploy.rs
// Copyright 2020-2021, The Tremor Team
//
// 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": "tremor-rs/tremor-runtime",
"path": "/tremor-script/src/deploy.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> aid: arena::Index,
src: &'static str,
reg: &Registry,
aggr_reg: &AggrRegistry,
) -> Result<Self> {
let mut helper = ast::Helper::new(reg, aggr_reg);
//let cu = include_stack.push(&file_name)?;
let tokens = Lexer::new(src, aid).collect::<Result<Ve... | code_fim | hard | {
"lang": "rust",
"repo": "tremor-rs/tremor-runtime",
"path": "/tremor-script/src/deploy.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let m1 = 10u8;
match m1
{
0 => println!("zero"),
10 => println!("ten"),
20 => println!("twenty"),
30 => println!("thirty"),
_ => println!("other")
}
}<|fim_prefix|>// repo: faisalrwp/MyRustClass path: /20200105/enumgeneric/src/main.rs
#[derive(Deb... | code_fim | hard | {
"lang": "rust",
"repo": "faisalrwp/MyRustClass",
"path": "/20200105/enumgeneric/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: faisalrwp/MyRustClass path: /20200105/enumgeneric/src/main.rs
#[derive(Debug)]
enum Options<T>
{
Some(T),
None
}
enum MatchTest{value1(u8), value2(u8)}
<|fim_suffix|> let m1 = 10u8;
match m1
{
0 => println!("zero"),
10 => println!("ten"),
20 => print... | code_fim | hard | {
"lang": "rust",
"repo": "faisalrwp/MyRustClass",
"path": "/20200105/enumgeneric/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
Err((Err2::V2(()), 0..2)),
flat_map(tag("ab"), |_, _, p| Err::<((), _, _), _>(((), 0..p))).parse("abc")
)
}
#[test]
fn flat_map_some_parses() {
assert_eq!(
Ok((0u8, "c", 2)),
flat_map(tag("ab"), |_, s, p| Ok::<_, ((), _)>((0u8, s, p))).parse("abc")
... | code_fim | easy | {
"lang": "rust",
"repo": "WaDelma/mini-pl",
"path": "/parsco/tests/control.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WaDelma/mini-pl path: /parsco/tests/control.rs
extern crate parsco;
use parsco::{Parser, tag, flat_map};
use parsco::common::Err2;
<|fim_suffix|> assert_eq!(
Ok((0u8, "c", 2)),
flat_map(tag("ab"), |_, s, p| Ok::<_, ((), _)>((0u8, s, p))).parse("abc")
)
}<|fim_middle|>#[te... | code_fim | hard | {
"lang": "rust",
"repo": "WaDelma/mini-pl",
"path": "/parsco/tests/control.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CavHack/EinsteinDB path: / einsteindb-gen(0).einsteindb-gen/edn-causet-sql/src/storage/range.rs
//Copyright 2021-2023 WHTCORPS INC ALL RIGHTS RESERVED. APACHE 2.0 COMMUNITY EDITION SL
// AUTHORS: WHITFORD LEDER
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
//... | code_fim | hard | {
"lang": "rust",
"repo": "CavHack/EinsteinDB",
"path": "/ einsteindb-gen(0).einsteindb-gen/edn-causet-sql/src/storage/range.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.