text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let mut relooper: Relooper<i32, i32> = Relooper::new();
let mut nodes_mapping: HashMap<i32, NodeId> = HashMap::new();
// copy input CFG into relooper
for node in graph.node_indices() {
let u = graph.node_weight(node).cloned().unwrap();
let b_u = relooper.add_block(u);
... | code_fim | hard | {
"lang": "rust",
"repo": "lenoil98/basic_rs",
"path": "/src/relooper/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/zbox path: /tests/common/mod.rs
#![allow(dead_code)]
extern crate tempdir;
#[cfg(any(
feature = "storage-faulty",
feature = "storage-file",
feature = "storage-zbox-faulty"
))]
pub mod controller;
pub mod crypto;
#[cfg(any(
feature = "storage-faulty",
feature = "stora... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/zbox",
"path": "/tests/common/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ddboline/garmin_rust path: /garmin_lib/src/common/garmin_sync.rs
use anyhow::Error;
use futures::stream::{StreamExt, TryStreamExt};
use log::debug;
use rand::{
distributions::{Alphanumeric, DistString},
thread_rng,
};
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use rusoto_... | code_fim | hard | {
"lang": "rust",
"repo": "ddboline/garmin_rust",
"path": "/garmin_lib/src/common/garmin_sync.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn process_s3_item(mut item: S3Object) -> Option<KeyItem> {
item.key.take().and_then(|key| {
item.e_tag.take().and_then(|etag| {
item.last_modified.as_ref().and_then(|last_mod| {
OffsetDateTime::parse(last_mod, &Rfc3339)
.ok()
... | code_fim | hard | {
"lang": "rust",
"repo": "ddboline/garmin_rust",
"path": "/garmin_lib/src/common/garmin_sync.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tracing::debug!("SPC is stopping as leader for {}", self.spc.stream_cluster_id);
let _ = self.repl_shutdown_tx.broadcast(true);
Ok(())
}
/// Establish connection to CPC for leadership heartbeat & syncing ISR data.
#[tracing::instrument(level = "trace", skip(self))]
... | code_fim | hard | {
"lang": "rust",
"repo": "ives9638/hadron",
"path": "/hadrond/_src/ctl_stream/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ives9638/hadron path: /hadrond/_src/ctl_stream/mod.rs
es for any specific
//! partition will be handled by the leader of the SPC group. Groups are composed of the replicas
//! of a partition.
mod repl;
mod storage;
use std::collections::HashMap;
use std::sync::Arc;
use anyhow::{Context, Resul... | code_fim | hard | {
"lang": "rust",
"repo": "ives9638/hadron",
"path": "/hadrond/_src/ctl_stream/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ives9638/hadron path: /hadrond/_src/ctl_stream/mod.rs
of the SPC group. Groups are composed of the replicas
//! of a partition.
mod repl;
mod storage;
use std::collections::HashMap;
use std::sync::Arc;
use anyhow::{Context, Result};
use prost::Message;
use sled::Tree;
use tokio::stream::Stre... | code_fim | hard | {
"lang": "rust",
"repo": "ives9638/hadron",
"path": "/hadrond/_src/ctl_stream/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/lib/fho/src/subtool.rs
ffx_fidl::DaemonError;
use fidl::endpoints::Proxy;
use fidl_fuchsia_developer_ffx as ffx_fidl;
use selectors::{self, VerboseError};
use std::os::unix::process::ExitStatusExt;
use std::process::ExitStatus;
use std::time::Duration;
u... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/lib/fho/src/subtool.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
// This keeps the macros from having compiler errors.
use crate as fho;
use crate::testing::*;
use crate::FhoVersion;
use argh::FromArgs;
use async_trait::async_trait;
use fho_macro::FfxTool;
// The main testing part will happen i... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/lib/fho/src/subtool.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/lib/fho/src/subtool.rs
;
use ffx_fidl::DaemonError;
use fidl::endpoints::Proxy;
use fidl_fuchsia_developer_ffx as ffx_fidl;
use selectors::{self, VerboseError};
use std::os::unix::process::ExitStatusExt;
use std::process::ExitStatus;
use std::time::Durat... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/lib/fho/src/subtool.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn parse_proxy_target() {
assert_eq!(
ProxyTarget::from_str("localhost").unwrap(),
ProxyTarget::from((Scheme::HTTP, Authority::from_static("localhost"))),
);
assert_eq!(
ProxyTarget::from_str("localhost:8000").unwrap(),
ProxyTarget::from((Scheme::HTTP, A... | code_fim | medium | {
"lang": "rust",
"repo": "transparencies/penguin",
"path": "/lib/src/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn parse_proxy_target_bad() {
assert!(matches!(
ProxyTarget::from_str("").unwrap_err(),
ProxyTargetParseError::InvalidUri(_),
));
assert!(matches!(
ProxyTarget::from_str("github.com").unwrap_err(),
ProxyTargetParseError::MissingScheme,
));
assert... | code_fim | hard | {
"lang": "rust",
"repo": "transparencies/penguin",
"path": "/lib/src/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: transparencies/penguin path: /lib/src/tests.rs
use std::str::FromStr;
use hyper::http::uri::{Authority, Scheme};
use super::*;
/// Asserts that certain traits are implemented for the public types. `Debug` is
/// already covered by `#![deny(missing_debug_implementations)]`.
#[allow(unused_vari... | code_fim | medium | {
"lang": "rust",
"repo": "transparencies/penguin",
"path": "/lib/src/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-windowing/glutin path: /glutin/src/api/glx/config.rs
//! Everything related to finding and manipulating the `GLXFBConfig`.
use std::ops::Deref;
use std::os::raw::c_int;
use std::sync::Arc;
use std::{fmt, slice};
use glutin_glx_sys::glx::types::GLXFBConfig;
use glutin_glx_sys::{glx, glx_ex... | code_fim | hard | {
"lang": "rust",
"repo": "rust-windowing/glutin",
"path": "/glutin/src/api/glx/config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl X11GlConfigExt for Config {
fn x11_visual(&self) -> Option<X11VisualInfo> {
unsafe {
let raw_visual = self
.inner
.display
.inner
.glx
.GetVisualFromFBConfig(self.inner.display.inner.raw.cast(), *s... | code_fim | hard | {
"lang": "rust",
"repo": "rust-windowing/glutin",
"path": "/glutin/src/api/glx/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Failed to serialize message.
#[derive(Debug, Error)]
#[error("failed to serialize message: {error}")]
pub struct SerializeMessageError {
/// The error.
#[from]
error: SerdeJsonError,
}
/// Failed to request a response.
#[derive(Debug, Error)]
pub enum RequestResponseError {
/// An err... | code_fim | hard | {
"lang": "rust",
"repo": "casey/paper",
"path": "/src/io/lsp/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: casey/paper path: /src/io/lsp/utils.rs
//! Implements language server utilities.
use {
core::fmt::{self, Display},
fehler::throws,
jsonrpc_core::{Id, Value, Version},
log::error,
lsp_types::{notification::Notification, request::Request},
market::{ComposeFrom, NonComposibl... | code_fim | hard | {
"lang": "rust",
"repo": "casey/paper",
"path": "/src/io/lsp/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The outcome of the response.
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub(crate) enum Outcome {
/// The result was successful.
Result(Value),
}
impl Display for Outcome {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
... | code_fim | hard | {
"lang": "rust",
"repo": "casey/paper",
"path": "/src/io/lsp/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type Result<T> = std::result::Result<T, failure::Error>;
pub static CONTENT_TYPE: &str = "application/json";
pub fn get_localhost() -> SocketAddr {
"127.0.0.1:8080".parse::<SocketAddr>().unwrap()
}<|fim_prefix|>// repo: arso-project/Toshi path: /toshi-test/src/lib.rs
/// Toshi-test is a modified... | code_fim | medium | {
"lang": "rust",
"repo": "arso-project/Toshi",
"path": "/toshi-test/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_localhost() -> SocketAddr {
"127.0.0.1:8080".parse::<SocketAddr>().unwrap()
}<|fim_prefix|>// repo: arso-project/Toshi path: /toshi-test/src/lib.rs
/// Toshi-test is a modified version of Gotham's Test server, credit goes to them
/// https://github.com/gotham-rs/gotham/blob/master/gotham/s... | code_fim | medium | {
"lang": "rust",
"repo": "arso-project/Toshi",
"path": "/toshi-test/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arso-project/Toshi path: /toshi-test/src/lib.rs
/// Toshi-test is a modified version of Gotham's Test server, credit goes to them
/// https://github.com/gotham-rs/gotham/blob/master/gotham/src/test.rs
/// This was created to create a more integration test oriented way to test Toshi services
/// ... | code_fim | medium | {
"lang": "rust",
"repo": "arso-project/Toshi",
"path": "/toshi-test/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnpmayer/drebbel path: /src/lib.rs
// #![feature(slice_patterns)]
pub mod ast;
mod syntax; // lalrpop
pub mod intermediate;
pub mod exec;
#[cfg(test)]
use std::collections::HashMap;
pub use syntax::{parse_Expression, parse_Statement, parse_Program};
pub use intermediate::{transform_compoun... | code_fim | hard | {
"lang": "rust",
"repo": "johnpmayer/drebbel",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Testing program {}", program_name);
let program = programs::file_program(format!("examples/{}.drebbel", program_name).as_str());
assert_ok(&program);
let mut program: Program = program.unwrap();
println!(" Transforming entry block");
jit(&program.entry);
for (ref sub... | code_fim | hard | {
"lang": "rust",
"repo": "johnpmayer/drebbel",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(parse_Expression("1234 + 5678"), Ok(Box::new(Expression::ApplyInfixBinOp(
Box::new(Expression::Lit(Literal::Number(1234))),
InfixBinaryOperator::Add,
Box::new(Expression::Lit(Literal::Number(5678))))
)));
// Mixes with groups
assert!(parse_Expression("(12... | code_fim | hard | {
"lang": "rust",
"repo": "johnpmayer/drebbel",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nabijaczleweli/mcp-mapping-transposer path: /src/network.rs
use curl::easy::Easy;
use std::path::Path;
use std::io::Write;
use std::fs::File;
use mapping::MappingSpec;
<|fim_suffix|> true
}).unwrap();
ctx.write_function(|data| {
buf.extend_from_slice(data);
Ok(data.len())
}).unwr... | code_fim | hard | {
"lang": "rust",
"repo": "nabijaczleweli/mcp-mapping-transposer",
"path": "/src/network.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn download_to_file(destination_file: &Path, url: String) {
let mut buf = Vec::new();
let mut ctx = Easy::new();
ctx.url(&url).unwrap();
{
let mut ctx = ctx.transfer();
ctx.progress_function(|dltotal, dlnow, _, _| {
if dltotal != 0f64 && dlnow != 0f64 {
print!("\r{}% ", ((dlnow / dlt... | code_fim | hard | {
"lang": "rust",
"repo": "nabijaczleweli/mcp-mapping-transposer",
"path": "/src/network.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cbourjau/scraping-dbg path: /src/bin/parse_bip.rs
use futures::stream::{self, StreamExt, TryStreamExt};
use futures::future::poll_fn;
use reqwest::RequestBuilder;
use tokio;
use tower::{self, Service, ServiceBuilder};
use bip_api::parsing::BipData;
use bip_api::scrapers::{
default_client, p... | code_fim | hard | {
"lang": "rust",
"repo": "cbourjau/scraping-dbg",
"path": "/src/bin/parse_bip.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut svc = ServiceBuilder::new()
.rate_limit(10, std::time::Duration::from_secs(1))
.retry(RetryLimit::new(3))
.service(svc);
poll_fn(|mut cx| svc.poll_ready(&mut cx)).await.unwrap();
let item_pipeline = StdOutPipeline;
// Get cookies
svc.call(client.get(COOKIE_LA... | code_fim | hard | {
"lang": "rust",
"repo": "cbourjau/scraping-dbg",
"path": "/src/bin/parse_bip.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dineshadepu/dem2d-rs path: /src/physics/dem/mod.rs
#[macro_use]
pub mod equations;
// local imports
use contact_search::{NNPSMutParts, NNPS};
use std::collections::HashMap;
// external crate imports
use cm::{Vector3, Zero};
use ndarray::prelude::*;
pub struct DemDiscrete {
pub len: usize,... | code_fim | hard | {
"lang": "rust",
"repo": "dineshadepu/dem2d-rs",
"path": "/src/physics/dem/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> DemDiscreteSrcStrkt{
m: &mut self.m,
x: &mut self.x,
y: &mut self.y,
u: &mut self.u,
v: &mut self.v,
omega_z: &mut self.omega_z,
inertia: &mut self.in... | code_fim | hard | {
"lang": "rust",
"repo": "dineshadepu/dem2d-rs",
"path": "/src/physics/dem/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn read_file<P: AsRef<Path>>(path: P) -> PolyLine {
let file = File::open(path).unwrap();
let mut reader = BufReader::new(file);
let mut buf = String::new();
reader.read_line(&mut buf).expect("first line not present");
buf.clear();
let mut result = Vec::new();
for line in ... | code_fim | medium | {
"lang": "rust",
"repo": "Lesstat/alg_engineering_ss17",
"path": "/src/ae5/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lesstat/alg_engineering_ss17 path: /src/ae5/mod.rs
use std::path::Path;
use std::fs::File;
use std::io::{BufRead, BufReader};
use ndarray::Array2;
#[derive(Debug)]
pub struct Point {
x: f64,
y: f64,
}
<|fim_suffix|>
pub fn read_file<P: AsRef<Path>>(path: P) -> PolyLine {
let file... | code_fim | medium | {
"lang": "rust",
"repo": "Lesstat/alg_engineering_ss17",
"path": "/src/ae5/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackweinbender/advent_of_code path: /2017/day17/src/main.rs
fn main() {
part_1();
part_2();
}
fn part_1(){
let mut whirl = vec![0];
let skip = 324;
let mut insert = 1;
let mut index = 0;
for i in 0..2017 {
index = (index + skip) % whirl.len();
index +... | code_fim | medium | {
"lang": "rust",
"repo": "jackweinbender/advent_of_code",
"path": "/2017/day17/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> whirl_len += 1;
}
println!("Answer #2: {}", after_zero);
}
mod test {
#[test]
fn test_whirl(){
let mut whirl = vec![0];
let skip = 3;
let mut insert = 1;
let mut index = 0;
println!("");
for i in 0..40 {
println!("{:?}", ... | code_fim | hard | {
"lang": "rust",
"repo": "jackweinbender/advent_of_code",
"path": "/2017/day17/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let cur_hash = main_tour_hash.load(Ordering::Relaxed);
if cur_hash != our_tour_hash {
println!("saving");
let main_tour = main_tour_mutex.lock().unwrap().clone();
main_tour.save(&format!("{}-tmp.... | code_fim | hard | {
"lang": "rust",
"repo": "usamec/kaggle2018",
"path": "/mega_opt/src/bin/opt_search.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: usamec/kaggle2018 path: /mega_opt/src/bin/opt_search.rs
extern crate mega_opt;
extern crate rand;
#[macro_use]
extern crate structopt;
extern crate chrono;
use mega_opt::*;
use std::collections::HashSet;
use std::sync::{Mutex, Arc};
use std::thread;
use std::sync::atomic::{AtomicUsize, Ordering... | code_fim | hard | {
"lang": "rust",
"repo": "usamec/kaggle2018",
"path": "/mega_opt/src/bin/opt_search.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (0.05, 0.0, 0.0, 600000, 0.0, 4, 0), //12
(0.05, 0.0, 0.0, 1000000, 0.0, 4, 0), //13 y
(0.05, 0.0, 0.0, 1400000, 0.0, 4, 0), //14
(0.05, 0.0, 0.0, 600000, 0.0, 0, 3), //15
(0.05, 0.0, 0.0, 1000000, 0.0, 0, 3), //16 yy
(0.05, 0.0, 0.0, 1400000, 0.0, 0, 3), //17 y
... | code_fim | hard | {
"lang": "rust",
"repo": "usamec/kaggle2018",
"path": "/mega_opt/src/bin/opt_search.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustkas/error-index path: /main_tests/tests/e0030.rs
// #![allow(unused)]
/*
cargo test --test e0030
cargo test --test e0030 with_error -- --nocapture
cargo test --test e0030 without_error1 -- --nocapture
*/
/*
When matching against a range, the compiler verifies that the range is non-empty
*... | code_fim | hard | {
"lang": "rust",
"repo": "rustkas/error-index",
"path": "/main_tests/tests/e0030.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match 1 {
// This range is empty, and the compiler can tell.
1..=1 => {
println!("{}", "1");
}
_ => {
println!("{}", "empty");
}
}
}
#[test]
fn without_error10() {
match 10 {
... | code_fim | medium | {
"lang": "rust",
"repo": "rustkas/error-index",
"path": "/main_tests/tests/e0030.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn with_error() {
//TODO uncomment the lines below
// match 5 {
//
// // This range is empty, and the compiler can tell.
// 6 ..= 5 => {}
// }
}
#[test]
fn without_error1() {
match 1 {
... | code_fim | medium | {
"lang": "rust",
"repo": "rustkas/error-index",
"path": "/main_tests/tests/e0030.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
time_granularity: items.iter().map(Into::into).max().unwrap_or_default(),
items: ZeroVec::clone_from_slice(&items),
}
}
}
impl From<reference::Pattern> for Pattern<'_> {
fn from(input: reference::Pattern) -> Self {
Self {
items: Z... | code_fim | hard | {
"lang": "rust",
"repo": "fabura/icu4x",
"path": "/components/datetime/src/pattern/runtime/pattern.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fabura/icu4x path: /components/datetime/src/pattern/runtime/pattern.rs
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
use super::super::{ref... | code_fim | hard | {
"lang": "rust",
"repo": "fabura/icu4x",
"path": "/components/datetime/src/pattern/runtime/pattern.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn visit_str<E>(self, pattern_string: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
// Parse a string into a list of fields.
let reference_deserializer =
crate::pattern::reference::pattern::DeserializePatternUTS35String;
... | code_fim | hard | {
"lang": "rust",
"repo": "fabura/icu4x",
"path": "/components/datetime/src/pattern/runtime/pattern.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Syndim/actix-mqtt-client path: /src/actors/packets/unsubscribe.rs
use actix::{AsyncContext, Handler, Message};
use log::error;
use mqtt::packet::UnsubscribePacket;
use mqtt::TopicFilter;
use crate::actors::utils;
#[derive(Message)]
#[rtype(result = "()")]
pub struct Unsubscribe {
topic: St... | code_fim | hard | {
"lang": "rust",
"repo": "Syndim/actix-mqtt-client",
"path": "/src/actors/packets/unsubscribe.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Handler<Unsubscribe> for UnsubscribeActor {
type Result = ();
fn handle(&mut self, msg: Unsubscribe, ctx: &mut Self::Context) -> Self::Result {
let batch_msg = BatchUnsubscribe::new(vec![msg.topic]);
ctx.notify(batch_msg);
}
}<|fim_prefix|>// repo: Syndim/actix-mqtt-client... | code_fim | hard | {
"lang": "rust",
"repo": "Syndim/actix-mqtt-client",
"path": "/src/actors/packets/unsubscribe.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxdeviant/oldschool-rs path: /src/optimal_quest_guide.rs
count.completed_diaries.contains(&diary_id)
}
OptimalQuestGuideStep::Train { skill, to, .. } => {
&self.account.get_level(skill) >= to
}
})
.next(... | code_fim | hard | {
"lang": "rust",
"repo": "maxdeviant/oldschool-rs",
"path": "/src/optimal_quest_guide.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>: Level(42),
to: Level(60),
},
Quest(MOURNINGS_END_PART_I),
Quest(MOURNINGS_END_PART_II),
Train {
skill: Magic,
from: Level(59),
to: Level(65),
},
Train {
skill: Crafting,
from: Level(50... | code_fim | hard | {
"lang": "rust",
"repo": "maxdeviant/oldschool-rs",
"path": "/src/optimal_quest_guide.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>OBBERY),
Train {
skill: Crafting,
from: Level(46),
to: Level(50),
},
Quest(THE_HAND_IN_THE_SAND),
Train {
skill: Mining,
from: Level(41),
to: Level(45),
},
Quest(ENAKHRAS_LAMENT),
... | code_fim | hard | {
"lang": "rust",
"repo": "maxdeviant/oldschool-rs",
"path": "/src/optimal_quest_guide.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn write(&self, start: u16, size: usize, buf: &[u8]) {
let end = start + size as u16 - 1;
let pg_s_off = start & 0x1f;
let pg_e_off = end & 0x1f;
let pg_s = start >> 5;
let pg_e = end >> 5;
if pg_s == pg_e {
self.page_write(start, size, b... | code_fim | hard | {
"lang": "rust",
"repo": "Determinant/nixie-clock",
"path": "/src/at24c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Determinant/nixie-clock path: /src/at24c.rs
use i2c::{I2C, TransDir};
const AT24C_ADDR: u8 = 0b1010111; /* suppose A0, A1, A2 = 1 */
pub struct AT24C<'a>(&'a I2C<'a>);
impl<'a> AT24C<'a> {
pub fn read(&self, start: u16, size: usize, buf: &mut [u8]) {
let &AT24C(ref i2c) = self;
... | code_fim | hard | {
"lang": "rust",
"repo": "Determinant/nixie-clock",
"path": "/src/at24c.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jonesey13/GG-Render-Playground path: /src/input/external_input.rs
use gg::input::{MouseInput, KeyboardInput, JoystickInput};
use gg::games::GameInput;
<|fim_suffix|> fn get_kbd_inp<'a>(&'a mut self) -> Option<&'a mut KeyboardInput> { Some(&mut self.kbd) }
fn get_joystick_inp<'a>(&'a mut ... | code_fim | hard | {
"lang": "rust",
"repo": "Jonesey13/GG-Render-Playground",
"path": "/src/input/external_input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_kbd_inp<'a>(&'a mut self) -> Option<&'a mut KeyboardInput> { Some(&mut self.kbd) }
fn get_joystick_inp<'a>(&'a mut self) -> Option<&'a mut JoystickInput> { Some(&mut self.joystick) }
}<|fim_prefix|>// repo: Jonesey13/GG-Render-Playground path: /src/input/external_input.rs
use gg::input::{M... | code_fim | medium | {
"lang": "rust",
"repo": "Jonesey13/GG-Render-Playground",
"path": "/src/input/external_input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-vmm/vmm-sys-util path: /src/linux/sock_ctrl_msg.rs
g_ptr as *mut u8).wrapping_add(CMSG_ALIGN!(cmsg.cmsg_len)) as *mut cmsghdr;
if next_cmsg
.wrapping_offset(1)
.wrapping_sub(msghdr.msg_control as usize) as usize
> msghdr.msg_controllen as usize
{
null... | code_fim | hard | {
"lang": "rust",
"repo": "rust-vmm/vmm-sys-util",
"path": "/src/linux/sock_ctrl_msg.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-vmm/vmm-sys-util path: /src/linux/sock_ctrl_msg.rs
Each of the following macros performs the same function as their C counterparts. They are each
// macros because they are used to size statically allocated arrays.
macro_rules! CMSG_ALIGN {
($len:expr) => {
(($len) as usize + s... | code_fim | hard | {
"lang": "rust",
"repo": "rust-vmm/vmm-sys-util",
"path": "/src/linux/sock_ctrl_msg.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Trait for types that can be converted into an `iovec` that can be referenced by a syscall for
/// the lifetime of this object.
///
/// # Safety
///
/// This is marked unsafe because the implementation must ensure that the returned pointer and size
/// is valid and that the lifetime of the returned poi... | code_fim | hard | {
"lang": "rust",
"repo": "rust-vmm/vmm-sys-util",
"path": "/src/linux/sock_ctrl_msg.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dirbaio/rp2040-pac path: /src/io.rs
use crate::generic::*;
#[derive(Copy, Clone)]
pub struct Int(pub *mut u8);
unsafe impl Send for Int {}
unsafe impl Sync for Int {}
impl Int {
#[doc = "Interrupt Enable for proc0"]
pub fn inte(self, n: usize) -> Reg<regs::Int, RW> {
assert!(n < ... | code_fim | hard | {
"lang": "rust",
"repo": "Dirbaio/rp2040-pac",
"path": "/src/io.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ize + n * 8usize)) }
}
#[doc = "Raw Interrupts"]
pub fn intr(self, n: usize) -> Reg<regs::Int, RW> {
assert!(n < 4usize);
unsafe { Reg::from_ptr(self.0.add(240usize + n * 4usize)) }
}
pub fn int_dormant_wake(self) -> Int {
unsafe { Int(self.0.add(352usize)) }
... | code_fim | hard | {
"lang": "rust",
"repo": "Dirbaio/rp2040-pac",
"path": "/src/io.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<A: Actor + actix::Handler<EventMessage>> Handler<StringMessage> for RsyslogCollectorActor<A>
where
<A as Actor>::Context: ToEnvelope<A, EventMessage>,
{
type Result = ();
fn handle(&mut self, msg: StringMessage, _: &mut Context<Self>) -> Self::Result {
debug!("RsyslogCollectorAct... | code_fim | hard | {
"lang": "rust",
"repo": "WuerthPhoenix/tornado",
"path": "/tornado/rsyslog_collector/src/actors/collector.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn handle(&mut self, msg: StringMessage, _: &mut Context<Self>) -> Self::Result {
debug!("RsyslogCollectorActor - received msg: [{}]", &msg.msg);
let _s = msg.span.entered();
match self.collector.to_event(&msg.msg) {
Ok(event) => self
.writer_addr
... | code_fim | hard | {
"lang": "rust",
"repo": "WuerthPhoenix/tornado",
"path": "/tornado/rsyslog_collector/src/actors/collector.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WuerthPhoenix/tornado path: /tornado/rsyslog_collector/src/actors/collector.rs
use actix::dev::ToEnvelope;
use actix::prelude::*;
use log::*;
use tornado_collector_common::Collector;
use tornado_collector_json::JsonPayloadCollector;
use tornado_common::actors::message::{EventMessage, StringMessa... | code_fim | medium | {
"lang": "rust",
"repo": "WuerthPhoenix/tornado",
"path": "/tornado/rsyslog_collector/src/actors/collector.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> web::block(move || {
let context = session::create_context(credentials.clone())
.expect("unable to create context");
let (mut em, mut dm) =
crate::session::get_em_dm(credentials).expect("must not error");
let table_name = TableName::from(¶m.0);
... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/diwata",
"path": "/crates/server/src/api.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize)]
pub struct DaoParam {
dao: String,
}
pub fn record_detail(
req: HttpRequest,
table_name_param: web::Path<String>,
dao_param: web::Query<DaoParam>,
) -> impl Future<Item = HttpResponse, Error = Error> {
require_credentials(&req).expect("Should have credent... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/diwata",
"path": "/crates/server/src/api.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ivanceras/diwata path: /crates/server/src/api.rs
use crate::{
credentials::Credentials,
error::ServiceError,
global,
session,
};
use actix_web::{
web,
Error,
HttpRequest,
HttpResponse,
};
use diwata_intel::{
data_read,
Dao,
TableName,
};
use futures::f... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/diwata",
"path": "/crates/server/src/api.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>(enum)..";denominator="..tostring(denom)..";")@
@/repeat@
Uoči da su ovi razlomci jednaki.<|fim_prefix|>// repo: bradunov/shkola path: /questions/fractions/q00078/text.rs
Koji deo figure je obojen? Zapiši razlomkom.
@repeat(4)@
@center@ @lib.select_objects(denom, 1, "table", "", style_tabl... | code_fim | medium | {
"lang": "rust",
"repo": "bradunov/shkola",
"path": "/questions/fractions/q00078/text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bradunov/shkola path: /questions/fractions/q00078/text.rs
Koji deo figure je obojen? Zapiši razlomkom.
@repeat(4)@
@center@ @lib.select_objects(denom, 1, "tab<|fim_suffix|>tor/denominator == "..tostring(enum).."/"..tostring(denom)..")", false, {},\
"numerator="..tostring(enum)..";denominat... | code_fim | medium | {
"lang": "rust",
"repo": "bradunov/shkola",
"path": "/questions/fractions/q00078/text.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tor/denominator == "..tostring(enum).."/"..tostring(denom)..")", false, {},\
"numerator="..tostring(enum)..";denominator="..tostring(denom)..";")@
@/repeat@
Uoči da su ovi razlomci jednaki.<|fim_prefix|>// repo: bradunov/shkola path: /questions/fractions/q00078/text.rs
Koji deo figure j... | code_fim | medium | {
"lang": "rust",
"repo": "bradunov/shkola",
"path": "/questions/fractions/q00078/text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_or_create_property_impl<'a>(
client: &ApiClient,
label: &str,
prop_type: PropertyDataType,
topo_id_id: impl Into<Option<&'a str>>,
) -> Result<String, Error> {
let claims = match topo_id_id.into() {
Some(id) => vec![claim_string(id, &label.to_snake_case())],
None... | code_fim | hard | {
"lang": "rust",
"repo": "Quantum-Platinum-Cloud/transport-topo",
"path": "/src/database_initializer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Quantum-Platinum-Cloud/transport-topo path: /src/database_initializer.rs
use crate::clients::api_client::{claim_item, claim_string};
use crate::clients::{
sparql_client, ApiClient, ApiError, ObjectType, PropertyDataType, SparqlClient,
};
use crate::known_entities::{EntitiesId, Items, Propert... | code_fim | hard | {
"lang": "rust",
"repo": "Quantum-Platinum-Cloud/transport-topo",
"path": "/src/database_initializer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let op1 = Operation::Delete { uuid };
assert_eq!(
db.apply(op1).err().unwrap().to_string(),
format!("Task Database Error: Task {} does not exist", uuid)
);
assert_eq!(db.sorted_tasks(), vec![]);
assert_eq!(db.operations(), vec![]);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "gravityvi/taskchampion",
"path": "/taskchampion/src/taskdb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gravityvi/taskchampion path: /taskchampion/src/taskdb.rs
g::{info, trace, warn};
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::str;
use uuid::Uuid;
/// A TaskDb is the backend for a replica. It manages the storage, operations, synchronization,
/// and so on, and ... | code_fim | hard | {
"lang": "rust",
"repo": "gravityvi/taskchampion",
"path": "/taskchampion/src/taskdb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_apply_create_update_delete_prop() {
let mut db = TaskDb::new_inmemory();
let uuid = Uuid::new_v4();
let op1 = Operation::Create { uuid };
db.apply(op1.clone()).unwrap();
let op2 = Operation::Update {
uuid,
property: S... | code_fim | hard | {
"lang": "rust",
"repo": "gravityvi/taskchampion",
"path": "/taskchampion/src/taskdb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>//impl Clone for ConsumerConfig{
// fn clone(&self) -> Self {
// self.index_name,
// self.
// }
//}<|fim_prefix|>// repo: vsop-479/transfer-rust path: /src/domain/consumer_config.rs
#[derive(Clone)]
pub struct ConsumerConfig {
pub index_name : String,
pub data_key : String,
... | code_fim | hard | {
"lang": "rust",
"repo": "vsop-479/transfer-rust",
"path": "/src/domain/consumer_config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vsop-479/transfer-rust path: /src/domain/consumer_config.rs
#[derive(Clone)]
pub struct ConsumerConfig {
pub index_name : String,
pub data_key : String,
pub batch : u32,
pub thread_num : u32
}
<|fim_suffix|>//impl Clone for ConsumerConfig{
// fn clone(&self) -> Self {
// ... | code_fim | hard | {
"lang": "rust",
"repo": "vsop-479/transfer-rust",
"path": "/src/domain/consumer_config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[fuchsia::test]
fn two_tags_with_message() {
let mut packet = test_packet();
let a_start = 1;
let a_count = 11;
let a_end = a_start + a_count;
packet.data[0] = a_count as c_char;
packet.fill_data(a_start..a_end, 'A' as _);
let b_start = a_end + 1;
let b_count = 5;
le... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/lib/diagnostics/log/message/rust/src/test.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // legacy verbosity where v=1
packet.metadata.severity = LogLevelFilter::Info as i32 - 1;
buffer = &packet.as_bytes()[..METADATA_SIZE + 2];
parsed = crate::from_logger(get_test_identity(), LoggerMessage::try_from(buffer).unwrap());
clear_legacy_verbosity(&mut expected_message);
exp... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/lib/diagnostics/log/message/rust/src/test.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/diagnostics/log/message/rust/src/test.rs
har(tag_len) + "tag2\0msg\0"`
data: [c_char; MAX_DATAGRAM_LEN - METADATA_SIZE],
}
#[fuchsia::test]
fn abi_test() {
assert_eq!(METADATA_SIZE, 32);
assert_eq!(MAX_TAGS, 5);
assert_eq!(MAX_TAG_LEN, 64);
as... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/lib/diagnostics/log/message/rust/src/test.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut tracker = Tracker::new(
[0; 20],
"http://localhost:8888".to_owned(),
[0; 20],
8888);
tracker.start(1000);
let start_resp = runtime.block_on(tracker).expect("start should not return error");
assert_eq!(start_resp, TrackerResponse::Success(
Tr... | code_fim | hard | {
"lang": "rust",
"repo": "jsandler18/boosttorrent2",
"path": "/src/tracker/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jsandler18/boosttorrent2 path: /src/tracker/test.rs
use crate::boostencode::Value;
use hyper::{
Body,
Request,
Response,
server::Server,
};
use maplit::hashmap;
use std::net::IpAddr;
use std::sync::{
Arc,
RwLock,
};
use super::*;
use tokio;
fn service_handler(_request_:... | code_fim | hard | {
"lang": "rust",
"repo": "jsandler18/boosttorrent2",
"path": "/src/tracker/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(start_resp, TrackerResponse::Success(
TrackerSuccessResponse {
interval: 10,
min_interval: None,
tracker_id: Some("i am the tracker".to_owned()),
complete: 10,
incomplete: 10,
peers: vec![PeerInfo {
... | code_fim | hard | {
"lang": "rust",
"repo": "jsandler18/boosttorrent2",
"path": "/src/tracker/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guyoung/CaptfEncoder path: /CaptfEncoder-V3/encoding/src/converter/internal/brainfuck/utils/ir.rs
use super::{Op, Program};
use std::fmt::{Debug, Error, Formatter};
/// Link (aka. pointer) to next operation in program graph.
type Link = Option<usize>;
/// Operations in intermediate repre... | code_fim | hard | {
"lang": "rust",
"repo": "guyoung/CaptfEncoder",
"path": "/CaptfEncoder-V3/encoding/src/converter/internal/brainfuck/utils/ir.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(generated)
}
fn optimize_program_once(&mut self) -> usize {
let mut idx = 0;
let mut len = 0;
loop {
if idx == std::usize::MAX {
return len;
}
let replacement = self.find_replacement(idx);
... | code_fim | hard | {
"lang": "rust",
"repo": "guyoung/CaptfEncoder",
"path": "/CaptfEncoder-V3/encoding/src/converter/internal/brainfuck/utils/ir.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pathbox/learning-rust path: /rust-by-example/conversion/src/main.rs
use std::convert::From;
use std::convert::TryFrom;
use std::convert::TryInto;
#[derive(Debug)]
struct Number {
value: i32,
}
#[derive(Debug, PartialEq)]
struct EvenNumber(i32);
impl TryFrom<i32> for EvenNumber {
type... | code_fim | hard | {
"lang": "rust",
"repo": "pathbox/learning-rust",
"path": "/rust-by-example/conversion/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if count == 3 {
println!("three");
continue;
}
println!("{}", count);
if count == 10 {
println!("OK, it's enough");
break;
}
}
'outer: loop {
println!("Entered the outer loop");
'inner: loo... | code_fim | hard | {
"lang": "rust",
"repo": "pathbox/learning-rust",
"path": "/rust-by-example/conversion/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let shapes = i.collect::<Vec<_>>();
Self { shapes }
}
fn intersect_ray(&self, r: &Ray3) -> Option<(SurfaceInteraction, &Shapes)> {
self
.shapes
.iter()
.filter_map(|s| s.intersect_ray(r).map(|si| (si, s)))
.filter(|(si, _)| si.it.t > f32::EPSILON)
.max_by(|a, ... | code_fim | medium | {
"lang": "rust",
"repo": "JulianKnodt/mireba",
"path": "/src/accelerator/naive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JulianKnodt/mireba path: /src/accelerator/naive.rs
use super::Accelerator;
use crate::{interaction::SurfaceInteraction, shapes::Shapes};
use quick_maths::Ray3;
<|fim_suffix|>impl Accelerator for Naive {
fn build(i: impl Iterator<Item = Shapes>) -> Self {
let shapes = i.collect::<Vec<_>>()... | code_fim | medium | {
"lang": "rust",
"repo": "JulianKnodt/mireba",
"path": "/src/accelerator/naive.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hgzimmerman/visualization path: /sierpinski/src/sierpinski.rs
use common::l_system::Grammar;
use nannou::geom::Point2;
///
/// Angle should be 120 deg
#[derive(Clone, Copy, Debug)]
pub enum Sierpinski {
F,
G,
Plus,
Minus
}
impl Grammar for Sierpinski {
type Item = Point2;
... | code_fim | hard | {
"lang": "rust",
"repo": "hgzimmerman/visualization",
"path": "/sierpinski/src/sierpinski.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
use Sierpinski::*;
let cpy = current_pt.clone();
match v {
F => *current_pt = line_to(*current_pt, *current_angle, line_length),
G => *current_pt = line_to(*current_pt, *current_angle, line_length),
Plus => *current_angle -= angle_step,
... | code_fim | hard | {
"lang": "rust",
"repo": "hgzimmerman/visualization",
"path": "/sierpinski/src/sierpinski.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Produces a new point from the current one
#[inline]
fn line_to(pt: Point2, angle: f32, line_length: f32) -> Point2 {
Point2 {
x: pt.x + line_length * angle.cos(),
y: pt.y + line_length * angle.sin()
}
}<|fim_prefix|>// repo: hgzimmerman/visualization path: /sierpinski/src/sie... | code_fim | hard | {
"lang": "rust",
"repo": "hgzimmerman/visualization",
"path": "/sierpinski/src/sierpinski.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::fmt;
use std::fmt::Debug;
impl Debug for ArrayBuffer {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("ArrayBuffer len: {}",self.data.len()))
}
}<|fim_prefix|>// repo: Ryanmtate/node-bindgen path: /nj-core/src/buffer.rs
use std::ptr;
u... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/node-bindgen",
"path": "/nj-core/src/buffer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ryanmtate/node-bindgen path: /nj-core/src/buffer.rs
use std::ptr;
use log::trace;
use crate::TryIntoJs;
use crate::sys::napi_value;
use crate::sys::napi_env;
use crate::val::JsEnv;
use crate::NjError;
/// pass rust byte arry as Node.js ArrayBuffer
pub struct ArrayBuffer{
data: Vec<u8>
}... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/node-bindgen",
"path": "/nj-core/src/buffer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn try_to_js(self, js_env: &JsEnv) -> Result<napi_value,NjError> {
let len = self.data.len();
let box_data = Box::new(self.data);
let mut napi_buffer = ptr::null_mut();
// get pointer to vec's buffer
let data_buffer = box_data.as_ptr();
// g... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/node-bindgen",
"path": "/nj-core/src/buffer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/sns/src/client.rs
pub fn set_resource_arn(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_resource_arn(input);
self
}
}
#[derive(std::fmt::Debug)]
pub struct ListTopics<... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/sns/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/sns/src/client.rs
<crate::error::ListPhoneNumbersOptedOutError>,
>
where
R::Policy: smithy_client::bounds::SmithyRetryPolicy<
crate::input::ListPhoneNumbersOptedOutInputOperationOutputAlias,
crate::output:... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/sns/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub struct ListTagsForResource<
C = smithy_client::erase::DynConnector,
M = aws_hyper::AwsMiddleware,
R = smithy_client::retry::Standard,
> {
handle: std::sync::Arc<super::Handle<C, M, R>>,
inner: crate::input::list_tags_for_resource_input::Builder,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/sns/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GuildOfWeavers/winterfell path: /fri/src/verifier/mod.rs
CENSE file in the root directory of this source tree.
//! Contains an implementation of FRI verifier and associated components.
use crate::{folding::fold_positions, utils::map_positions_to_indexes, FriOptions, VerifierError};
use core::{... | code_fim | hard | {
"lang": "rust",
"repo": "GuildOfWeavers/winterfell",
"path": "/fri/src/verifier/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // make sure the remainder values satisfy the degree
verify_remainder(remainder, max_degree_plus_1 - 1)
}
}
// REMAINDER DEGREE VERIFICATION
// ================================================================================================
/// Returns Ok(true) if values in the `remai... | code_fim | hard | {
"lang": "rust",
"repo": "GuildOfWeavers/winterfell",
"path": "/fri/src/verifier/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GuildOfWeavers/winterfell path: /fri/src/verifier/mod.rs
the MIT license found in the
// LICENSE file in the root directory of this source tree.
//! Contains an implementation of FRI verifier and associated components.
use crate::{folding::fold_positions, utils::map_positions_to_indexes, FriOp... | code_fim | hard | {
"lang": "rust",
"repo": "GuildOfWeavers/winterfell",
"path": "/fri/src/verifier/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self(fut.boxed())
}
}
impl<F, T> From<F> for Job<T>
where
F: Future<Output = T> + Send + 'static,
{
fn from(fut: F) -> Self {
Self::Future(fut.into())
}
}
pub fn assert_request_job(_: impl IsRequest) {}
pub fn assert_response_job(_: impl IsResponse) {}<|fim_prefix|>// re... | code_fim | hard | {
"lang": "rust",
"repo": "petar-dambovaliev/darpi",
"path": "/darpi-web/src/job.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: petar-dambovaliev/darpi path: /darpi-web/src/job.rs
use crate::{Body, Response};
use async_trait::async_trait;
use futures::Future;
use futures_util::FutureExt;
use http::request::Parts as RequestParts;
use std::pin::Pin;
use std::sync::Arc;
#[async_trait]
pub trait RequestJobFactory<C, T = ()>... | code_fim | hard | {
"lang": "rust",
"repo": "petar-dambovaliev/darpi",
"path": "/darpi-web/src/job.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait IsResponse {}
pub enum Job<T = ()> {
Future(FutureJob<T>),
CpuBound(CpuJob<T>),
IOBlocking(IOBlockingJob<T>),
}
impl<T> From<FutureJob<T>> for Job<T> {
fn from(fut: FutureJob<T>) -> Self {
Self::Future(fut)
}
}
impl<T> From<CpuJob<T>> for Job<T> {
fn from(job: C... | code_fim | hard | {
"lang": "rust",
"repo": "petar-dambovaliev/darpi",
"path": "/darpi-web/src/job.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.