text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> components::App::run(fill![]).expect("error running application");
}<|fim_prefix|>// repo: ruza-net/eru path: /src/main.rs
#[macro_use]
mod utils;
mod styles;
mod behavior;
mod components;
mod model;
use iced::Application;
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "ruza-net/eru",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hawkw/async-workshop path: /vendor/pin-project/tests/ui/cfg/tuple-struct.rs
// compile-fail
use pin_project::pin_project;
<|fim_suffix|>#[pin_project]
pub struct TupleStruct(
#[cfg(not(any()))] //~ ERROR `cfg` attributes on the field of tuple structs are not supported
#[pin]
Foo,
... | code_fim | medium | {
"lang": "rust",
"repo": "hawkw/async-workshop",
"path": "/vendor/pin-project/tests/ui/cfg/tuple-struct.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[pin_project]
pub struct TupleStruct(
#[cfg(not(any()))] //~ ERROR `cfg` attributes on the field of tuple structs are not supported
#[pin]
Foo,
#[cfg(any())]
#[pin]
Bar,
);
fn main() {}<|fim_prefix|>// repo: hawkw/async-workshop path: /vendor/pin-project/tests/ui/cfg/tuple-struc... | code_fim | medium | {
"lang": "rust",
"repo": "hawkw/async-workshop",
"path": "/vendor/pin-project/tests/ui/cfg/tuple-struct.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<C: HttpClient + Clone + Send> SagaClientImpl<C> {
pub fn new(client: C, url: String) -> Self {
Self { client, url }
}
}
impl<C: HttpClient + Clone> SagaClient for SagaClientImpl<C> {
fn update_order_states(&self, order_state_updates: Vec<OrderStateUpdate>) -> Box<Future<Item = ()... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/billing",
"path": "/src/client/saga/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/billing path: /src/client/saga/mod.rs
mod error;
mod types;
use failure::Fail;
use futures::{prelude::*, Future};
use hyper::{Headers, Method};
use stq_http::client::HttpClient;
pub use self::error::*;
pub use self::types::OrderStateUpdate;
pub trait SagaClient: Send + Sync + 'sta... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/billing",
"path": "/src/client/saga/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<C: HttpClient + Clone> SagaClient for SagaClientImpl<C> {
fn update_order_states(&self, order_state_updates: Vec<OrderStateUpdate>) -> Box<Future<Item = (), Error = Error> + Send> {
let SagaClientImpl { client, url } = self.clone();
let fut = serde_json::to_string(&order_state_up... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/billing",
"path": "/src/client/saga/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alerdenisov/unrust path: /src/world/processor.rs
use engine::{ComponentArena, Material, Mesh};
use std::marker::PhantomData;
use world::type_watcher::{GameObjectComponentPair, TypeWatcherBuilder, Watcher};
use world::{ComponentBased, GameObject, Handle, World};
use engine::Component;
use std::c... | code_fim | hard | {
"lang": "rust",
"repo": "alerdenisov/unrust",
"path": "/src/world/processor.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn apply_materials(&self, &Vec<Rc<Material>>) {}
}
pub trait IProcessorBuilder {
fn new_processor(&self, arena: &Rc<ComponentArena>) -> Arc<Component>;
fn register_watchers(&self, TypeWatcherBuilder) -> TypeWatcherBuilder;
}
pub struct ProcessorBuilder<T> {
marker: PhantomData<T>,
c... | code_fim | hard | {
"lang": "rust",
"repo": "alerdenisov/unrust",
"path": "/src/world/processor.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaisawind/raspberrypi path: /rust/blinking_led/src/main.rs
extern crate sysfs_gpio;
extern crate ctrlc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;
use sysfs_gpio::{Direction, Pin};
<|fim_suffix|> let led_pin = Pin::new... | code_fim | hard | {
"lang": "rust",
"repo": "kaisawind/raspberrypi",
"path": "/rust/blinking_led/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let led_pin = Pin::new(26); // number depends on chip, etc.
led_pin.with_exported(|| {
sleep(Duration::from_millis(80));
led_pin.set_direction(Direction::Out)?;
while running.load(Ordering::SeqCst) {
led_pin.set_value(1)?;
sleep(Duration::from_m... | code_fim | hard | {
"lang": "rust",
"repo": "kaisawind/raspberrypi",
"path": "/rust/blinking_led/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> led_pin.with_exported(|| {
sleep(Duration::from_millis(80));
led_pin.set_direction(Direction::Out)?;
while running.load(Ordering::SeqCst) {
led_pin.set_value(1)?;
sleep(Duration::from_millis(200));
led_pin.set_value(0)?;
sleep(Dur... | code_fim | hard | {
"lang": "rust",
"repo": "kaisawind/raspberrypi",
"path": "/rust/blinking_led/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: killercup/rust-analyzer path: /crates/libsyntax2/src/lib.rs
//! An experimental implementation of [Rust RFC#2256 libsyntax2.0][rfc#2256].
//!
//! The intent is to be an IDE-ready parser, i.e. one that offers
//!
//! - easy and fast incremental re-parsing,
//! - graceful handling of errors, and
/... | code_fim | hard | {
"lang": "rust",
"repo": "killercup/rust-analyzer",
"path": "/crates/libsyntax2/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn reparser(node: SyntaxNodeRef) -> Option<fn(&mut Parser)> {
let res = match node.kind() {
BLOCK => grammar::block,
NAMED_FIELD_DEF_LIST => grammar::named_field_def_list,
_ => return None,
};
Some(res)
}
}
pub /*(meh)*/ fn replace_range... | code_fim | hard | {
"lang": "rust",
"repo": "killercup/rust-analyzer",
"path": "/crates/libsyntax2/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // parasail
let matrix = Matrix::new(MatrixType::IdentityWithPenalty);
let profile = Profile::new(q.as_bytes(), &matrix);
let parasail_score = global_alignment_score(&profile, r.as_bytes(), 2, 1);
let r_padded = PaddedBytes::from_bytes::<NucMatrix>(r.as_bytes(), 20... | code_fim | hard | {
"lang": "rust",
"repo": "jianshu93/block-aligner",
"path": "/examples/nanopore_accuracy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jianshu93/block-aligner path: /examples/nanopore_accuracy.rs
#[cfg(not(feature = "simd_avx2"))]
fn main() {}
#[cfg(feature = "simd_avx2")]
fn test(file_name: &str, min_size: usize, max_size: usize, verbose: bool) -> (usize, f64, usize) {
use parasailors::{Matrix, *};
use block_aligner:... | code_fim | hard | {
"lang": "rust",
"repo": "jianshu93/block-aligner",
"path": "/examples/nanopore_accuracy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "simd_avx2")]
fn main() {
use std::env;
let arg1 = env::args().skip(1).next();
let verbose = arg1.is_some() && arg1.unwrap() == "-v";
let paths = ["data/real.illumina.b10M.txt", "data/real.ont.b10M.txt", "data/sequences.txt"];
let names = ["illumina", "nanopore 1kbp", ... | code_fim | medium | {
"lang": "rust",
"repo": "jianshu93/block-aligner",
"path": "/examples/nanopore_accuracy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Herbstein/aoc2020 path: /src/day06.rs
use std::collections::BTreeSet;
type Group = Vec<BTreeSet<char>>;
fn parse_inclusive_group(s: &str) -> Group {
s.lines().map(|l| l.trim().chars().collect()).collect()
}
<|fim_suffix|>#[aoc_generator(day6)]
fn generator(input: &str) -> Vec<Group> {
... | code_fim | medium | {
"lang": "rust",
"repo": "Herbstein/aoc2020",
"path": "/src/day06.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> s.split("\n\n").map(|s| parse_inclusive_group(s.trim()))
}
#[aoc_generator(day6)]
fn generator(input: &str) -> Vec<Group> {
parse_inclusive_groups(input.trim()).collect()
}
#[aoc(day6, part1)]
pub fn first(input: &[Group]) -> usize {
input
.iter()
.map(|g| {
g.ite... | code_fim | medium | {
"lang": "rust",
"repo": "Herbstein/aoc2020",
"path": "/src/day06.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day6, part2)]
pub fn second(input: &[Group]) -> usize {
input
.iter()
.map(|g| {
let mut iter = g.iter();
let first = iter.next().unwrap().clone();
iter.fold(first, |h, p| h.intersection(&p).cloned().collect())
.len()
})... | code_fim | hard | {
"lang": "rust",
"repo": "Herbstein/aoc2020",
"path": "/src/day06.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let [img_w, img_h] = frame.swapchain_image().dimensions();
let graphics = &model.graphics;
// Dynamic state.
let viewport = Viewport {
origin: [0.0, 0.0],
dimensions: [img_w as _, img_h as _],
depth_range: 0.0..1.0,
};
let dynamic_state = DynamicState {
... | code_fim | hard | {
"lang": "rust",
"repo": "freesig/pose_designer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: freesig/pose_designer path: /src/main.rs
e vulkano;
use vulkano_shaders;
use nuitrack_rs as nuitrack;
use termion;
use nuitrack_pose_estimation as npe;
use serde_json;
use clap;
mod controls;
mod poses;
mod joints;
use self::joints::j2d_to_j;
use self::nannou::prelude::*;
use self::vulkano::b... | code_fim | hard | {
"lang": "rust",
"repo": "freesig/pose_designer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let graphics = Graphics {
render_pass,
pipeline,
framebuffers,
sampler,
};
let current = Current {
skeletons: None,
debug_poses: None,
debug_skeletons: None,
depth: None,
color: None,
rgba_image,
depth_ima... | code_fim | hard | {
"lang": "rust",
"repo": "freesig/pose_designer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbStavola/advent_rust path: /src/problem_two.rs
fn main() {
let input = include_str!("../problems/problem_two.txt");
let mut paper_length = 0;
let mut ribbon_length = 0;
<|fim_suffix|> let mut slack = if side_one > side_two { side_one } else { side_two };
if slack < s... | code_fim | hard | {
"lang": "rust",
"repo": "mbStavola/advent_rust",
"path": "/src/problem_two.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dimen_max: &u32 = dimens.iter().max().unwrap();
let ribbon_wrap = 2 * (dimens[0] + dimens[1] + dimens[2] - dimen_max);
(dimens[0] * dimens[1] * dimens[2]) + ribbon_wrap
}<|fim_prefix|>// repo: mbStavola/advent_rust path: /src/problem_two.rs
fn main() {
let input = include_str!("... | code_fim | medium | {
"lang": "rust",
"repo": "mbStavola/advent_rust",
"path": "/src/problem_two.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn length_of_paper(dimens: &Vec<u32>) -> u32 {
//2*l*w + 2*w*h + 2*h*l
let side_one = dimens[0] * dimens[1];
let side_two = dimens[1] * dimens[2];
let side_three = dimens[0] * dimens[2];
let mut slack = if side_one > side_two { side_one } else { side_two };
if slack < side_... | code_fim | hard | {
"lang": "rust",
"repo": "mbStavola/advent_rust",
"path": "/src/problem_two.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self_return_type.node == other_return_type.node;
}
}
} else if let Some(self_data) = self.get_hashmap() {
if let Some(other_data) = other.get_hashmap() {
if self_data.len() == other_data.len() {
... | code_fim | hard | {
"lang": "rust",
"repo": "sflynlang/sflynlang-interpreter",
"path": "/parser/ast/data_types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sflynlang/sflynlang-interpreter path: /parser/ast/data_types.rs
use crate::ast::Node;
use std::{collections::HashMap, fmt};
pub type DataType = Node<DataTypes>;
impl DataType {
pub fn to_string(&self) -> String {
self.node.to_string()
}
}
impl fmt::Display for DataType {
f... | code_fim | hard | {
"lang": "rust",
"repo": "sflynlang/sflynlang-interpreter",
"path": "/parser/ast/data_types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nov11/rust-pl path: /concurrency/src/main.rs
extern crate num;
extern crate image;
use image::ColorType;
use image::png::PNGEncoder;
use std::fs::File;
use std::str::FromStr;
use std::io::Write;
use num::Complex;
fn escape_time(c: Complex<f64>, limit: u32) -> Option<u32> {
let mut z = Com... | code_fim | hard | {
"lang": "rust",
"repo": "Nov11/rust-pl",
"path": "/concurrency/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// render(&mut pixels, bounds, upper_left, lower_right);
let threads = 8;
let rows_per_band = (bounds.1 + threads - 1) / threads;
let bands: Vec<&mut [u8]> = pixels.chunks_mut(rows_per_band * bounds.0).collect();
crossbeam::scope(|spawner| {
for (i, band) in bands.into_iter().... | code_fim | hard | {
"lang": "rust",
"repo": "Nov11/rust-pl",
"path": "/concurrency/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sql_page = warp::path::end().map(move || {
let mut params = Parameters::new();
let query = select(("country.name".as_("name"), "COUNT(*)".as_("count")))
.from(
"Country"
.as_("country")
.inner_join("City".as_("city"))
.on("city.country_id = countr... | code_fim | hard | {
"lang": "rust",
"repo": "Factisio/factisio",
"path": "/server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Factisio/factisio path: /server/src/main.rs
#![allow(missing_docs)]
#![allow(unused_variables)]
mod fixtures;
use fixtures::starwars::schema::{Database, Query};
use handlebars::Handlebars;
use juniper::{EmptyMutation, EmptySubscription, RootNode};
use scooby::postgres::{select, Aliasable, Join... | code_fim | hard | {
"lang": "rust",
"repo": "Factisio/factisio",
"path": "/server/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sql_page_print = SqlPagePrint { query: query };
match handlebars.render("template_page_sql", &sql_page_print) {
Ok(s) => Response::builder()
.header("content-type", "text/html")
.body(format!("{}", s)),
Err(e) => Response::builder()
.header("content-type", ... | code_fim | hard | {
"lang": "rust",
"repo": "Factisio/factisio",
"path": "/server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pprobst/rust-stuff path: /ch10_modules/use.rs
/*
* The use declaration can be used to bind a full path to a new name, for easier access.
* It is often used like this:
*/
<|fim_suffix|>fn main () {
my_first_function();
}<|fim_middle|> // extern crate deeply; // normally, this would exist... | code_fim | medium | {
"lang": "rust",
"repo": "pprobst/rust-stuff",
"path": "/ch10_modules/use.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main () {
my_first_function();
}<|fim_prefix|>// repo: pprobst/rust-stuff path: /ch10_modules/use.rs
/*
* The use declaration can be used to bind a full path to a new name, for easier access.
* It is often used like this:
*/
// extern crate deeply; // normally, this would exist and not be co... | code_fim | medium | {
"lang": "rust",
"repo": "pprobst/rust-stuff",
"path": "/ch10_modules/use.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut registry = CommandVersionRegistry::new(Path::new("not-important"));
assert!(registry.state.is_empty());
registry.add(CommandVersion::new(
"the-command",
"42",
Path::new("/path/to/the-command-v42"),
))?;
assert!(registry.st... | code_fim | hard | {
"lang": "rust",
"repo": "dotboris/alt",
"path": "/src/command_version.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> registry.add(CommandVersion::new(
"the-command",
"43",
Path::new("/path/to/the-command-v43"),
))?;
assert_eq!(
registry.state,
HashMap::from([(
"the-command".to_string(),
HashMap::from([
... | code_fim | hard | {
"lang": "rust",
"repo": "dotboris/alt",
"path": "/src/command_version.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dotboris/alt path: /src/command_version.rs
=> {
Ok(Self::new(path))
}
_ => Err(error),
})
}
pub fn save(&self) -> Result<(), SaveError> {
if let Some(parent) = self.path.parent() {
fs::create_dir_all(parent)?;
}... | code_fim | hard | {
"lang": "rust",
"repo": "dotboris/alt",
"path": "/src/command_version.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rt,
api_port: None,
k_val: 8,
async_poll_interval: 300,
initial_neighbors: vec![]
}
}
}<|fim_prefix|>// repo: aaliang/ailmedak path: /src/config.rs
pub struct Config {
pub network_port: u16,
pub api_port: Option<u16>,
pub k_val: usize,
pub async_poll_... | code_fim | medium | {
"lang": "rust",
"repo": "aaliang/ailmedak",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aaliang/ailmedak path: /src/config.rs
pub struct Config {
pub network_port: u16,
pub api_port: Option<u16>,
pub k_val: usize,
pub async_poll_interval: u32,
pub initial_neighbors: Vec<String>
}
impl Config {
//creates a Config with the network port set to port, all<|fim_suf... | code_fim | medium | {
"lang": "rust",
"repo": "aaliang/ailmedak",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: christianpoulsen/edge-offloading path: /client-based/src/controller.rs
use std::{thread};
use std::net::{TcpListener, TcpStream, Shutdown, SocketAddrV4};
use std::io::{Read, Write, Error};
use std::str::from_utf8;
use crate::helper;
use crate::server::{Server};
pub struct Controller {
port... | code_fim | hard | {
"lang": "rust",
"repo": "christianpoulsen/edge-offloading",
"path": "/client-based/src/controller.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.num_of_servers += 1;
}
}
fn start_servers<'a>(port: i32, num: i32) -> Vec<Server> {
if DEBUG { println!("Controller: Starting the {} servers...", num) };
let mut servers: Vec<Server> = Vec::new();
let mut port = port;
for _i in 0..num {
port += 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "christianpoulsen/edge-offloading",
"path": "/client-based/src/controller.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wonchulee/tide-example path: /src/templates/articles.rs
use crate::records::{Article, PartialArticle};
use askama::Template;
#[derive(Template)]
#[template(path = "articles/form.html")]
pub struct ArticleForm<'a> {
title: &'a str,
text: &'a str,
action: String,
}
impl<'a> ArticleFo... | code_fim | hard | {
"lang": "rust",
"repo": "wonchulee/tide-example",
"path": "/src/templates/articles.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // pub fn for_article(article: &'a Article) -> Self {
// Self {
// title: &article.title,
// text: &article.text,
// action: format!("/articles/{}", article.id),
// }
// }
}
#[derive(Template)]
#[template(path = "articles/index.html")]
pub struc... | code_fim | hard | {
"lang": "rust",
"repo": "wonchulee/tide-example",
"path": "/src/templates/articles.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jiegec/rcore_plus path: /kernel/src/arch/x86_64/interrupt/mod.rs
pub mod consts;
mod handler;
pub use self::handler::*;
use crate::memory::phys_to_virt;
use apic::*;
use trapframe::{TrapFrame, UserContext};
#[inline(always)]
pub unsafe fn enable() {
x86_64::instructions::interrupts::enable... | code_fim | hard | {
"lang": "rust",
"repo": "jiegec/rcore_plus",
"path": "/kernel/src/arch/x86_64/interrupt/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline(always)]
pub fn ack(_irq: usize) {
let mut lapic = unsafe { XApic::new(phys_to_virt(LAPIC_ADDR)) };
lapic.eoi();
}
pub fn get_trap_num(context: &UserContext) -> usize {
context.trap_num
}
pub fn wait_for_interrupt() {
x86_64::instructions::interrupts::enable_interrupts_and_hlt()... | code_fim | hard | {
"lang": "rust",
"repo": "jiegec/rcore_plus",
"path": "/kernel/src/arch/x86_64/interrupt/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline(always)]
pub fn enable_irq(irq: usize) {
let mut ioapic = unsafe { IoApic::new(phys_to_virt(IOAPIC_ADDR as usize)) };
ioapic.set_irq_vector(irq as u8, (consts::IrqMin + irq) as u8);
ioapic.enable(irq as u8, 0);
}
pub fn timer() {
crate::trap::timer();
}
#[inline(always)]
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "jiegec/rcore_plus",
"path": "/kernel/src/arch/x86_64/interrupt/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match doc_headers(&buffer[..]) {
IResult::Done(body, hdrs) => {
res.headers_mut().insert(
"Content-Type",
hdrs.content_type.conten... | code_fim | hard | {
"lang": "rust",
"repo": "cite-reader/rust-http-server",
"path": "/src/fastcgi/driver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> buffer.len() - rest.len()
},
IResult::Error(_e) => {
unimplemented!()
},
IResult::Incomplete(_) => 0
}
};
reader.consume(consume);
... | code_fim | hard | {
"lang": "rust",
"repo": "cite-reader/rust-http-server",
"path": "/src/fastcgi/driver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cite-reader/rust-http-server path: /src/fastcgi/driver.rs
//! A driver for FastCGI connections
use cgi;
use cgi::parser::doc_headers;
use config::Config;
use errors::{Result, Error};
use fastcgi::{Record, Content, EndRequest, protocol_status};
use fastcgi::parser::record;
use fastcgi::serialize... | code_fim | hard | {
"lang": "rust",
"repo": "cite-reader/rust-http-server",
"path": "/src/fastcgi/driver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpichard/rustfx path: /src/suites/message.rs
extern crate libc;
use libc::*;
use suites::core::*;
/*#include "ofxMessage.h"
typedef struct OfxMessageSuiteV2 {
OfxStatus (*message)(void *handle,
const char *messageType,
const char *messageId,
const char *format,
... | code_fim | medium | {
"lang": "rust",
"repo": "cpichard/rustfx",
"path": "/src/suites/message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub static OFX_MESSAGE_SUITE_V2
: OfxMessageSuiteV2
= OfxMessageSuiteV2 {
message: c_message,
setPersistentMessage: c_set_persistent_message,
clearPersistentMessage: clear_persistent_message,
};<|fim_prefix|>// repo: cpichard/rustfx path: /src/sui... | code_fim | hard | {
"lang": "rust",
"repo": "cpichard/rustfx",
"path": "/src/suites/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guskovd/faiss-rs path: /src/index/flat.rs
//! Interface and implementation to Flat index type.
use super::*;
use crate::error::{Error, Result};
use std::mem;
use std::ptr;
/// Alias for the native implementation of a flat index.
pub type FlatIndex = FlatIndexImpl;
/// Native implementation o... | code_fim | hard | {
"lang": "rust",
"repo": "guskovd/faiss-rs",
"path": "/src/index/flat.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let index: FlatIndexImpl = index.into_flat().unwrap();
assert_eq!(index.is_trained(), true);
assert_eq!(index.ntotal(), 5);
let xb = index.xb();
assert_eq!(xb.len(), 8 * 5);
}
#[test]
fn index_clone() {
let mut index = FlatIndexImpl::new_l2(D).u... | code_fim | hard | {
"lang": "rust",
"repo": "guskovd/faiss-rs",
"path": "/src/index/flat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chengluyu/tapl-rust path: /src/context.rs
use std::collections::VecDeque;
use crate::termtype::TermType;
pub enum Binding {
// NameBind,
VarBind(TermType),
}
pub struct Context(pub VecDeque<(String, Binding)>);
impl Context {
pub fn new() -> Context {
Context(VecDeque::ne... | code_fim | hard | {
"lang": "rust",
"repo": "chengluyu/tapl-rust",
"path": "/src/context.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn remove_binding(&mut self, name: &String) {
let mut at = None;
for (index, (item, _)) in self.0.iter().enumerate() {
if item == name {
at = Some(index)
}
}
if let Some(at) = at {
self.0.remove(at);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "chengluyu/tapl-rust",
"path": "/src/context.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DataController for CmdlineController {
fn query(&self, model: Arc<DataModel>, _: Value) -> Result<Value> {
Ok(json!(&*model
.get::<CmdlineCollection>()
.context("Failed to read the kernel cmdline from the CmdlineCollector")?))
}
fn description(&self) -> St... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/lib/scrutiny/plugins/src/zbi/controller.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/security/lib/scrutiny/plugins/src/zbi/controller.rs
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::zbi::collection::{BootFsCollection... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/lib/scrutiny/plugins/src/zbi/controller.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn description(&self) -> String {
"Extracts the bootfs files from a ZBI".to_string()
}
fn usage(&self) -> String {
UsageBuilder::new()
.name("bootfs - Extracts bootfs files")
.summary("bootfs")
.description("Extracts the bootfs files from a ... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/lib/scrutiny/plugins/src/zbi/controller.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let root = tree.root();
let child = tree.get_by_ref(root.children()[0]).unwrap();
assert_eq!(child.name, "BoolValue");
assert_eq!(child.class, "BoolValue");
assert_eq!(child.properties.get("Value"), Some(&Variant::Bool(true)));
}<|fim_prefix|>// repo: Anaminus/rbx-dom path: /rbx_xml/... | code_fim | medium | {
"lang": "rust",
"repo": "Anaminus/rbx-dom",
"path": "/rbx_xml/tests/temp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(child.name, "BoolValue");
assert_eq!(child.class, "BoolValue");
assert_eq!(child.properties.get("Value"), Some(&Variant::Bool(true)));
}<|fim_prefix|>// repo: Anaminus/rbx-dom path: /rbx_xml/tests/temp.rs
//! Temporary tests while re-bootstrapping rbx_xml
use rbx_dom_weak::types::... | code_fim | hard | {
"lang": "rust",
"repo": "Anaminus/rbx-dom",
"path": "/rbx_xml/tests/temp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Anaminus/rbx-dom path: /rbx_xml/tests/temp.rs
//! Temporary tests while re-bootstrapping rbx_xml
use rbx_dom_weak::types::Variant;
<|fim_suffix|> let tree = rbx_xml::from_str_default(document).unwrap();
let root = tree.root();
let child = tree.get_by_ref(root.children()[0]).unwrap(... | code_fim | hard | {
"lang": "rust",
"repo": "Anaminus/rbx-dom",
"path": "/rbx_xml/tests/temp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RandomExplosion/lightbox_rs path: /src/conf.rs
use serde::{Deserialize, Serialize};
use log::{info, trace, warn, error};
use chrono::prelude::*;
const ALLOWED_PINS: [u8; 25] = [2,3,4,17,27,22,10,9,11,5,6,13,19,26,18,23,24,25,8,7,1,12,16,20,21];
/*
* This file contains the struct equiv... | code_fim | hard | {
"lang": "rust",
"repo": "RandomExplosion/lightbox_rs",
"path": "/src/conf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //TODO: Check all alarms for valid dates
for mut user in config.users {
//Check reminders
user.reminders = user.reminders.into_iter().filter(|reminder| {
if DateTime::parse_from_str(&reminder.light_on, "%d/%m").is_ok() {
true
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "RandomExplosion/lightbox_rs",
"path": "/src/conf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
gtk::init().unwrap_or_else(|_| panic!("Failed to initialize GTK."));
println!("Major: {}, Minor: {}", gtk::get_major_version(), gtk::get_minor_version());
let window = RenderingAPITestWindow::new(800, 500);
window.exit_on_close();
gtk::main();
}<|fim_prefix|>// repo: softd... | code_fim | hard | {
"lang": "rust",
"repo": "softdevteam/minimal-idiomatic-rust-gtk",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: softdevteam/minimal-idiomatic-rust-gtk path: /src/main.rs
#![cfg_attr(not(feature = "gtk_3_10"), allow(unused_variables, unused_mut))]
extern crate gtk;
extern crate cairo;
use std::rc::Rc;
use std::cell::RefCell;
use gtk::traits::*;
use gtk::signal::Inhibit;
use cairo::{Context, RectangleInt}... | code_fim | hard | {
"lang": "rust",
"repo": "softdevteam/minimal-idiomatic-rust-gtk",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn exit_on_close(&self) {
self.window.connect_delete_event(|_, _| {
gtk::main_quit();
Inhibit(true)
});
}
}
fn main() {
gtk::init().unwrap_or_else(|_| panic!("Failed to initialize GTK."));
println!("Major: {}, Minor: {}", gtk::get_major_version(), g... | code_fim | hard | {
"lang": "rust",
"repo": "softdevteam/minimal-idiomatic-rust-gtk",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!(message = "outgoing_task finished with an error. notifying the broker to remove the connection", %e);
let msg = Message::Client(client_id.clone(), ClientEvent::CloseSession);
broker_handle.send(msg).await?;
... | code_fim | hard | {
"lang": "rust",
"repo": "darobs/iotedge",
"path": "/mqtt/mqtt-broker/src/connection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: darobs/iotedge path: /mqtt/mqtt-broker/src/connection.rs
use std::net::SocketAddr;
use std::sync::Arc;
use std::time::Duration;
use futures_util::future::{select, Either};
use futures_util::pin_mut;
use futures_util::sink::{Sink, SinkExt};
use futures_util::stream::{Stream, StreamExt};
use lazy... | code_fim | hard | {
"lang": "rust",
"repo": "darobs/iotedge",
"path": "/mqtt/mqtt-broker/src/connection.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let mut input = String::new();
match std::io::stdin().read_line(&mut input) {
Ok(_) => match evaluate(input.trim().into()) {
Ok(val) => println!("The computed number is {}\n", val),
Err(error) => println!("error: {}", error),
},
Err(error) => println!("er... | code_fim | hard | {
"lang": "rust",
"repo": "siddharthborderwala/math-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Hello! Welcome to Arithmetic expression evaluator.");
println!("You can calculate value for expression such as 2*3+(4-5)+2^3/4.");
println!("Allowed numbers: positive, negative and decimals.");
println!("Supported operations: Add, Subtract, Multiply,Divide, PowerOf(^).");
println!("Ent... | code_fim | hard | {
"lang": "rust",
"repo": "siddharthborderwala/math-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: siddharthborderwala/math-rs path: /src/main.rs
use parse_math::ast;
use parse_math::parser::{ParseError, Parser};
fn evaluate(expr: String) -> Result<f64, ParseError> {
<|fim_suffix|>fn main() {
println!("Hello! Welcome to Arithmetic expression evaluator.");
println!("You can calculate valu... | code_fim | hard | {
"lang": "rust",
"repo": "siddharthborderwala/math-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Add the regolith tiles
for y in 3..height {
let mut row: Vec<Tile> = Vec::new();
for x in 0..width {
row.push(Tile {
position: (x, y),
texture_id: texture_map[&TileType::Regolith],
tile_t... | code_fim | hard | {
"lang": "rust",
"repo": "Robaire/rust-motherload",
"path": "/src/map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Robaire/rust-motherload path: /src/map.rs
use std::collections::HashMap;
extern crate gl;
use gl::types::{GLint, GLuint, GLvoid};
extern crate gl_util;
extern crate image;
/// Stores information on every tile in the world
pub struct Map {
tiles: Vec<Vec<Tile>>,
size: (u32, u32),
_... | code_fim | hard | {
"lang": "rust",
"repo": "Robaire/rust-motherload",
"path": "/src/map.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkomitee/krb5.rs path: /src/error.rs
extern crate libc;
use libc::{c_int};
use std::ffi::{NulError};
use std::string::FromUtf8Error;
use context::Context;
#[derive(Debug)]
pub enum Error {
Krb5(Krb5Error),
FromUtf8(FromUtf8Error),
Nul(NulError),
}
#[derive(Debug)]
pub struct Krb5... | code_fim | hard | {
"lang": "rust",
"repo": "mkomitee/krb5.rs",
"path": "/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
Error::FromUtf8(ref e) => e.description(),
Error::Nul(ref e) => e.description(),
Error::Krb5(ref e) => e.description(),
}
}
fn cause(&self) -> Option<&::std::error::Error> {
match *self {
Error::FromUtf8(ref e) =... | code_fim | hard | {
"lang": "rust",
"repo": "mkomitee/krb5.rs",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The relation between a node and its execution dependant.
#[derive(Debug, Display, Clone, PartialEq, Serialize, Deserialize, HtmlCodec, TextCodec, StripNode, SmartDefault, Read, Write)]
#[serde(crate = "common::serde")]
pub enum ExecutionDependantRelation {
#[default]
Assigns,
Alters,
D... | code_fim | easy | {
"lang": "rust",
"repo": "stencila/stencila",
"path": "/rust/schema/src/types/execution_dependant_relation.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stencila/stencila path: /rust/schema/src/types/execution_dependant_relation.rs
// Generated file; do not edit. See `schema-gen` crate.
<|fim_suffix|>/// The relation between a node and its execution dependant.
#[derive(Debug, Display, Clone, PartialEq, Serialize, Deserialize, HtmlCodec, TextCod... | code_fim | easy | {
"lang": "rust",
"repo": "stencila/stencila",
"path": "/rust/schema/src/types/execution_dependant_relation.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_part1_example2() {
assert_eq!(part1(&parse_input(include_str!("test2.txt"))), 33);
}
#[test]
fn test_part1_example3() {
assert_eq!(part1(&parse_input(include_str!("test3.txt"))), 35);
}
#[test]
fn test_part1_example4() {
assert_eq!(part1(&parse_input(include_s... | code_fim | hard | {
"lang": "rust",
"repo": "dhedegaard/adventofcode2019",
"path": "/aoc2019/src/day10/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dhedegaard/adventofcode2019 path: /aoc2019/src/day10/mod.rs
use std::collections::HashSet;
use std::f64::consts::PI;
use std::iter::FromIterator;
pub fn raw_input() -> String {
include_str!("input.txt").to_string()
}
pub fn parse_input(input: &str) -> HashSet<(isize, isize)> {
input
.s... | code_fim | hard | {
"lang": "rust",
"repo": "dhedegaard/adventofcode2019",
"path": "/aoc2019/src/day10/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_part1_example3() {
assert_eq!(part1(&parse_input(include_str!("test3.txt"))), 35);
}
#[test]
fn test_part1_example4() {
assert_eq!(part1(&parse_input(include_str!("test4.txt"))), 41);
}
#[test]
fn test_part1_example5() {
assert_eq!(part1(&parse_input(include_s... | code_fim | hard | {
"lang": "rust",
"repo": "dhedegaard/adventofcode2019",
"path": "/aoc2019/src/day10/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn print_result_frist(result: Result<i32>) {
match result {
Ok(o) => println!("multiplication_first: {:?}", o),
Err(e) => println!("Error: {:?}", e),
}
}
pub fn print_result_last(result: Result<i32>) {
match result {
Ok(n) => println!("multiplication_last: {:?}", ... | code_fim | hard | {
"lang": "rust",
"repo": "TianTianForever/Rust-Tutorial",
"path": "/twenty-four_days_of_rust/options_with_results.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TianTianForever/Rust-Tutorial path: /twenty-four_days_of_rust/options_with_results.rs
#![crate_type="lib"]
#![crate_name="options_with_results"]
use std::num::ParseIntError;
use std::result;
type Result<T> = std::result::Result<T, String>;
pub fn multiplication_first(vec: Vec<&str>) -> Result<i... | code_fim | hard | {
"lang": "rust",
"repo": "TianTianForever/Rust-Tutorial",
"path": "/twenty-four_days_of_rust/options_with_results.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn multiplication_last(vec: Vec<&str>) -> Result<i32> {
vec.last().ok_or("please use a vector with at least one element.".to_owned())
.and_then(|l| l.parse::<i32>()
.map_err(|e| e.to_string())
.map(|x| 2 * x))
}
pub fn print_result_frist(result: Result<i3... | code_fim | medium | {
"lang": "rust",
"repo": "TianTianForever/Rust-Tutorial",
"path": "/twenty-four_days_of_rust/options_with_results.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: botagar/keccakrs path: /src/keccak.rs
#![crate_type = "lib"]
#![crate_name = "keccakrs"]
// #![feature(use_extern_macros)]
#[macro_use] extern crate crunchy;
mod constants;
mod round;
mod keccak_f;
mod sponge;
mod padder;
<|fim_suffix|> pub fn hash(&mut self) -> Vec<u8> {
self.sponge.abso... | code_fim | hard | {
"lang": "rust",
"repo": "botagar/keccakrs",
"path": "/src/keccak.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Keccak {
pub fn new(rate: usize, capacity: usize) -> Keccak {
Keccak {
state: [0; 25],
sponge: Sponge::new(rate, capacity),
input_padder: Padder::new(rate),
data_queue: vec![]
}
}
pub fn injest(&mut self, input: &mut String) {
let mut input_as_bytes: Vec<u8... | code_fim | hard | {
"lang": "rust",
"repo": "botagar/keccakrs",
"path": "/src/keccak.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
loop {
unsafe {
let foo: libloading::Symbol<fn(i32, i32) -> i32> = lib.get(b"foo").unwrap();
let res = foo(6, 7);
println!("{}", res);
}
println!("Awaiting next change...");
let pkg = watch.next().unwrap();
lib = pkg.build().... | code_fim | medium | {
"lang": "rust",
"repo": "mitchmindtree/hotlib",
"path": "/examples/demo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>n!("{}", res);
}
println!("Awaiting next change...");
let pkg = watch.next().unwrap();
lib = pkg.build().unwrap().load().unwrap();
}
}<|fim_prefix|>// repo: mitchmindtree/hotlib path: /examples/demo.rs
fn main() {
let test_crate_path = std::path::Path::new(env!("CA... | code_fim | hard | {
"lang": "rust",
"repo": "mitchmindtree/hotlib",
"path": "/examples/demo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitchmindtree/hotlib path: /examples/demo.rs
fn main() {
let test_crate_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("test_crate")
.join("Cargo.toml");
println!("Begin watch<|fim_suffix|>
loop {
unsafe {
let foo: libloading::Symbol... | code_fim | medium | {
"lang": "rust",
"repo": "mitchmindtree/hotlib",
"path": "/examples/demo.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wycats/codespan path: /codespan/src/span.rs
use std::cmp::Ordering;
use std::{cmp, fmt};
use index::{ByteIndex, Index};
/// A region of code in a source file
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Ord, PartialOrd)]
#[cfg_attr(feature = "serialization", derive(Deserialize, Seriali... | code_fim | hard | {
"lang": "rust",
"repo": "wycats/codespan",
"path": "/codespan/src/span.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create a new span from a byte start and an offset
pub fn from_offset(start: I, off: I::Offset) -> Span<I> {
Span::new(start, start + off)
}
/// Return a new span with the low byte position replaced with the supplied byte position
///
/// ```rust
/// use codespan::{... | code_fim | hard | {
"lang": "rust",
"repo": "wycats/codespan",
"path": "/codespan/src/span.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Return a `Span` between the end of `self` to the beginning of `end`.
///
/// ```plain
/// self ~~~~~~~
/// end ~~~~~~~~
/// returns ~~~~~~~~~
/// ```
///
/// ```rust
/// use codespan::{ByteIndex, Span};
///
/// let a = Spa... | code_fim | hard | {
"lang": "rust",
"repo": "wycats/codespan",
"path": "/codespan/src/span.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
pub struct ActorHandle<A: Actor> {
sender: mpsc::Sender<(
A::MessageGroup,
oneshot::Sender<<A::MessageGroup as MessageGroup>::ReplyGroup>,
)>,
_actor: PhantomData<A>,
}
impl<A: Actor> ActorHandle<A> {
pub async fn send<M, R>(&self, msg: M) -> R
where
... | code_fim | hard | {
"lang": "rust",
"repo": "EthanYidongArchives/chikatetsu",
"path": "/src/actor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<A: Actor> ActorHandle<A> {
pub async fn send<M, R>(&self, msg: M) -> R
where
M: Message<Group = A::MessageGroup, Reply = R>,
R: Reply<Group = <A::MessageGroup as MessageGroup>::ReplyGroup>,
{
let (tx, rx) = oneshot::channel();
let _ = self.sender.send((msg.... | code_fim | hard | {
"lang": "rust",
"repo": "EthanYidongArchives/chikatetsu",
"path": "/src/actor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EthanYidongArchives/chikatetsu path: /src/actor.rs
use tokio::sync::*;
use async_trait::async_trait;
use std::marker::PhantomData;
use crate::message::*;
#[async_trait]
pub trait Actor: Sized + Send + 'static {
type MessageGroup: MessageGroup;
async fn handle_all(
&mut self,... | code_fim | medium | {
"lang": "rust",
"repo": "EthanYidongArchives/chikatetsu",
"path": "/src/actor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qdrant/qdrant path: /lib/segment/src/index/field_index/full_text_index/inverted_index.rs
use std::collections::{BTreeSet, HashMap};
use serde::{Deserialize, Serialize};
use super::posting_list::PostingList;
use super::postings_iterator::intersect_postings_iterator;
use crate::index::field_inde... | code_fim | hard | {
"lang": "rust",
"repo": "qdrant/qdrant",
"path": "/lib/segment/src/index/field_index/full_text_index/inverted_index.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.points_count -= 1;
for removed_token in removed_doc.tokens() {
// unwrap safety: posting list exists and contains the document id
let posting = self.postings.get_mut(*removed_token as usize).unwrap();
if let Some(vec) = posting {
ve... | code_fim | hard | {
"lang": "rust",
"repo": "qdrant/qdrant",
"path": "/lib/segment/src/index/field_index/full_text_index/inverted_index.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> env.assert_type(js_value, crate::sys::napi_valuetype_napi_number)?;
let mut value: i64 = 0;
napi_call_result!(crate::sys::napi_get_value_int64(
env.inner(),
js_value,
&mut value
))?;
Ok(value)
}
}
impl JSValue<'_> for bool... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/node-bindgen",
"path": "/nj-core/src/convert.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinyon/node-bindgen path: /nj-core/src/convert.rs
use libc::size_t;
use std::ptr;
use crate::sys::napi_value;
use crate::val::JsEnv;
use crate::NjError;
use crate::napi_call_result;
/// convert to JS object
pub trait TryIntoJs {
fn try_to_js(self, js_env: &JsEnv) -> Result<napi_value, Nj... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/node-bindgen",
"path": "/nj-core/src/convert.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use crate::sys::napi_get_array_length;
let mut length: u32 = 0;
napi_call_result!(napi_get_array_length(env.inner(), js_value, &mut length))?;
let mut elements = vec![];
for i in 0..length {
let js_element = env.get_element(js_value, i)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/node-bindgen",
"path": "/nj-core/src/convert.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(dead_code)]
pub fn show_a_mg(&self, relation: &Relation) {
println!("a_mg");
for m in relation.initial_retailers() {
for g in relation.all_products() {
print!("{}\t", self.a_mg[m][g]);
}
println!("");
}
}
}
im... | code_fim | hard | {
"lang": "rust",
"repo": "quangtung97-study/20191-software-economics-version2",
"path": "/src/rrgame.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.