text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> Ok(())
}
fn command(mut self) -> Result<()> {
loop {
let mut line = String::new();
let _ = self.reader.read_line(&mut line)?;
match line.trim() {
"heartbreak" => self.write(b"got\n")?,
"whoami" => {
let str = self.user.clone() + "\n";
self.write(str.as_bytes())?;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "redtankd/rust-test",
"path": "/net/std/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn command(mut self) -> Result<()> {
loop {
let mut line = String::new();
let _ = self.reader.read_line(&mut line)?;
match line.trim() {
"heartbreak" => self.write(b"got\n")?,
"whoami" => {
let str = self.user.clone() + "\n";
self.write(str.as_bytes())?;
}
"quit" => ... | code_fim | hard | {
"lang": "rust",
"repo": "redtankd/rust-test",
"path": "/net/std/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redtankd/rust-test path: /net/std/src/main.rs
use std::collections::HashMap;
use std::io::prelude::*;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::Result;
use std::net::{TcpListener, TcpStream};
use std::sync::Arc;
use std::sync::RwLock;
use std::thread;
use std::time::Duration;
... | code_fim | hard | {
"lang": "rust",
"repo": "redtankd/rust-test",
"path": "/net/std/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roelanto/AdventOfCode path: /2019/day4/src/main.rs
fn rle_reduce_int(num : &str) -> Vec<u32>{
let digits: Vec<_> = num.to_string().chars().map(|d| d.to_digit(10).unwrap()).collect();
return rle_reduce(digits);
}
fn rle_reduce(v:Vec<u32>) -> Vec<u32> {
let mut prev_read = v[0]+1;
... | code_fim | medium | {
"lang": "rust",
"repo": "roelanto/AdventOfCode",
"path": "/2019/day4/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> v.iter().map(|x| if *x == 2 {1} else {0}).sum()
}
fn main() {
let v:Vec<_> = (240298..784956).map(|x| x).collect();
let viter = v.iter();
// determine which have double input
let vfilter:Vec<&u32> = viter.filter(|x| has_multiples(rle_reduce_int(&x.to_string())) > 0).collect();
... | code_fim | medium | {
"lang": "rust",
"repo": "roelanto/AdventOfCode",
"path": "/2019/day4/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nikclayton/gflags-derive path: /examples/protobuf/app/src/main.rs
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::fs::File;
use std::io::BufReader;
use std::iter::FromIterator;
use std::path::{Path, PathBuf};
mod proto {
include!(concat!(env!... | code_fim | hard | {
"lang": "rust",
"repo": "nikclayton/gflags-derive",
"path": "/examples/protobuf/app/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if proto::DEBUG.is_present() && proto::DEBUG.flag {
println!(
"Loaded config:\n{}",
serde_json::to_string_pretty(&config_pb)?
);
}
let config = Config::from(&config_pb);
if config.debug {
println!(
"Config after command line par... | code_fim | hard | {
"lang": "rust",
"repo": "nikclayton/gflags-derive",
"path": "/examples/protobuf/app/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config = Config::from(&config_pb);
if config.debug {
println!(
"Config after command line parsing:\n{}",
serde_json::to_string_pretty(&config)?
);
}
println!("Suggested password: {}", config.pwgen.generate());
Ok(())
}
fn read_config_from_... | code_fim | hard | {
"lang": "rust",
"repo": "nikclayton/gflags-derive",
"path": "/examples/protobuf/app/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s: u16 = env::args().nth(1).expect("Expect a input").parse()?;
let mut d: u32 = 0;
while s > 0 {
match (s % 2, EXPLAINS.get(&2u16.pow(d))) {
(1, Some(v)) => println!("{} {}", "[\u{2713}]".bold(), v.green().bold()),
(0, Some(v)) => println!("{} {}", "[\u{... | code_fim | medium | {
"lang": "rust",
"repo": "kwuiee/rust-gadgets",
"path": "/explain-flags/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kwuiee/rust-gadgets path: /explain-flags/src/main.rs
#[macro_use]
extern crate lazy_static;
use std::collections::BTreeMap;
use std::env;
use colored::*;
// [Explanation source](https://broadinstitute.github.io/picard/explain-flags.html)
lazy_static! {
static ref EXPLAINS: BTreeMap<u16, &... | code_fim | medium | {
"lang": "rust",
"repo": "kwuiee/rust-gadgets",
"path": "/explain-flags/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abissell/rust-programming-language path: /ch-8/int_list/src/main.rs
use std::collections::HashMap;
fn main() {
println!("Hello, world!");
let mut v = vec![4, 2, 1, 1, 3, 5, 5];
println!("v is {:?}", v);
println!("mean of v is {}", mean(&v));
println!("median of v is {}", med... | code_fim | medium | {
"lang": "rust",
"repo": "abissell/rust-programming-language",
"path": "/ch-8/int_list/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn mode(v: &Vec<i32>) -> Vec<i32> {
let mut counts = HashMap::new();
for i in v {
let count = counts.entry(i).or_insert(0);
*count += 1;
}
let mut highest_count = 0;
let mut modes = Vec::<i32>::new();
for (value, count) in counts {
if count > highest_count ... | code_fim | hard | {
"lang": "rust",
"repo": "abissell/rust-programming-language",
"path": "/ch-8/int_list/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: opensourcegeek/stest path: /src/file_utils.rs
use std::fs::File;
use std::io::prelude::*;
pub fn write_to_file(csv_content: String, file_name: &str) -> () {
let full_file_name = get_full_file_name(file_name);
let mut f = File::create(full_file_name).expect("Unable to create file");
... | code_fim | medium | {
"lang": "rust",
"repo": "opensourcegeek/stest",
"path": "/src/file_utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn get_full_file_name_with_csv_extension_test() {
assert_eq!("abc.csv".to_string(), get_full_file_name("abc.csv"));
}
}<|fim_prefix|>// repo: opensourcegeek/stest path: /src/file_utils.rs
use std::fs::File;
use std::io::prelude::*;
pub fn write_to_file(csv_content: String, f... | code_fim | hard | {
"lang": "rust",
"repo": "opensourcegeek/stest",
"path": "/src/file_utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::get_full_file_name;
#[test]
fn get_full_file_name_no_csv_extension_test() {
assert_eq!("abc.csv".to_string(), get_full_file_name("abc"));
}
#[test]
fn get_full_file_name_with_csv_extension_test() {
assert_eq!("abc.csv".to_string... | code_fim | hard | {
"lang": "rust",
"repo": "opensourcegeek/stest",
"path": "/src/file_utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fooker/photonic path: /photonic-cli/src/client/grpc.rs
use anyhow::Error;
use async_trait::async_trait;
use photonic_grpc_proto as proto;
use crate::client::{AttrInfo, AttrValueType, NodeInfo};
use crate::SendValue;
pub struct GrpcClient {
client: proto::interface_client::InterfaceClient<... | code_fim | hard | {
"lang": "rust",
"repo": "fooker/photonic",
"path": "/photonic-cli/src/client/grpc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let node = response.into_inner().node;
return Ok(node.map(Into::into));
}
async fn send(&mut self, name: String, value: SendValue) -> Result<(), Error> {
let value = match value {
SendValue::Trigger => proto::input_send_request::Value::Trigger(proto::TriggerVa... | code_fim | hard | {
"lang": "rust",
"repo": "fooker/photonic",
"path": "/photonic-cli/src/client/grpc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn gen_access_token(&self, device_code: &str) -> Result<GetAccessTokenResponse> {
let res = self
.client
.post("https://github.com/login/oauth/access_token")
.header("Content-Type", "application/json")
.body(
json!({
... | code_fim | hard | {
"lang": "rust",
"repo": "shandanjay/yag",
"path": "/src/github/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shandanjay/yag path: /src/github/client.rs
use anyhow::Result;
use clap::crate_version;
use log::debug;
use reqwest::{header::HeaderMap, Client, Method, RequestBuilder, Response, Url};
use serde_json::json;
use super::structs::{DeviceCode, GetAccessTokenResponse};
const GITHUB_API_ENDPOINT: &s... | code_fim | hard | {
"lang": "rust",
"repo": "shandanjay/yag",
"path": "/src/github/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pka/ogcapi-codegen path: /codegen/server/src/mimetypes.rs
/// mime types for requests and responses
pub mod responses {
use hyper::mime::*;
// The macro is called per-operation to beat the recursion limit
lazy_static! {
/// Create Mime objects for the response content type... | code_fim | hard | {
"lang": "rust",
"repo": "pka/ogcapi-codegen",
"path": "/codegen/server/src/mimetypes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> lazy_static! {
/// Create Mime objects for the response content types for GetFeatures
pub static ref GET_FEATURES_A_QUERY_PARAMETER_HAS_AN_INVALID_VALUE: Mime = "application/json".parse().unwrap();
}
lazy_static! {
/// Create Mime objects for the response content types... | code_fim | hard | {
"lang": "rust",
"repo": "pka/ogcapi-codegen",
"path": "/codegen/server/src/mimetypes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok((output_format_context, encode_context))
}
/// encode -> write_frame
fn encode_write_frame(
frame_after: Option<&AVFrame>,
encode_context: &mut AVCodecContext,
output_format_context: &mut AVFormatContextOutput,
out_stream_index: usize,
) -> Result<()> {
encode_context
.... | code_fim | hard | {
"lang": "rust",
"repo": "LittleTung/rsmpeg",
"path": "/tests/avio_writing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Return output_format_context and encode_context
fn open_output_file(
filename: &CStr,
decode_context: &AVCodecContext,
) -> Result<(AVFormatContextOutput, AVCodecContext)> {
let buffer = Arc::new(Mutex::new(File::create(filename.to_str()?)?));
let buffer1 = buffer.clone();
// Cust... | code_fim | hard | {
"lang": "rust",
"repo": "LittleTung/rsmpeg",
"path": "/tests/avio_writing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LittleTung/rsmpeg path: /tests/avio_writing.rs
/// Simplified transcoding test, select the first video stream in given video file
/// and transcode it. Store the output in memory.
use anyhow::{anyhow, bail, Context, Result};
use cstr::cstr;
use rsmpeg::{
self,
avcodec::{AVCodec, AVCodecC... | code_fim | hard | {
"lang": "rust",
"repo": "LittleTung/rsmpeg",
"path": "/tests/avio_writing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: svmk/fund-watch-bot path: /src/market/fund_report/model/weight.rs
use crate::prelude::*;
use crate::market::common::error::weight_parse_error::WeightParseError;
#[derive(Debug, Clone, PartialEq, PartialOrd, ValueObject)]
#[value_object(error_type = "Failure", load_fn = "Weight::from_f64")]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "svmk/fund-watch-bot",
"path": "/src/market/fund_report/model/weight.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn sub(&self, other: &Self) -> Weight {
let value = self.0 - other.0;
assert!(value >= 0.0);
assert!(value <= 100.0);
return Weight(value);
}
pub fn into_f64(self) -> f64 {
return self.0;
}
}<|fim_prefix|>// repo: svmk/fund-watch-bot path: /src... | code_fim | hard | {
"lang": "rust",
"repo": "svmk/fund-watch-bot",
"path": "/src/market/fund_report/model/weight.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn min_entanglement(weights: &[usize], group_size: usize) -> usize {
let group_weight = weights.iter().sum::<usize>() / group_size;
let is_right_weight = |v: &[&usize]| v.iter().cloned().sum::<usize>() == group_weight;
let mut min_entanglement = None;
for i in 1..weights.len() - (group_si... | code_fim | medium | {
"lang": "rust",
"repo": "jmageau/advent_of_code",
"path": "/src/year_2015/day_24.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmageau/advent_of_code path: /src/year_2015/day_24.rs
use itertools::Itertools;
pub fn answers() -> String {
format!("{}, {}", answer_one(), answer_two())
}
fn answer_one() -> String {
let weights: Vec<_> = input()
.lines()
.map(|l| l.parse::<usize>().unwrap())
... | code_fim | hard | {
"lang": "rust",
"repo": "jmageau/advent_of_code",
"path": "/src/year_2015/day_24.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let group_weight = weights.iter().sum::<usize>() / group_size;
let is_right_weight = |v: &[&usize]| v.iter().cloned().sum::<usize>() == group_weight;
let mut min_entanglement = None;
for i in 1..weights.len() - (group_size - 1) {
for group in weights
.iter()
... | code_fim | hard | {
"lang": "rust",
"repo": "jmageau/advent_of_code",
"path": "/src/year_2015/day_24.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KurosPlayspace/codegame path: /src/client_gen/go/mod.rs
use super::*;
pub type Generator = trans_gen::gens::go::Generator;
impl<G: Game> ClientGen<G> for trans_gen::GeneratorImpl<Generator> {
const NAME: &'static str = "Go";
const RUNNABLE: bool = true;
type GenOptions = <Generator... | code_fim | hard | {
"lang": "rust",
"repo": "KurosPlayspace/codegame",
"path": "/src/client_gen/go/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut command = command(
PathBuf::from(".")
.join(format!(
"{}{}",
options.name,
if cfg!(windows) { ".exe" } else { "" }
))
.to_str()
.unwrap(),
);
... | code_fim | hard | {
"lang": "rust",
"repo": "KurosPlayspace/codegame",
"path": "/src/client_gen/go/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Start the blink task
blink::spawn().unwrap();
(Shared { red_led }, Local {}, init::Monotonics(rtc))
}
#[task(shared = [red_led])]
fn blink(mut cx: blink::Context) {
// If the LED were a local resource, the lock would not be necessary
cx.shared.red_l... | code_fim | medium | {
"lang": "rust",
"repo": "atsamd-rs/atsamd",
"path": "/boards/metro_m0/examples/blinky_rtic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atsamd-rs/atsamd path: /boards/metro_m0/examples/blinky_rtic.rs
//! Uses RTIC with the RTC as time source to blink an LED.
//!
//! The idle task is sleeping the CPU, so in practice this gives similar power
//! figure as the "sleeping_timer_rtc" example.
#![no_std]
#![no_main]
use metro_m0 as bs... | code_fim | hard | {
"lang": "rust",
"repo": "atsamd-rs/atsamd",
"path": "/boards/metro_m0/examples/blinky_rtic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[init]
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
let mut peripherals: Peripherals = cx.device;
let pins = bsp::Pins::new(peripherals.PORT);
let mut core: rtic::export::Peripherals = cx.core;
let mut clocks = GenericClockController::with_exte... | code_fim | hard | {
"lang": "rust",
"repo": "atsamd-rs/atsamd",
"path": "/boards/metro_m0/examples/blinky_rtic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blueluna/psila path: /psila-data/src/lib.rs
//! # Psila - A Z**bee crate
//!
//! This crate contains multiple sub-systems of the Z**bee standard.
//!
//!
#![warn(missing_docs)]
#![cfg_attr(feature = "core", no_std)]
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate hash32_derive;
... | code_fim | hard | {
"lang": "rust",
"repo": "blueluna/psila",
"path": "/psila-data/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = [
0x41, 0x88, 0xf5, 0xbb, 0xbb, 0xbb, 0xeb, 0x9a, 0xca, 0x67, 0xf6, 0xc1, 0xcf, 0x66,
0x25, 0x36, 0x6f, 0x94, 0x9f, 0x30, 0x22, 0x32, 0x9f, 0x3f, 0xc1, 0xb2, 0x79, 0x3c,
0x11, 0x11, 0x31, 0x2b, 0xca, 0x41, 0x55, 0xa5, 0x42, 0x52, 0x39, 0xd1, 0xa0, 0xe... | code_fim | hard | {
"lang": "rust",
"repo": "blueluna/psila",
"path": "/psila-data/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitchmindtree/imxrt-rs path: /imxrt-ral/src/imxrt105/instances/csu.rs
#![allow(non_snake_case, non_upper_case_globals)]
#![allow(non_camel_case_types)]
//! CSU registers
//!
//! Used by: imxrt1051, imxrt1052
#[cfg(not(feature = "nosync"))]
pub use crate::imxrt105::peripherals::csu::Instance;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-ral/src/imxrt105/instances/csu.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Raw pointer to CSU
///
/// Dereferencing this is unsafe because you are not ensured unique
/// access to the peripheral, so you may encounter data races with
/// other users of this peripheral. It is up to you to ensure you
/// will not cause data races.
///
/// This constant is provided for ease of u... | code_fim | hard | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-ral/src/imxrt105/instances/csu.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> None
}
fn with_new_children(
self: Arc<Self>,
mut children: Vec<Arc<dyn ExecutionPlan>>,
) -> Result<Arc<dyn ExecutionPlan>> {
Ok(Arc::new(Self::new(
self.verbose,
children.pop().unwrap(),
self.schema.clone(),
)))
... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/core/src/physical_plan/analyze.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/core/src/physical_plan/analyze.rs
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. ... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/core/src/physical_plan/analyze.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Should not take ownership
fn get_char(data: String) -> char {
data.chars().last().unwrap()
}
// Should take ownership
fn string_uppercase(mut data: &String) {
data = &data.to_uppercase();
println!("{}", data);
}<|fim_prefix|>// repo: rust-lang/rustlings path: /exercises/move_semantics/mo... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rustlings",
"path": "/exercises/move_semantics/move_semantics6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> string_uppercase(&data);
}
// Should not take ownership
fn get_char(data: String) -> char {
data.chars().last().unwrap()
}
// Should take ownership
fn string_uppercase(mut data: &String) {
data = &data.to_uppercase();
println!("{}", data);
}<|fim_prefix|>// repo: rust-lang/rustlings pa... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rustlings",
"path": "/exercises/move_semantics/move_semantics6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustlings path: /exercises/move_semantics/move_semantics6.rs
// move_semantics6.rs
//
// You can't change anything except adding or removing references.
//
// Execute `rustlings hint move_semantics6` or use the `hint` watch subcommand
// for a hint.
<|fim_suffix|>// Should not take ow... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rustlings",
"path": "/exercises/move_semantics/move_semantics6.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benzyx/Elric path: /src/server.rs
use crate::utils::*;
use crate::messages::*;
use crate::messages::ClientMessage::*;
use crate::protocol::*;
use crate::exchange::Exchange;
<|fim_suffix|> async fn handle_connection(self, mut stream: TcpStream) -> R {
let msg: ClientMessage = framed_read(&m... | code_fim | hard | {
"lang": "rust",
"repo": "benzyx/Elric",
"path": "/src/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn handle_connection(self, mut stream: TcpStream) -> R {
let msg: ClientMessage = framed_read(&mut stream).await?;
match msg {
LimitOrderMsg(limit_order_msg) => {
self.exchange.lock().await.process_limit_order(limit_order_msg);
}
};
Ok(())
}
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "benzyx/Elric",
"path": "/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/futures-channel/src/mpsc/mod.rs
e_state(self.inner.state.load(SeqCst));
self.maybe_parked = state.is_open;
}
fn poll_ready(&mut self, cx: &mut Context<'_>) -> P... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/futures-channel/src/mpsc/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.close();
if self.inner.is_some() {
loop {
match self.next_message() {
Poll::Ready(Some(_)) => {}
Poll::Ready(None) => break,
Poll::Pending => {
let state = decode_state(self... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/futures-channel/src/mpsc/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/futures-channel/src/mpsc/mod.rs
Poll::Ready(Err(SendError { kind: SendErrorKind::Disconnected }))
}
}
fn queue_push_and_signal(&self, msg: T) {
self.inner.message_queue.push(msg);
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/futures-channel/src/mpsc/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut child = exec_git(
vec!["clone", repo_string.as_str(), repo_dir.clone().as_str()],
Option::from(Stdio::inherit()), Option::from(Stdio::inherit())
);
child.wait().unwrap();
settings_file.clone().add_repo(object! {
"path" => repo_dir.clone().as_str(),
"... | code_fim | hard | {
"lang": "rust",
"repo": "mckernant1/project-manager",
"path": "/src/subcommands/clone.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mckernant1/project-manager path: /src/subcommands/clone.rs
use clap::ArgMatches;
use crate::setup::SettingsFile;
use crate::subcommands::util::exec_git;
use std::process::Stdio;
<|fim_suffix|> let mut child = exec_git(
vec!["clone", repo_string.as_str(), repo_dir.clone().as_str()],
... | code_fim | hard | {
"lang": "rust",
"repo": "mckernant1/project-manager",
"path": "/src/subcommands/clone.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let json_clone = settings_file
.clone().get_settings_json().clone();
let default_dir = json_clone["defaultDir"].as_str().unwrap().clone();
let repo_name: String = repo_string.split('/').last().unwrap()
.chars().take_while(|c| { c != &'.' }).collect();
let repo_dir = format!... | code_fim | medium | {
"lang": "rust",
"repo": "mckernant1/project-manager",
"path": "/src/subcommands/clone.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(response)
},
Method::Upsert => {
let response = handler.handle_upsert(store, &mut request)?;
response.check()?;
if response.message.method != Method::Upsert {
return Err(String::from("invalid m... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/mitrid-core",
"path": "/src/io/network/server/router.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-chainblock/mitrid-core path: /src/io/network/server/router.rs
//! # Router
//!
//! `router` is the module providing the trait implemented by the server router.
use base::Result;
use base::size::ConstantSize;
use base::Checkable;
use base::Serializable;
use base::Datable;
use base::{Eval, E... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/mitrid-core",
"path": "/src/io/network/server/router.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NielsKlo/Zoo path: /api/src/main.rs
use actix_web::{HttpServer, HttpResponse, App, Responder, get, post};
use actix_web::web::Json;
use actix_session::{CookieSession, Session};
use std::io;
use database;
use database::models::game_state::GameState as DBGameState;
use domain::GameState as DomainG... | code_fim | hard | {
"lang": "rust",
"repo": "NielsKlo/Zoo",
"path": "/api/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[get("/save_animals")]
async fn save_animals(session: Session) -> impl Responder {
println!("API call for save_animals.");
let game_state = session.get::<DBGameState>("game").unwrap().unwrap();
database::save_animal(game_state);
HttpResponse::Ok()
}
#[get("/tick_forward")]
async fn tick... | code_fim | hard | {
"lang": "rust",
"repo": "NielsKlo/Zoo",
"path": "/api/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: angsy/lnqft path: /src/main.rs
use std::ffi::OsStr;
use std::fs;
use std::io::{prelude::*, stdin};
use std::net::{TcpListener, TcpStream};
use std::path::Path;
use std::process::exit;
use std::thread::sleep;
use std::time::Duration;
fn file_handler() -> (String, String) {
let mut _file_pat... | code_fim | hard | {
"lang": "rust",
"repo": "angsy/lnqft",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let (file_name, file_data) = file_handler();
let address: String = socket_address();
let link: String = format!("{0}/{1}", &address, &file_name);
println!("\nFile will be temporarily hosted at...\n\x1B[32;1m{0}\x1B[0m\nPlease exits the program after transfer completed.\n", link);
l... | code_fim | hard | {
"lang": "rust",
"repo": "angsy/lnqft",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heyyyoyy/rust-restful-api path: /src/posts/models.rs
use super::super::schema::post;
<|fim_suffix|>
#[table_name = "post"]
#[derive(Serialize, Deserialize, Insertable, AsChangeset)]
pub struct NewPost {
pub title: String,
pub description: String,
}<|fim_middle|>
#[derive(Serialize, Dese... | code_fim | medium | {
"lang": "rust",
"repo": "heyyyoyy/rust-restful-api",
"path": "/src/posts/models.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[table_name = "post"]
#[derive(Serialize, Deserialize, Insertable, AsChangeset)]
pub struct NewPost {
pub title: String,
pub description: String,
}<|fim_prefix|>// repo: heyyyoyy/rust-restful-api path: /src/posts/models.rs
use super::super::schema::post;
<|fim_middle|>#[derive(Serialize, Deser... | code_fim | medium | {
"lang": "rust",
"repo": "heyyyoyy/rust-restful-api",
"path": "/src/posts/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(OrdinalValue::new(80))
}
);
b.rule_2("22ieme...29ieme, 32ieme...39ieme, 42ieme...49ieme, 52ieme...59ieme",
integer_check_by_range!(20, 50, |integer: &IntegerValue| integer.value % 10 == 0),
ordinal_check_by_range!(2, 9),
|integer, ordinal| {
... | code_fim | hard | {
"lang": "rust",
"repo": "tlverwijst/rustling-ontology",
"path": "/grammar/fr/src/rules_number.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tlverwijst/rustling-ontology path: /grammar/fr/src/rules_number.rs
("ordinal 2",
b.reg(r#"seconde?|deuxi[eè]me"#)?,
|_| {
Ok(OrdinalValue::new(2))
}
);
b.rule_1_terminal(
"ordinals (premier..seizieme)",
b.reg(r#"(trois|quatr|cin... | code_fim | hard | {
"lang": "rust",
"repo": "tlverwijst/rustling-ontology",
"path": "/grammar/fr/src/rules_number.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tlverwijst/rustling-ontology path: /grammar/fr/src/rules_number.rs
, "").replace(",", ".");
let value: f64 = reformatted_string.parse()?;
FloatValue::new(value)
});
b.rule_2("numbers prefix with -, negative or minus",
... | code_fim | hard | {
"lang": "rust",
"repo": "tlverwijst/rustling-ontology",
"path": "/grammar/fr/src/rules_number.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cwb96/cpcontrol-redacted path: /src/macros.rs
#[macro_export]
macro_rules! uprint {
($serial:expr, $($arg:tt)*) => {
$serial.write_fmt(format_args!($($arg)*)).ok()
};
}
<|fim_suffix|>#[macro_export]
macro_rules! send_empty_frames {
($can:expr, $len:expr, [$($id:tt),*]) => {... | code_fim | hard | {
"lang": "rust",
"repo": "cwb96/cpcontrol-redacted",
"path": "/src/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! send_empty_frames {
($can:expr, $len:expr, [$($id:tt),*]) => {
$(
crate::utils::send_empty_message($can, $id, $len);
)*
};
}<|fim_prefix|>// repo: cwb96/cpcontrol-redacted path: /src/macros.rs
#[macro_export]
macro_rules! uprint {
($serial... | code_fim | hard | {
"lang": "rust",
"repo": "cwb96/cpcontrol-redacted",
"path": "/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn index_2d_to_1d(x: u32, y: u32, rows: u32) -> u32 {
rows * y + x
}<|fim_prefix|>// repo: Lucassifoni/imago path: /native/imago/src/imago/util.rs
use std::path::Path;
use image::DynamicImage;
use rustler::{Error, Term};
<|fim_middle|>pub fn open_file_arg0<'a>(arg0: Term<'a>) -> Result<DynamicI... | code_fim | hard | {
"lang": "rust",
"repo": "Lucassifoni/imago",
"path": "/native/imago/src/imago/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lucassifoni/imago path: /native/imago/src/imago/util.rs
use std::path::Path;
use image::DynamicImage;
use rustler::{Error, Term};
<|fim_suffix|>pub fn index_2d_to_1d(x: u32, y: u32, rows: u32) -> u32 {
rows * y + x
}<|fim_middle|>pub fn open_file_arg0<'a>(arg0: Term<'a>) -> Result<DynamicI... | code_fim | hard | {
"lang": "rust",
"repo": "Lucassifoni/imago",
"path": "/native/imago/src/imago/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng: PcgRng = SeedableRng::from_seed([0, 0]);
const W: u32 = 400;
const H: u32 = 300;
const N: u32 = 20_000;
let seeds = vec![(W / 2, H / 2)];
simulate_dla(&mut rng,
W,
H,
N,
&seeds,
&[(0,... | code_fim | medium | {
"lang": "rust",
"repo": "mneumann/dla-rs",
"path": "/examples/conf_middle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mneumann/dla-rs path: /examples/conf_middle.rs
extern crate dla;
extern crate pcg;
extern crate rand;
<|fim_suffix|> let mut rng: PcgRng = SeedableRng::from_seed([0, 0]);
const W: u32 = 400;
const H: u32 = 300;
const N: u32 = 20_000;
let seeds = vec![(W / 2, H / 2)];
sim... | code_fim | medium | {
"lang": "rust",
"repo": "mneumann/dla-rs",
"path": "/examples/conf_middle.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mut rng: PcgRng = SeedableRng::from_seed([0, 0]);
const W: u32 = 400;
const H: u32 = 300;
const N: u32 = 20_000;
let seeds = vec![(W / 2, H / 2)];
simulate_dla(&mut rng,
W,
H,
N,
&seeds,
... | code_fim | medium | {
"lang": "rust",
"repo": "mneumann/dla-rs",
"path": "/examples/conf_middle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct SizeBySpeed {
pub curve: MinMaxCurve,
pub range: Range<f32>,
}
#[derive(Debug, Clone)]
pub struct SizeOverLifetime {
pub curve: MinMaxCurve,
}
#[derive(Debug, Clone)]
pub struct VelocityOverLifetime {}
pub fn size_over_lifetime(
compute_task_pool: Res<... | code_fim | hard | {
"lang": "rust",
"repo": "TheRawMeatball/bevy_prototype_particles",
"path": "/src/modifiers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheRawMeatball/bevy_prototype_particles path: /src/modifiers.rs
use crate::curve::MinMaxCurve;
#[derive(Debug, Clone)]
pub struct ColorBySpeed {
// color: Curve<Color>,
pub range: Range<f32>,
}
#[derive(Debug, Clone)]
pub struct ColorByLifetime {
// color: Curve<Color>,
}
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "TheRawMeatball/bevy_prototype_particles",
"path": "/src/modifiers.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub enum RotationOverLifetime {
ZOnly {
curve: MinMaxCurve,
range: Range<f32>,
}
AllAxes {
x: MinMaxCurve,
y: MinMaxCurve,
z: MinMaxCurve,
range: Range<f32>,
}
}
#[derive(Debug, Clone)]
pub struct SizeBySpeed {
pu... | code_fim | hard | {
"lang": "rust",
"repo": "TheRawMeatball/bevy_prototype_particles",
"path": "/src/modifiers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn bench_setup_n(n: i64, b: &mut Bencher) {
let base = "./test_files/".to_owned();
let filename = generate(n, base);
let mut g = match Graph::import_file(&filename) {
Ok(r) => r,
Err(e) => {
println!("Error importing: {} {}", filename, e)... | code_fim | hard | {
"lang": "rust",
"repo": "RyanCarrier/dijkstrust",
"path": "/src/graph.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let base = "./test_files/".to_owned();
let filename = generate(n, base);
let mut g = match Graph::import_file(&filename) {
Ok(r) => r,
Err(e) => {
println!("Error importing: {} {}", filename, e);
return;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "RyanCarrier/dijkstrust",
"path": "/src/graph.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RyanCarrier/dijkstrust path: /src/graph.rs
use std::fmt;
use vertex;
use std;
use std::fs::File;
use std::io::Read;
use std::io;
use std::num;
use std::error;
use std::collections::BinaryHeap;
use std::cmp::Ordering;
#[derive(Debug)]
pub enum ImportError {
Io(io::Error),
Fmt(fmt::Erro... | code_fim | hard | {
"lang": "rust",
"repo": "RyanCarrier/dijkstrust",
"path": "/src/graph.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/flashroute.rs path: /src/utils.rs
use std::{
net::{IpAddr, Ipv4Addr},
time::{SystemTime, UNIX_EPOCH},
};
use petgraph::dot::Dot;
use pnet::datalink::NetworkInterface;
use tokio::io::AsyncWriteExt;
use crate::{error::*, topo::TopoGraph, OPT};
pub fn get_interface_ipv4_addr(ni: ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/flashroute.rs",
"path": "/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait GlobalIpv4Ext {
fn is_bz_global(&self) -> bool;
}
impl GlobalIpv4Ext for Ipv4Addr {
fn is_bz_global(&self) -> bool {
// check if this address is 192.0.0.9 or 192.0.0.10. These addresses are the only two
// globally routable addresses in the 192.0.0.0/24 range.
if... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/flashroute.rs",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GlobalIpv4Ext for Ipv4Addr {
fn is_bz_global(&self) -> bool {
// check if this address is 192.0.0.9 or 192.0.0.10. These addresses are the only two
// globally routable addresses in the 192.0.0.0/24 range.
if u32::from_be_bytes(self.octets()) == 0xc0000009
|| u... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/flashroute.rs",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tshepang/gd32vf103-pac path: /src/spi0.rs
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - control register 0"]
pub ctl0: CTL0,
_reserved0: [u8; 2usize],
#[doc = "0x04 - control register 1"]
pub ctl1: CTL1,
_reserved1: [u8; 2usize],
#[... | code_fim | hard | {
"lang": "rust",
"repo": "tshepang/gd32vf103-pac",
"path": "/src/spi0.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
register: ::vcell::VolatileCell<u16>,
}
#[doc = "control register 1"]
pub mod ctl1;
#[doc = "status register"]
pub struct STAT {
register: ::vcell::VolatileCell<u16>,
}
#[doc = "status register"]
pub mod stat;
#[doc = "data register"]
pub struct DATA {
register: ::vcell::VolatileCell<u16>,
... | code_fim | hard | {
"lang": "rust",
"repo": "tshepang/gd32vf103-pac",
"path": "/src/spi0.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub struct RCRC {
register: ::vcell::VolatileCell<u16>,
}
#[doc = "RX CRC register"]
pub mod rcrc;
#[doc = "TX CRC register"]
pub struct TCRC {
register: ::vcell::VolatileCell<u16>,
}
#[doc = "TX CRC register"]
pub mod tcrc;
#[doc = "I2S control register"]
pub struct I2SCTL {
register: ::vcel... | code_fim | hard | {
"lang": "rust",
"repo": "tshepang/gd32vf103-pac",
"path": "/src/spi0.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deepankarsharma/hhvm path: /hphp/hack/src/parser/syntax_smart_constructors.rs
make_markup_section(s: NoState, arg0 : Self::R, arg1 : Self::R, arg2 : Self::R, arg3 : Self::R) -> (NoState, Self::R) {
(s, Self::R::make_markup_section(arg0, arg1, arg2, arg3))
}
fn make_markup_suffi... | code_fim | hard | {
"lang": "rust",
"repo": "deepankarsharma/hhvm",
"path": "/hphp/hack/src/parser/syntax_smart_constructors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deepankarsharma/hhvm path: /hphp/hack/src/parser/syntax_smart_constructors.rs
tement_block_scoped(arg0, arg1, arg2, arg3, arg4, arg5))
}
fn make_using_statement_function_scoped(s: NoState, arg0 : Self::R, arg1 : Self::R, arg2 : Self::R, arg3 : Self::R) -> (NoState, Self::R) {
(s... | code_fim | hard | {
"lang": "rust",
"repo": "deepankarsharma/hhvm",
"path": "/hphp/hack/src/parser/syntax_smart_constructors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn make_anonymous_class(s: NoState, arg0 : Self::R, arg1 : Self::R, arg2 : Self::R, arg3 : Self::R, arg4 : Self::R, arg5 : Self::R, arg6 : Self::R, arg7 : Self::R, arg8 : Self::R) -> (NoState, Self::R) {
(s, Self::R::make_anonymous_class(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))
... | code_fim | hard | {
"lang": "rust",
"repo": "deepankarsharma/hhvm",
"path": "/hphp/hack/src/parser/syntax_smart_constructors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.registers[c as usize] = if self.registers[a as usize] > self.registers[b as usize] {
1
} else {
0
};
}
fn eqir(&mut self, a: u32, b: u32, c: u32) {
self.registers[c as usize] = if a == self.registers[b as usize] {
1
... | code_fim | hard | {
"lang": "rust",
"repo": "commieprincess/aoc2018",
"path": "/day_16/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: commieprincess/aoc2018 path: /day_16/src/main.rs
use regex::Regex;
type CpuMethod = Box<Fn(&mut Cpu, u32, u32, u32)>;
fn main() {
let input = include_str!("input.txt").trim();
let input_regex = Regex::new(r"Before:\s+\[(\d+),\s+(\d+),\s+(\d+),\s+(\d+)\]\n(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\... | code_fim | hard | {
"lang": "rust",
"repo": "commieprincess/aoc2018",
"path": "/day_16/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn gtir(&mut self, a: u32, b: u32, c: u32) {
self.registers[c as usize] = if a > self.registers[b as usize] { 1 } else { 0 };
}
fn gtri(&mut self, a: u32, b: u32, c: u32) {
self.registers[c as usize] = if self.registers[a as usize] > b { 1 } else { 0 };
}
fn gtrr(&mut... | code_fim | hard | {
"lang": "rust",
"repo": "commieprincess/aoc2018",
"path": "/day_16/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MatevzFa/class2json path: /src/bytecode/mod.rs
macro_rules! instruction {
($instr:expr, [$(eval $a:expr),*]) => {{
let mut vector: Vec<i32> = Vec::new();
$(vector.push($x as u8);)*
(instr, vector.sum(), vector)
}};
}
pub fn to_string(bytecode: u8) -> (&'static st... | code_fim | hard | {
"lang": "rust",
"repo": "MatevzFa/class2json",
"path": "/src/bytecode/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>0, vec![]),
0xff => ("impdep2", 0, vec![]),
0x68 => ("imul", 0, vec![]),
0x74 => ("ineg", 0, vec![]),
0x80 => ("ior", 0, vec![]),
0x70 => ("irem", 0, vec![]),
0xac => ("ireturn", 0, vec![]),
0x78 => ("ishl", 0, vec![]),
0x7a => ("ishr", 0, ve... | code_fim | hard | {
"lang": "rust",
"repo": "MatevzFa/class2json",
"path": "/src/bytecode/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>),
0x67 => ("dsub", 0, vec![]),
0x59 => ("dup", 0, vec![]),
0x5a => ("dup_x1", 0, vec![]),
0x5b => ("dup_x2", 0, vec![]),
0x5c => ("dup2", 0, vec![]),
0x5d => ("dup2_x1", 0, vec![]),
0x5e => ("dup2_x2", 0, vec![]),
0x8d => ("f2d", 0, vec![]),... | code_fim | hard | {
"lang": "rust",
"repo": "MatevzFa/class2json",
"path": "/src/bytecode/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let p = e310x::Peripherals::take().unwrap();
let mut clint = p.CLINT.split();
let clocks = Clocks::freeze(
p.PRCI.constrain(),
p.AONCLK.constrain());
let mut gpio = p.GPIO0.split();
let txrx = hifive1::tx_rx(
gpio.pin17,
gpio.pin16,
&mut gpio.ou... | code_fim | hard | {
"lang": "rust",
"repo": "irandms/riscv-phone",
"path": "/firmware/examples/atomiqueue_example.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: irandms/riscv-phone path: /firmware/examples/atomiqueue_example.rs
#![no_std]
#![no_main]
extern crate riscv;
extern crate hifive1;
extern crate atomiqueue;
extern crate panic_halt;
use riscv_rt::entry;
use core::{
sync::atomic::{AtomicBool, Ordering},
ptr::null_mut,
};
use atomiqueue:... | code_fim | hard | {
"lang": "rust",
"repo": "irandms/riscv-phone",
"path": "/firmware/examples/atomiqueue_example.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (mut tx, _) = Serial::uart0(
p.UART0,
txrx,
115_200.bps(),
clocks,
).split();
let mut stdout = Stdout(&mut tx);
writeln!(stdout, "AtomiQueue Example").unwrap();
unsafe {
MTIME_G = &mut clint.mtime;
MTIMECMP_G = &mut clint.mtimecm... | code_fim | hard | {
"lang": "rust",
"repo": "irandms/riscv-phone",
"path": "/firmware/examples/atomiqueue_example.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>t::Import(pos, path)))
},
token => {
Some(Err(ParseError::ExpectedString(token)))
}
}
}<|fim_prefix|>// repo: stanipintjuk/foil path: /src/compiler/parser/parsers/import_parser.rs
use helpers::all_ok;
use compiler::models::{Ast, SetField, Token, Val, Keyword};
use ... | code_fim | medium | {
"lang": "rust",
"repo": "stanipintjuk/foil",
"path": "/src/compiler/parser/parsers/import_parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stanipintjuk/foil path: /src/compiler/parser/parsers/import_parser.rs
use helpers::all_ok;
use compiler::models::{Ast, SetField, Token, Val, Keyword};
use compiler::parser::{ParseResult, Parser};
<|fim_suffix|>t::Import(pos, path)))
},
token => {
Some(Err(ParseError::... | code_fim | hard | {
"lang": "rust",
"repo": "stanipintjuk/foil",
"path": "/src/compiler/parser/parsers/import_parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clemson-cal/gridiron path: /src/thread_pool.rs
use std::cell;
use std::thread;
type Job = Box<dyn FnOnce() + Send + 'static>;
#[cfg(feature = "crossbeam_channel")]
type JobSender = crossbeam_channel::Sender<Job>;
#[cfg(not(feature = "crossbeam_channel"))]
type JobSender = std::sync::mpsc::Sen... | code_fim | hard | {
"lang": "rust",
"repo": "clemson-cal/gridiron",
"path": "/src/thread_pool.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> std::sync::mpsc::channel()
}
#[cfg(feature = "core_affinity")]
fn make_workers(num_threads: usize) -> Vec<Worker> {
use core_affinity::{get_core_ids, set_for_current};
get_core_ids()
.unwrap()
.into_iter()
.take(num_threads)
... | code_fim | hard | {
"lang": "rust",
"repo": "clemson-cal/gridiron",
"path": "/src/thread_pool.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(not(feature = "core_affinity"))]
fn make_workers(num_threads: usize) -> Vec<Worker> {
(0..num_threads)
.map(|_| {
let (sender, receiver) = Self::make_channels();
let handle = thread::spawn(move || {
for job in receiver {... | code_fim | hard | {
"lang": "rust",
"repo": "clemson-cal/gridiron",
"path": "/src/thread_pool.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rheydskey/neoirc path: /src/server/db/create.rs
use async_std::stream::StreamExt;
use sqlx::{Connection, Sqlite, SqliteConnection};
use std::path::PathBuf;
<|fim_suffix|>pub async fn read_dir_to_vec(p: PathBuf) -> Vec<String> {
let mut result: Vec<String> = Vec::new();
let mut ee = asyn... | code_fim | hard | {
"lang": "rust",
"repo": "Rheydskey/neoirc",
"path": "/src/server/db/create.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn read_dir_to_vec(p: PathBuf) -> Vec<String> {
let mut result: Vec<String> = Vec::new();
let mut ee = async_std::fs::read_dir(p).await.expect("err");
while let Some(some) = ee.next().await {
match some {
Ok(e) => {
result.push(String::from(e.file_... | code_fim | hard | {
"lang": "rust",
"repo": "Rheydskey/neoirc",
"path": "/src/server/db/create.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.