text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/pascal.rs
typenum::Integer>::$typenum_const);
assert!(val <= <MAX as typenum::Integer>::$typenum_const);
//TODO: Add more checks here.
$name(val, PhantomData)
}
$v fn get(self) -> $base_type {
... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/pascal.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn len(&mut self) -> usize {
self.packets.len()
}
/// Adds a packet to the waiting packets
pub fn enqueue(&mut self, seq: u16, packet: GafferPacket) {
// TODO: Handle overwriting other packet?
// That really shouldn't happen, but it should be encoded here
self.packets.insert... | code_fim | hard | {
"lang": "rust",
"repo": "acmcarther/gaffer_udp",
"path": "/src/connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_empty(&mut self) -> bool {
self.packets.is_empty()
}
pub fn len(&mut self) -> usize {
self.packets.len()
}
/// Adds a packet to the waiting packets
pub fn enqueue(&mut self, seq: u16, packet: GafferPacket) {
// TODO: Handle overwriting other packet?
// That really... | code_fim | hard | {
"lang": "rust",
"repo": "acmcarther/gaffer_udp",
"path": "/src/connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmcarther/gaffer_udp path: /src/connection.rs
use std::collections::HashMap;
use itertools::Itertools;
use packet::GafferPacket;
/// Connection to a known third party
///
/// Contains:
/// - own unacked sent-packets
/// - ack-state of third party's packets
/// - own dropped packets
/// - own... | code_fim | hard | {
"lang": "rust",
"repo": "acmcarther/gaffer_udp",
"path": "/src/connection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BigAngryDinosaur/rs_atcoder path: /src/bin/longest_path.rs
use std::io;
use std::io::prelude::*;
use std::cmp::max;
fn main() {
let stdin = io::stdin();
let handle = stdin.lock();
let mut lines = handle.lines().map(|l| l.unwrap());
let line1: Vec<usize> = lines.next().unwrap()... | code_fim | medium | {
"lang": "rust",
"repo": "BigAngryDinosaur/rs_atcoder",
"path": "/src/bin/longest_path.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> longest_distance
}
fn memoize(graph: Vec<Vec<usize>>, num_vertices: usize) -> usize {
fn go(graph: &Vec<Vec<usize>>, num_vertices: usize, vertex: usize, memo: &mut Vec<usize>) -> usize {
if vertex == num_vertices + 1 {
return 0;
}
if memo[vertex] == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "BigAngryDinosaur/rs_atcoder",
"path": "/src/bin/longest_path.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if vertex == num_vertices + 1 {
return 0;
}
if memo[vertex] == 0 {
let mut longest_distance = 0;
for dest in graph[vertex].clone() {
longest_distance = max(longest_distance, 1 + go(graph, num_vertices, dest, memo));
}... | code_fim | hard | {
"lang": "rust",
"repo": "BigAngryDinosaur/rs_atcoder",
"path": "/src/bin/longest_path.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
transform: Transform,
graphics: &mut Context,
model_manager: &AssetManager<sukakpak::Mesh>,
_texture_manager: &AssetManager<Texture>,
) {
let mat = transform.mat() * self.transform.mat();
graphics
.draw_mesh(
ma... | code_fim | hard | {
"lang": "rust",
"repo": "scifi6546/Sukakpak",
"path": "/summit_surveyor_v2/src/gui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
transform: Transform,
_graphics: &mut Context,
_gui_state: &mut GuiState,
_model_manager: &mut AssetManager<sukakpak::Mesh>,
_texture_manager: &mut AssetManager<Texture>,
) {
self.transform = transform
}
fn build_listner(&self)... | code_fim | hard | {
"lang": "rust",
"repo": "scifi6546/Sukakpak",
"path": "/summit_surveyor_v2/src/gui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scifi6546/Sukakpak path: /summit_surveyor_v2/src/gui.rs
ntSize;
use text::{TextBuilder, TextBuilderContainer, TextInfo};
pub struct GuiComponent {
pub item: Mutex<Box<dyn GuiItem>>,
}
#[derive(Default)]
pub struct GuiState {
text_builders: TextBuilderContainer,
}
impl GuiComponent {
... | code_fim | hard | {
"lang": "rust",
"repo": "scifi6546/Sukakpak",
"path": "/summit_surveyor_v2/src/gui.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kompics/kompicsbenches path: /actix/src/actix_system_provider.rs
//use super::*;
use actix::*;
//use actix::prelude::*;
use futures::channel::mpsc::{channel, Receiver, Sender};
use futures::channel::oneshot::channel as promise;
use futures::{StreamExt, Future};
use std::fmt;
use std::sync::{Arc... | code_fim | hard | {
"lang": "rust",
"repo": "kompics/kompicsbenches",
"path": "/actix/src/actix_system_provider.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl MyActor {
fn new() -> MyActor {
MyActor { count: 0 }
}
}
// Provide Actor implementation for our actor
impl Actor for MyActor {
type Context = Context<Self>;
fn started(&mut self, _ctx: &mut Context<Self>) {
println!("Actor is ... | code_fim | hard | {
"lang": "rust",
"repo": "kompics/kompicsbenches",
"path": "/actix/src/actix_system_provider.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn run(spec: &Spec) -> BenchResult {
// Pre-generate the payload so weŕe not measuring string
// creation.
let data = (0..spec.size).map(|_| "x").collect::<String>();
// Create our first actor
let mut addr: Addr<_> = RingActor {
next: None,
id: 0,
max... | code_fim | hard | {
"lang": "rust",
"repo": "klxqlehua/xactor-benchmarks",
"path": "/src/xactor_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: klxqlehua/xactor-benchmarks path: /src/xactor_test.rs
use super::{Result as BenchResult, Spec};
use xactor::*;
// The ring actor
struct RingActor {
// Next actor in the ring - must allow None as the actor only knows
// about the next actor once it has been created.
next: Option<Addr... | code_fim | hard | {
"lang": "rust",
"repo": "klxqlehua/xactor-benchmarks",
"path": "/src/xactor_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samdolt/influxdb-rs path: /src/connection.rs
use url::Url;
use semver::Version;
use reqwest::get;
use reqwest::StatusCode;
use reqwest::Client;
use slog::Logger;
use ::headers::XInfluxDbVersion;
use ::ConnectParams;
use ::Credential;
use ::Lines;
use ::Result;
use ::ErrorKind;
pub struct ... | code_fim | hard | {
"lang": "rust",
"repo": "samdolt/influxdb-rs",
"path": "/src/connection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!(params.logger, "Port parsed");
let username = match url.username() {
"" => None,
u => Some(u.to_string())
};
debug!(params.logger, "Username parsed");
let password = match url.password(){
None => None,
Some(... | code_fim | hard | {
"lang": "rust",
"repo": "samdolt/influxdb-rs",
"path": "/src/connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kumazuma/rs-threads-board path: /src/common.rs
extern crate serde;
extern crate rouille;
extern crate crypto;
pub fn error(msg:&str, code:u16)->rouille::Response{
rouille::Response::text(msg).with_status_code(code)
}
pub fn to_sha3(text:&str)->String{
use crypto::digest::Digest;
use... | code_fim | medium | {
"lang": "rust",
"repo": "Kumazuma/rs-threads-board",
"path": "/src/common.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // read hash digest
hasher.result_str()
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ServerSetting{
pub host:String,
pub db:String,
pub user:String,
pub password:String,
pub aes_iv:String,
pub aes_key:String
}
#[derive(Clone, Copy)]
pub enum ResponseContentType{
Html,
... | code_fim | medium | {
"lang": "rust",
"repo": "Kumazuma/rs-threads-board",
"path": "/src/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[pyfn(module, "sieve")]
fn sieve_py(py: Python, n: u32) -> &PyList {
let list = PyList::new(py, &sieve(n as usize));
list
}
Ok(())
}<|fim_prefix|>// repo: RangHo/rusty-python path: /rustsieve/src/lib.rs
use pyo3::Python;
use pyo3::prelude::*;
use pyo3::types::PyList;
fn... | code_fim | medium | {
"lang": "rust",
"repo": "RangHo/rusty-python",
"path": "/rustsieve/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RangHo/rusty-python path: /rustsieve/src/lib.rs
use pyo3::Python;
use pyo3::prelude::*;
use pyo3::types::PyList;
fn sieve(n: usize) -> Vec<u32> {
let mut sieve: Vec<u32> = (2..((n + 1) as u32)).collect();
let limit: usize = ((n as f64).sqrt() + 1.0) as usize;
<|fim_suffix|>
#[pyfn(... | code_fim | hard | {
"lang": "rust",
"repo": "RangHo/rusty-python",
"path": "/rustsieve/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //println!(
// "{}\n{}の{}が{}として認定されました。",
// dt.format("%Y年%m月%d日"),
// device.name,
// device.type_name,
// device.radio_equipment_code
//);
add_giteki(&database,... | code_fim | hard | {
"lang": "rust",
"repo": "itok01/gitekikun",
"path": "/src/giteki_client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: itok01/gitekikun path: /src/giteki_client.rs
use chrono::NaiveDate;
use super::db::*;
pub async fn get_latest_giteki_list() -> Result<giteki::list::Response, Box<dyn std::error::Error>>
{
let mut giteki_params = giteki::list::RequestParameters::new();
giteki_params.set_sk(12);
Ok(g... | code_fim | hard | {
"lang": "rust",
"repo": "itok01/gitekikun",
"path": "/src/giteki_client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut giteki_params = giteki::list::RequestParameters::new();
giteki_params.set_dc(7);
giteki_params.set_sk(12);
giteki_params.set_de(&end_date);
let resp: giteki::list::Response = giteki::list::get(&giteki_params).await?;
for giteki_info in resp.giteki {... | code_fim | hard | {
"lang": "rust",
"repo": "itok01/gitekikun",
"path": "/src/giteki_client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
Solution::search_range(vec![5, 7, 7, 8, 8, 10], 8),
vec![3, 4]
);
assert_eq!(
Solution::search_range(vec![5, 7, 7, 8, 8, 10], 6),
vec![-1, -1]
);
assert_eq!(Solution::search_range(vec![1], 0), vec![-1, -1]);
}<|fim_prefix|>// repo: Baoyx007/LeetCode-Rust path: /34.在排... | code_fim | medium | {
"lang": "rust",
"repo": "Baoyx007/LeetCode-Rust",
"path": "/34.在排序数组中查找元素的第一个和最后一个位置.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![tmp_low as i32, tmp_high as i32]
}
None => vec![-1, -1],
}
}
}
#[test]
fn case() {
assert_eq!(
Solution::search_range(vec![5, 7, 7, 8, 8, 10], 8),
vec![3, 4]
);
assert_eq!(
Solution::search_range(vec![5, 7, 7, 8, 8, 10], 6),
vec![-1, -1]
);
assert_... | code_fim | hard | {
"lang": "rust",
"repo": "Baoyx007/LeetCode-Rust",
"path": "/34.在排序数组中查找元素的第一个和最后一个位置.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Baoyx007/LeetCode-Rust path: /34.在排序数组中查找元素的第一个和最后一个位置.rs
/*
* @lc app=leetcode.cn id=34 lang=rust
*
* [34] 在排序数组中查找元素的第一个和最后一个位置
*/
impl Solution {
pub fn search_range(nums: Vec<i32>, target: i32) -> Vec<i32> {
if nums.is_empty() {
return vec![-1, -1];
};
if nums.len() ... | code_fim | hard | {
"lang": "rust",
"repo": "Baoyx007/LeetCode-Rust",
"path": "/34.在排序数组中查找元素的第一个和最后一个位置.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MikailBag/jjs-pps path: /engine/src/apis/import.rs
mod problem_importer;
mod template;
mod valuer_cfg;
use crate::operation::{Operation, ProgressWriter};
use anyhow::{bail, Context as _};
use problem_importer::Importer;
use serde::{Deserialize, Serialize};
use std::{
collections::HashSet,
... | code_fim | hard | {
"lang": "rust",
"repo": "MikailBag/jjs-pps",
"path": "/engine/src/apis/import.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>enum ImportKind {
Problem,
Contest,
}
fn detect_import_kind(path: &Path) -> anyhow::Result<ImportKind> {
if !path.exists() {
bail!("path {} does not exists", path.display());
}
if path.join("problem.xml").exists() {
return Ok(ImportKind::Problem);
}
if path.jo... | code_fim | hard | {
"lang": "rust",
"repo": "MikailBag/jjs-pps",
"path": "/engine/src/apis/import.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let manifest_path = dest.join("problem.toml");
let manifest_toml =
toml::Value::try_from(importer.problem_cfg.clone()).context("serialize ppc config")?;
let manifest_data = toml::ser::to_string_pretty(&manifest_toml)
.with_context(|| format!("stringify ppc config: {:#?}", &impo... | code_fim | hard | {
"lang": "rust",
"repo": "MikailBag/jjs-pps",
"path": "/engine/src/apis/import.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pool = Threadpool::new().unwrap();
pool.block_on(async { panic!() });
}<|fim_prefix|>// repo: raftario/wae path: /tests/basic.rs
use wae::Threadpool;
#[test]
fn ok() {
<|fim_middle|> let pool = Threadpool::new().unwrap();
let two = pool.block_on(async { 1 + 1 });
assert_eq!(2, two... | code_fim | medium | {
"lang": "rust",
"repo": "raftario/wae",
"path": "/tests/basic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raftario/wae path: /tests/basic.rs
use wae::Threadpool;
#[test]
fn ok() {
<|fim_suffix|>#[test]
#[should_panic]
fn err() {
let pool = Threadpool::new().unwrap();
pool.block_on(async { panic!() });
}<|fim_middle|> let pool = Threadpool::new().unwrap();
let two = pool.block_on(asyn... | code_fim | medium | {
"lang": "rust",
"repo": "raftario/wae",
"path": "/tests/basic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::HopcroftKarp;
#[test]
fn testcase1() {
let mut hopkarp = HopcroftKarp::new(2);
let graph = vec![vec![0, 1], vec![0]];
let expected: Vec<Option<usize>> = vec![Some(1), Some(0)];
assert_eq!(&expected, hopkarp.get_maximum_matchin... | code_fim | hard | {
"lang": "rust",
"repo": "calcoloergosum/hopcroft-karp-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut hopkarp = HopcroftKarp::new(2);
let graph = vec![vec![0, 1], vec![0]];
let expected: Vec<Option<usize>> = vec![Some(1), Some(0)];
assert_eq!(&expected, hopkarp.get_maximum_matching(&graph));
}
#[test]
fn testcase2() {
let mut hopkarp = HopcroftKa... | code_fim | hard | {
"lang": "rust",
"repo": "calcoloergosum/hopcroft-karp-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: calcoloergosum/hopcroft-karp-rust path: /src/lib.rs
use std::collections::LinkedList;
use std::iter::repeat;
pub struct HopcroftKarp {
cur_d: Option<i32>,
l2d: Vec<Option<i32>>,
matching_l2r: Vec<Option<usize>>,
matching_r2l: Vec<Option<usize>>,
}
impl HopcroftKarp {
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "calcoloergosum/hopcroft-karp-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> entity.set_background_color(state, Color::white())
}
}
fn main() {
let app = Application::new(
WindowDescription::new()
.with_title("Stack")
.with_inner_size(300, 300),
|state, window| {
window.set_background_color(state, Color::white());
... | code_fim | hard | {
"lang": "rust",
"repo": "lineCode/tuix",
"path": "/examples/widgets/stack.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lineCode/tuix path: /examples/widgets/stack.rs
use tuix::*;
const STYLE: &str = r#"
stack {
background-color: white;
}
button {
width: 50px;
height: 30px;
color: black;
background-color: gray;
child-space: 1s;
border-radius: ... | code_fim | hard | {
"lang": "rust",
"repo": "lineCode/tuix",
"path": "/examples/widgets/stack.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // First page
let first = Element::new().build(state, self.stack, |builder|
builder
.set_background_color(Color::red())
);
Label::new("Red Page").build(state, first, |builder| builder.set_color(Color::black()));
Button::with_label("Next"... | code_fim | hard | {
"lang": "rust",
"repo": "lineCode/tuix",
"path": "/examples/widgets/stack.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: berquerant/jsongrep path: /src/select.rs
use crate::error::{Error, ErrorCode, Result};
use crate::query;
use serde_json::from_str;
use serde_json::value::Value;
/// JSON filter.
///
/// ```
/// # use jsongrep::raw_query;
/// # use jsongrep::query;
/// # use jsongrep::select;
/// # use std::conv... | code_fim | hard | {
"lang": "rust",
"repo": "berquerant/jsongrep",
"path": "/src/select.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let q = MockOkEvaluableQuery(false);
let got = Query::new(Box::new(q)).select(r#"{"x":1}"#);
assert!(got.err().unwrap().is_filtered());
}
#[test]
fn test_query_ok() {
let q = MockOkEvaluableQuery(true);
let got = Query::new(Box::new(q)).select(r#"{"x":1}... | code_fim | hard | {
"lang": "rust",
"repo": "berquerant/jsongrep",
"path": "/src/select.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct MockOkEvaluableQuery(bool);
impl query::EvaluableQuery for MockOkEvaluableQuery {
fn eval(&self, _: &Value) -> Result<bool> {
Ok(self.0)
}
}
#[test]
#[should_panic]
fn test_query_err_json() {
let q = MockOkEvaluableQuery(true);
Qu... | code_fim | hard | {
"lang": "rust",
"repo": "berquerant/jsongrep",
"path": "/src/select.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(target_arch = "x86_64")]
fn get_tib_pid(tib: &[u8]) -> u32 {
// Rust always returns a 32 bit number for PID. Will leave as is unless it turns out to cause any bugs.
u64::from_le_bytes(tib[0x40..0x48].try_into().unwrap()) as u32
}
#[test]
fn tib() {
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "mitunzavery/rustrat",
"path": "/rustrat-prng-seed/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (rdrand, remainder) = out_buf.split_at_mut(16);
let (rdtsc, tib) = remainder.split_at_mut(8);
unsafe {
rdrand_fn(rdrand.as_mut_ptr());
rdtsc_fn(rdtsc.as_mut_ptr());
copy_tib(tib.as_mut_ptr());
}
// TODO possibly use something other than Blake2? Used for si... | code_fim | hard | {
"lang": "rust",
"repo": "mitunzavery/rustrat",
"path": "/rustrat-prng-seed/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitunzavery/rustrat path: /rustrat-prng-seed/src/lib.rs
use blake2::{Blake2s, Digest};
// rdrand_fn needs an array of 16 bytes and will fill the array with random data from rdrand. A return value of 0 means that rdrand could not provide random values. Note that some values may have changed in t... | code_fim | hard | {
"lang": "rust",
"repo": "mitunzavery/rustrat",
"path": "/rustrat-prng-seed/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Put elements back to a.
a.swap_with_slice(&mut b);
}
#[cfg(test)]
mod tests {
use crate::test_utilities;
use rand::Rng;
use std::iter;
#[test]
fn test_counting_sort_by_key() {
let mut a = Vec::new();
let mut b = Vec::new();
let mut rng = rand::thre... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/Introduction-to-Algorithms",
"path": "/src/chapter_8_sorting_in_linear_time/section_8_2_counting_sort/extra.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: philipstears/osc path: /osc-fat-example/src/main.rs
#![allow(dead_code)]
use osc_block_storage::virt::*;
use osc_fat::*;
use std::fs::File;
use std::io::Result;
fn main() -> Result<()> {
let image = "/home/stears/data/simon/nox-rust/target/x86-nox/release/nox-rust.img";
let offset = 10... | code_fim | hard | {
"lang": "rust",
"repo": "philipstears/osc",
"path": "/osc-fat-example/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match entry {
DirectoryEntry::LongFileName(entry) => {
print!("{:>indent$}", "", indent = level * 2);
println!(
"LFN: {:?}",
std::char::decode_utf16(entry.chars())
.filter_map(|ch| ch.ok())
.collec... | code_fim | hard | {
"lang": "rust",
"repo": "philipstears/osc",
"path": "/osc-fat-example/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if entry.is_directory() {
println!("Dir: {}", std::str::from_utf8(entry.name()).unwrap(),);
if entry.name()[0] != b'.' {
let mut read_buffer = vec![0u8; fs.required_read_buffer_size()];
fs.walk_directory(
... | code_fim | hard | {
"lang": "rust",
"repo": "philipstears/osc",
"path": "/osc-fat-example/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jolestar/libra path: /language/functional-tests/src/tests/preprocessor_tests.rs
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
errors::*,
preprocessor::{build_transactions, extract_global_config, split_input},
};
fn parse_input(input: &... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/language/functional-tests/src/tests/preprocessor_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> parse_input(r"
//! new-transaction
main() {}
").unwrap();
}
#[rustfmt::skip]
#[test]
fn parse_input_config_before_first_empty_transaction() {
parse_input(r"
//! no-run: runtime
//! new-transaction
main() {}
").unwrap_err();
}
#[rustfmt::skip]
#[tes... | code_fim | medium | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/language/functional-tests/src/tests/preprocessor_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = (deg/90 + 4) % 4;
let s = 1 - (1 - a).abs();
let c = (2 - a).abs() - 1;
assert!(-1 <= s && s <= 1);
assert!(-1 <= c && c <= 1);
*self = Point(c*self.0 + s*self.1, c*self.1 - s*self.0);
}
}
//-----------------------------------------------------... | code_fim | hard | {
"lang": "rust",
"repo": "spadix0/AoC2020",
"path": "/12/navigate/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spadix0/AoC2020 path: /12/navigate/src/main.rs
use std::io;
fn main() {
let path = std::env::args().nth(1).unwrap();
let navs = read(&mut std::fs::File::open(path).unwrap());
//println!("{:?}", navs);
println!("part[1]: {}", traverse(&navs).l1_norm());
println!("part[2]: {}... | code_fim | hard | {
"lang": "rust",
"repo": "spadix0/AoC2020",
"path": "/12/navigate/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(traverse(&read(&mut EX0.as_bytes())), Point(17, -8));
}
#[test]
fn answer1() {
assert_eq!(traverse(&read(&mut INPUT.as_bytes())), Point(-163, -218));
}
#[test]
fn ex0_waypoint() {
assert_eq!(waypoint(&read(&mut EX0.as_bytes())), Point(214, -72))... | code_fim | hard | {
"lang": "rust",
"repo": "spadix0/AoC2020",
"path": "/12/navigate/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/* For internal use only. */
pub const queueSEND_TO_BACK: BaseType_t = 0;
pub const queueSEND_TO_FRONT: BaseType_t = 1;
pub const queueOVERWRITE: BaseType_t = 2;
/* For internal use only. These definitions *must* match those in queue.c. */
pub const queueQUEUE_TYPE_BASE: u8 = 0;
pub const queueQUEUE_TYP... | code_fim | hard | {
"lang": "rust",
"repo": "YonasJ/esp-idf-n-hal",
"path": "/src/esp_idf.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YonasJ/esp-idf-n-hal path: /src/esp_idf.rs
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(unused)]
pub mod std {
pub use core::*;
<|fim_suffix|>pub const pdFALSE: u32 = 0;
pub const pdTRUE: u32 = 1;
pub const pdPASS: u32 = pdTRUE;
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "YonasJ/esp-idf-n-hal",
"path": "/src/esp_idf.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zdimension/c2rust path: /c2rust/src/bin/c2rust-refactor.rs
extern crate env_logger;
#[macro_use]
extern crate log;
#[macro_use]
extern crate clap;
extern crate c2rust_refactor;
extern crate shlex;
use clap::{App, ArgMatches};
use std::fs::File;
use std::io::Read;
use std::process;
use std::str:... | code_fim | hard | {
"lang": "rust",
"repo": "zdimension/c2rust",
"path": "/c2rust/src/bin/c2rust-refactor.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> marks.push(Mark::new(id, label));
}
// Get plugin options
let plugins = args.values_of_lossy("plugin-name").unwrap_or(vec![]);
let plugin_dirs = args.values_of_lossy("plugin-dir").unwrap_or(vec![]);
// Handle --cargo and rustc-args
let rustc_args = match args.values_of_lo... | code_fim | hard | {
"lang": "rust",
"repo": "zdimension/c2rust",
"path": "/c2rust/src/bin/c2rust-refactor.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Test the behavior of `filter_anti` used on its own in a
/// leapjoin -- effectively it becomes a "set minus" operation.
#[test]
fn filter_anti_on_its_own((set1, set2) in (inputs(), inputs())) {
let input1: Relation<(u32, u32)> = set1.iter().collect();
let input2: Relati... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/datafrog",
"path": "/src/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // NB. Changed from `reachable_with_var_join`:
let edges_by_successor: Relation<_> = edges.iter().map(|&(n1, n2)| (n2, n1)).collect();
let reachable = iteration.variable::<(u32, u32)>("reachable");
reachable.insert(edges);
while iteration.changed() {
// reachable(N1, N3) :- e... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/datafrog",
"path": "/src/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/datafrog path: /src/test.rs
#![cfg(test)]
use crate::Iteration;
use crate::Relation;
use crate::RelationLeaper;
use proptest::prelude::*;
use proptest::{proptest, proptest_helper};
fn inputs() -> impl Strategy<Value = Vec<(u32, u32)>> {
prop::collection::vec((0_u32..100, 0_u32..1... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/datafrog",
"path": "/src/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result.push(Bar {
timestamp: timestamps[i] * 1000,
open: quote.opens[i].context(error::InternalLogic{ reason: "missing open not caught" })?,
high: quote.highs[i].context(error::InternalLogic{ reason: "missing high not caught" })?,
low: quote.lows[i].context(error:... | code_fim | hard | {
"lang": "rust",
"repo": "kov/yahoo-finance-rs",
"path": "/src/history.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kov/yahoo-finance-rs path: /src/history.rs
use chrono::{DateTime, Utc};
use snafu::{ensure, OptionExt};
use crate::{error, yahoo, Bar, Interval, Result};
fn aggregate_bars(data: yahoo::Data) -> Result<Vec<Bar>> {
let mut result = Vec::new();
let timestamps = &data.timestamps;
let quo... | code_fim | hard | {
"lang": "rust",
"repo": "kov/yahoo-finance-rs",
"path": "/src/history.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> aggregate_bars(yahoo::load_daily(symbol, interval).await?)
}
/// Retrieves OCLHV data for a symbol between a start and end date.
///
/// # Examples
///
/// Get 5 days worth of Apple data:
///
/// ``` no_run
/// use chrono::{Duration, TimeZone, Utc};
/// use yahoo_finance::{ history, Timestamped };
///... | code_fim | hard | {
"lang": "rust",
"repo": "kov/yahoo-finance-rs",
"path": "/src/history.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Debug for MLURef {
#[cold]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let t = self.text(Locale::none());
write!(
f,
"MLU({:?} {:?})",
if let Ok(ref t) = t { t } else { "None" },
self.tanslations()
)
... | code_fim | hard | {
"lang": "rust",
"repo": "kornelski/rust-lcms2",
"path": "/src/mlu.rs",
"mode": "spm",
"license": "MIT-0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kornelski/rust-lcms2 path: /src/mlu.rs
use crate::ffi::wchar_t;
use crate::*;
use foreign_types::{ForeignType, ForeignTypeRef};
use std::char::{decode_utf16, REPLACEMENT_CHARACTER};
use std::ffi::CString;
use std::fmt;
use std::iter::repeat;
use std::mem;
use std::ptr;
foreign_type! {
/// T... | code_fim | hard | {
"lang": "rust",
"repo": "kornelski/rust-lcms2",
"path": "/src/mlu.rs",
"mode": "psm",
"license": "MIT-0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-server/tests/func_insert.rs
mod sql_test;
use apllodb_server::test_support::test_setup;
use apllodb_shared_components::SqlState;
use sql_test::{SqlTest, Step, StepRes, Steps};
<|fim_suffix|>#[async_std::test]
async fn test_error_on_dup_pk() {
SqlTest::default... | code_fim | medium | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-server/tests/func_insert.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_setup();
}
#[async_std::test]
async fn test_error_on_dup_pk() {
SqlTest::default()
.add_steps(Steps::CreateTablePeople)
.add_step(Step::new("BEGIN", StepRes::Ok))
.add_step(Step::new(
"INSERT INTO people (id, age) VALUES (1, 10)",
StepRes::Ok,
... | code_fim | medium | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-server/tests/func_insert.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bwbuhse/challenge-probs-rust path: /src/code_wars/desc_order.rs
use std::collections::BTreeMap;
// https://www.codewars.com/kata/5467e4d82edf8bbf40000155
pub fn sol(mut x: u64) -> u64 {
let mut digit_counts = BTreeMap::new();
<|fim_suffix|> // Then iterate through the map and add count ... | code_fim | medium | {
"lang": "rust",
"repo": "bwbuhse/challenge-probs-rust",
"path": "/src/code_wars/desc_order.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Then iterate through the map and add count x's onto res, multiplying by 10 each time
let mut x_descending = 0;
for (digit, count) in digit_counts.iter().rev() {
for _ in 0..*count {
x_descending *= 10;
x_descending += *digit;
}
}
x_descending... | code_fim | medium | {
"lang": "rust",
"repo": "bwbuhse/challenge-probs-rust",
"path": "/src/code_wars/desc_order.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexxbb/sprios path: /src/sprios/src/app.rs
use crate::utils;
use crate::worlds::{World, final_world};
use gdk_pixbuf::{PixbufLoader};
use gio::ApplicationExt;
use glib::{clone};
use glib::signal::Inhibit;
use gtk::{ApplicationWindow, Box as GtkBox, BoxExt, Button, ButtonExt, ContainerExt, GtkWi... | code_fim | hard | {
"lang": "rust",
"repo": "alexxbb/sprios",
"path": "/src/sprios/src/app.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let thread_box = GtkBox::new(Orientation::Horizontal, 0);
thread_box.pack_start(&num_threads_label, false, false, 3);
thread_box.pack_start(&num_threads, true, true, 3);
left_panel.pack_start(&samples_box, false, true, 3);
left_panel.pack_start(&sampler_box, false,... | code_fim | hard | {
"lang": "rust",
"repo": "alexxbb/sprios",
"path": "/src/sprios/src/app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ainevsia/Leetcode-Rust path: /64. Minimum Path Sum/src/main.rs
fn main() {
assert_eq!(Solution::min_path_sum(vec![
vec![1,3,1],
vec![1,5,1],
vec![4,2,1]
]), 7);
}
<|fim_suffix|> #[test]
fn basic() {
assert_eq!(Solution::min_path_sum(vec![
... | code_fim | hard | {
"lang": "rust",
"repo": "Ainevsia/Leetcode-Rust",
"path": "/64. Minimum Path Sum/src/main.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::min_path_sum(vec![
vec![1,3,1],
vec![1,5,1],
vec![4,2,1]
]), 7);
assert_eq!(Solution::min_path_sum(vec![
vec![1],
]), 1);
}
}<|fim_prefix|>// repo: Ainevsia/Leetcode-Rust path: /64. Minimum Path Sum/s... | code_fim | medium | {
"lang": "rust",
"repo": "Ainevsia/Leetcode-Rust",
"path": "/64. Minimum Path Sum/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use crate::*;
#[test]
fn basic() {
assert_eq!(Solution::min_path_sum(vec![
vec![1,3,1],
vec![1,5,1],
vec![4,2,1]
]), 7);
assert_eq!(Solution::min_path_sum(vec![
vec![1],
]), 1);
}
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "Ainevsia/Leetcode-Rust",
"path": "/64. Minimum Path Sum/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn fixture_shapes(name: &str) -> (Polygon<f64>, Polygon<f64>) {
let path = format!("./fixtures/{}", name);
let shapes = match load_fixture_from_path(&path) {
GeoJson::FeatureCollection(collection) => collection.features,
_ => panic!("Fixture is not a feature collection"),
}... | code_fim | hard | {
"lang": "rust",
"repo": "21re/rust-geo-booleanop",
"path": "/tests/src/helper.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// ----------------------------------------------------------------------------
// Misc (plotting)
// ----------------------------------------------------------------------------
/// Wrapper around the Python plotting script to visualize test cases.
pub fn plot_generic_test_case(test_case_file: &str) {
... | code_fim | hard | {
"lang": "rust",
"repo": "21re/rust-geo-booleanop",
"path": "/tests/src/helper.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 21re/rust-geo-booleanop path: /tests/src/helper.rs
use geo_booleanop::boolean::BooleanOp;
use geo::{Coord, MultiPolygon, Polygon};
use geojson::{Feature, GeoJson, Geometry, Value};
use serde_json::{json, Map};
use std::convert::TryInto;
use std::fs::File;
use std::io::prelude::*;
use std::ite... | code_fim | hard | {
"lang": "rust",
"repo": "21re/rust-geo-booleanop",
"path": "/tests/src/helper.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: x4e/JVM4J path: /src/main/rust/lib.rs
mod jvmti;
mod jvm;
mod jni;
#[macro_use]
extern crate rs_jvm_bindings;
use rs_jvm_bindings::jni::{JavaVM, JNI_VERSION_1_8, jlong, JNIEnv, jobject, JNI_OK};
use rs_jvm_bindings::utils::*;
use std::os::raw::{c_int, c_void};
use std::ptr::null_mut;
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "x4e/JVM4J",
"path": "/src/main/rust/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub unsafe extern "system" fn Java_dev_binclub_jvm4j_JVM4J_getJvmti0(
_env: *mut JNIEnv, _this: jobject,
vm: jlong
) -> jlong {
let vm: *mut JavaVM = vm as *mut JavaVM;
let mut jvmti_ptr: *mut c_void = null_mut();
{
let result = (**vm).GetEnv.unwrap()(vm, jvmti_ptr.borrow_mut(), JVMTI_... | code_fim | hard | {
"lang": "rust",
"repo": "x4e/JVM4J",
"path": "/src/main/rust/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let character = if scancode_idx < 58 {
let shift_idx = if self.capslock ^ self.shift { 1 } else { 0 };
SCANCODES[scancode_idx as usize][shift_idx]
} else {
'\0'
};
KeyEvent {
character: character,
pressed: scancode < 0x7F,
scancode: scancode
}
}
pub fn handle_keyboard_inter... | code_fim | hard | {
"lang": "rust",
"repo": "Lucas-Developer/park_os",
"path": "/src/io/keyboard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lucas-Developer/park_os path: /src/io/keyboard.rs
use io::port::{Io, Port};
#[derive(Debug)]
pub struct KeyEvent {
pub character: char,
pub pressed: bool,
pub scancode: u8
}
static SCANCODES: [[char; 2]; 58] = [
['\0', '\0'],
['\x1B', '\x1B'],
['1', '!'],
['2', '@'],
['3', '£'],
['4'... | code_fim | hard | {
"lang": "rust",
"repo": "Lucas-Developer/park_os",
"path": "/src/io/keyboard.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn init_keyboard(&self) {
unsafe {
let keyb_port : Port<u8> = Port::new(0x64);
let data_port : Port<u8> = Port::new(0x60);
while (keyb_port.read() & 0x1) == 1 {
println!("empty keyboard!");
data_port.read();
}
}
}
fn parse_scancode(&mut self, scancode:u8) -> KeyEvent {
le... | code_fim | hard | {
"lang": "rust",
"repo": "Lucas-Developer/park_os",
"path": "/src/io/keyboard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn index_of(&self, pattern: &String) -> Option<usize> {
None
}
}<|fim_prefix|>// repo: xanahopper/leetcode path: /src/algorithm/kmp.rs
pub trait KmpSearch {
type T;
fn index_of(&self, pattern: &Self::T) -> Option<usize>;
}
<|fim_middle|>impl KmpSearch for str {
type T = Stri... | code_fim | easy | {
"lang": "rust",
"repo": "xanahopper/leetcode",
"path": "/src/algorithm/kmp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xanahopper/leetcode path: /src/algorithm/kmp.rs
pub trait KmpSearch {
type T;
fn index_of(&self, pattern: &Self::T) -> Option<usize>;
}
<|fim_suffix|> fn index_of(&self, pattern: &String) -> Option<usize> {
None
}
}<|fim_middle|>impl KmpSearch for str {
type T = Stri... | code_fim | easy | {
"lang": "rust",
"repo": "xanahopper/leetcode",
"path": "/src/algorithm/kmp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl KmpSearch for str {
type T = String;
fn index_of(&self, pattern: &String) -> Option<usize> {
None
}
}<|fim_prefix|>// repo: xanahopper/leetcode path: /src/algorithm/kmp.rs
pub trait KmpSearch {
type T;
<|fim_middle|> fn index_of(&self, pattern: &Self::T) -> Option<usize>... | code_fim | medium | {
"lang": "rust",
"repo": "xanahopper/leetcode",
"path": "/src/algorithm/kmp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: notmarek/horisan path: /src/helpers.rs
use crate::overdrive::{Drive, GoogleDrive};
use crate::structs::*;
use anitomy::{Anitomy, ElementCategory};
use google_drive3;
use serde::Serialize;
use std::cmp::Ordering;
use std::fs;
use std::lazy::SyncLazy;
static ANIME: SyncLazy<Vec<AnimeInfo... | code_fim | hard | {
"lang": "rust",
"repo": "notmarek/horisan",
"path": "/src/helpers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn file_sort(a: &ParsedFile, b: &ParsedFile) -> Ordering {
if a.r#type.as_ref().unwrap() == &"file".to_string()
&& b.r#type.as_ref().unwrap() == &"file".to_string()
&& a.anime.as_ref().unwrap_or(&"~~~".to_string())
== b.anime.as_ref().unwrap_or(&"~~~".to_string())
... | code_fim | hard | {
"lang": "rust",
"repo": "notmarek/horisan",
"path": "/src/helpers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MouseButton {
/// Returns `true` if this is the left mouse button.
#[inline(always)]
pub fn is_left(self) -> bool {
self == MouseButton::Left
}
/// Returns `true` if this is the right mouse button.
#[inline(always)]
pub fn is_right(self) -> bool {
self == ... | code_fim | hard | {
"lang": "rust",
"repo": "lupyuen/druid-embedded",
"path": "/druid-shell/src/mouse.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns `true` if this is the right mouse button.
#[inline(always)]
pub fn is_right(self) -> bool {
self == MouseButton::Right
}
}
//NOTE: this currently only contains cursors that are included by default on
//both Windows and macOS. We may want to provide polyfills for variou... | code_fim | hard | {
"lang": "rust",
"repo": "lupyuen/druid-embedded",
"path": "/druid-shell/src/mouse.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lupyuen/druid-embedded path: /druid-shell/src/mouse.rs
// Copyright 2019 The xi-editor 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://ww... | code_fim | hard | {
"lang": "rust",
"repo": "lupyuen/druid-embedded",
"path": "/druid-shell/src/mouse.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: risooonho/kludgine path: /src/shape/path.rs
use crate::{
math::{Point, Raw, Scale, Scaled, ScreenScale},
scene::Target,
shape::{Fill, Stroke},
KludgineError, KludgineResult,
};
use lyon_tessellation::path::{builder::PathBuilder as _, PathEvent as LyonPathEvent};
pub type Endpoin... | code_fim | hard | {
"lang": "rust",
"repo": "risooonho/kludgine",
"path": "/src/shape/path.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Path<Scaled> {
pub(crate) async fn translate_and_convert_to_device(
&self,
location: Point<f32, Scaled>,
scene: &Target,
) -> Path<Raw> {
let effective_scale = scene.scale_factor().await;
let location = scene.offset_point(location).await;
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "risooonho/kludgine",
"path": "/src/shape/path.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: giodamelio/little_boxes path: /vendor/windows-sys/src/Windows/Win32/System/Ole/mod.rs
ffi::c_void;
pub type IProvideClassInfo2 = *mut ::core::ffi::c_void;
pub type IProvideMultipleClassInfo = *mut ::core::ffi::c_void;
pub type IProvideRuntimeContext = *mut ::core::ffi::c_void;
pub type IQuickAct... | code_fim | hard | {
"lang": "rust",
"repo": "giodamelio/little_boxes",
"path": "/vendor/windows-sys/src/Windows/Win32/System/Ole/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: giodamelio/little_boxes path: /vendor/windows-sys/src/Windows/Win32/System/Ole/mod.rs
const super::super::Foundation:: DECIMAL , psout : *mut i16 ) -> ::windows_sys::core::HRESULT );
#[cfg(feature = "Win32_System_Com")]
::windows_targets::link ! ( "oleaut32.dll""system" #[doc = "*Required featur... | code_fim | hard | {
"lang": "rust",
"repo": "giodamelio/little_boxes",
"path": "/vendor/windows-sys/src/Windows/Win32/System/Ole/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> *self
}
}
#[repr(C)]
#[doc = "*Required features: `\"Win32_System_Ole\"`, `\"Win32_Foundation\"`, `\"Win32_Graphics_Gdi\"`, `\"Win32_UI_Controls\"`, `\"Win32_UI_WindowsAndMessaging\"`*"]
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_Controls", feat... | code_fim | hard | {
"lang": "rust",
"repo": "giodamelio/little_boxes",
"path": "/vendor/windows-sys/src/Windows/Win32/System/Ole/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/hermes path: /unsupported/juno/crates/juno/src/sema/decl_collector.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::collections::hash... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hermes",
"path": "/unsupported/juno/crates/juno/src/sema/decl_collector.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match root {
Node::FunctionDeclaration(ast::FunctionDeclaration { body, .. })
| Node::FunctionExpression(ast::FunctionExpression { body, .. }) => {
self.new_scope();
// Visit the children of the body, since we don't want to associate a
... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hermes",
"path": "/unsupported/juno/crates/juno/src/sema/decl_collector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Associate the active scope with the specified AST node, pop the previous
/// scope from the stack and make it active.
fn close_scope(&mut self, ptr: &'gc Node<'gc>) {
let decls = self.scope_stack.pop().unwrap();
if !decls.is_empty() {
self.scopes.insert(NodePtr:... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hermes",
"path": "/unsupported/juno/crates/juno/src/sema/decl_collector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fubarnetes/libjail-rs path: /src/process.rs
//! Jail-Specific extensions to the `std::process` module
use crate::{JailError, RunningJail};
use log::trace;
use std::os::unix::process::CommandExt;
use std::process;
/// Extension to the `std::process::Command` builder to run the command in a
/// j... | code_fim | medium | {
"lang": "rust",
"repo": "fubarnetes/libjail-rs",
"path": "/src/process.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> trace!("process::Command::jail({:?}, jail={:?})", self, jail);
let jail = *jail;
unsafe {
self.pre_exec(move || {
trace!("pre_exec handler: attaching");
jail.attach().map_err(|err| match err {
JailError::JailAttachErro... | code_fim | medium | {
"lang": "rust",
"repo": "fubarnetes/libjail-rs",
"path": "/src/process.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn do_echo<T, I, E>(radio: &mut T, mut buff: &mut [u8], mut info: &mut I, options: EchoOptions) -> Result<usize, BlockingError<E>>
where
T: Receive<Info=I, Error=E> + Transmit<Error=E> + Power<Error=E> + DelayUs<u32, Error=E>,
I: ReceiveInfo + std::fmt::Debug,
E: std::fmt::Debug,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "toyatech/embedded-radio",
"path": "/src/helpers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.