text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/zip/src/result.rs
use
std
:
:
error
:
:
Error
;
use
std
:
:
fmt
;
use
std
:
:
io
;
pub
type
ZipResult
<
T
>
=
Result
<
T
ZipError
>
;
#
[
derive
(
Debug
)
]
pub
struct
InvalidPassword
;
impl
fmt
:
:
Display
for
InvalidPassw... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/zip/src/result.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
:
UnsupportedArchive
(
err
)
=
>
write
!
(
fmt
"
unsupported
Zip
archive
:
{
err
}
"
)
ZipError
:
:
FileNotFound
=
>
write
!
(
fmt
"
specified
file
not
found
in
archive
"
)
}
}
}
impl
Error
for
ZipError
{
fn
source
(
&
self
)
-
>
Option
<
&
(
dyn
Error
+
'
static
)
>
{
match
self
{
ZipError
:
:
Io
(
err
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/zip/src/result.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: x7c1/plus path: /libs/aws/plus-aws/src/http/request/headers/header_map.rs
use crate::auth::v4::request::AuthorizationFactory;
use crate::http::request::ToHeaderFragment;
use crate::Error::HostNotFound;
use http::header::{AUTHORIZATION, HOST};
use http::HeaderMap;
use url::Url;
pub trait RichHea... | code_fim | hard | {
"lang": "rust",
"repo": "x7c1/plus",
"path": "/libs/aws/plus-aws/src/http/request/headers/header_map.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
A: ToHeaderFragment,
{
if let Some(header) = header {
self.push(header)
} else {
Ok(self)
}
}
fn host(mut self, url: &Url) -> crate::Result<Self> {
let host = url
.host_str()
.ok_or_else(|| HostN... | code_fim | hard | {
"lang": "rust",
"repo": "x7c1/plus",
"path": "/libs/aws/plus-aws/src/http/request/headers/header_map.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn known_id() {
let mut d = Diagnostics::default();
validate_id(&mut d, "", "Sn1");
assert_eq!(d.messages.len(), 0);
assert_eq!(d.errors, 0);
assert_eq!(d.warnings, 0);
}
#[test]
fn self_ref_context() {
let mut d = Diagnostics::d... | code_fim | hard | {
"lang": "rust",
"repo": "jonasthewolf/gsn2x",
"path": "/src/gsn/validation.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut d = Diagnostics::default();
let mut nodes = BTreeMap::<String, GsnNode>::new();
nodes.insert(
"C1".to_owned(),
GsnNode {
supported_by: Some(vec!["C1".to_owned()]),
..Default::default()
},
);
... | code_fim | hard | {
"lang": "rust",
"repo": "jonasthewolf/gsn2x",
"path": "/src/gsn/validation.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonasthewolf/gsn2x path: /src/gsn/validation.rs
d, in_context, "context", &valid_refs);
}
if let Some(support) = node.supported_by.as_ref() {
let mut valid_refs = vec![];
// Only goals and strategies can have other goals, strategies and solutions
if id.starts_with... | code_fim | hard | {
"lang": "rust",
"repo": "jonasthewolf/gsn2x",
"path": "/src/gsn/validation.rs",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: grounzero/juniper path: /juniper/src/macros/helper/mod.rs
//! Helper traits and definitions for macros.
pub mod subscription;
use std::fmt;
use futures::future::{self, BoxFuture};
use crate::FieldError;
/// This trait is used by [`graphql_scalar!`] macro to retrieve [`Error`] type
/// from ... | code_fim | hard | {
"lang": "rust",
"repo": "grounzero/juniper",
"path": "/juniper/src/macros/helper/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Wraps `msg` with [`Display`] implementation into opaque [`Send`] [`Future`]
/// which immediately resolves into [`FieldError`].
pub fn err_fut<'ok, D, Ok, S>(msg: D) -> BoxFuture<'ok, Result<Ok, FieldError<S>>>
where
D: fmt::Display,
Ok: Send + 'ok,
S: Send + 'static,
{
Box::pin(future... | code_fim | medium | {
"lang": "rust",
"repo": "grounzero/juniper",
"path": "/juniper/src/macros/helper/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: j2ghz/prometheus_jfplaybackreporting_exporter path: /src/main.rs
use futures::stream::StreamExt;
use prometheus_exporter_base::render_prometheus;
use prometheus_jfplaybackreporting_exporter::{read_file, render};
use std::{env, path::Path};
use tokio::fs::read_dir;
#[tokio::main]
async fn main()... | code_fim | hard | {
"lang": "rust",
"repo": "j2ghz/prometheus_jfplaybackreporting_exporter",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>path(), modif))
}
} else {
Some((file.path(), modif))
}
})
.await
.expect("No files found");
eprintln!("Reading {}", file.display());
let reader =... | code_fim | hard | {
"lang": "rust",
"repo": "j2ghz/prometheus_jfplaybackreporting_exporter",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nlopin/rust-hacker-rank path: /jumping_on_the_clouds/src/main.rs
use std::io;
use std::io::BufRead;
enum Cloud {
Cumulus,
Thunderheads,
}
fn main() {
<|fim_suffix|> let mut position: usize = 0;
let mut hops = 0;
while position != (clouds.len() - 1) {
... | code_fim | hard | {
"lang": "rust",
"repo": "nlopin/rust-hacker-rank",
"path": "/jumping_on_the_clouds/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut position: usize = 0;
let mut hops = 0;
while position != (clouds.len() - 1) {
let best_position = position + 2;
position = match clouds.get(best_position) {
Some(c) => if let Cloud::Cumulus = c { best_position ... | code_fim | hard | {
"lang": "rust",
"repo": "nlopin/rust-hacker-rank",
"path": "/jumping_on_the_clouds/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imorph/vector path: /src/internal_events/heartbeat.rs
use super::InternalEvent;
use metrics::gauge;
use std::time::Instant;
#[derive(Debug)]
pub struct Heartbeat {
pub since: Instant,
}
impl InternalEvent for Heartbeat {
fn emit_logs(&self) {
<|fim_suffix|> gauge!("uptime_second... | code_fim | medium | {
"lang": "rust",
"repo": "imorph/vector",
"path": "/src/internal_events/heartbeat.rs",
"mode": "psm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> gauge!("uptime_seconds", self.since.elapsed().as_secs() as f64);
}
}<|fim_prefix|>// repo: imorph/vector path: /src/internal_events/heartbeat.rs
use super::InternalEvent;
use metrics::gauge;
use std::time::Instant;
#[derive(Debug)]
pub struct Heartbeat {
pub since: Instant,
}
<|fim_midd... | code_fim | medium | {
"lang": "rust",
"repo": "imorph/vector",
"path": "/src/internal_events/heartbeat.rs",
"mode": "spm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Please input your guess.");
let mut guess = String::new(); //variables are immutable by default but mut makes them mutable.
//String::new() creates a new, empty String.
io::stdin().read_line(&mut guess) // calls stdin which takes user input, then save the input to the guess va... | code_fim | medium | {
"lang": "rust",
"repo": "Neats29/rusty",
"path": "/guessing_game/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut guess = String::new(); //variables are immutable by default but mut makes them mutable.
//String::new() creates a new, empty String.
io::stdin().read_line(&mut guess) // calls stdin which takes user input, then save the input to the guess variable, hence why it needs to be mutable. i... | code_fim | medium | {
"lang": "rust",
"repo": "Neats29/rusty",
"path": "/guessing_game/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Neats29/rusty path: /guessing_game/src/main.rs
extern crate rand;
use std::io; //use is a bit like import, io is the library from the standard library
use rand::Rng;
<|fim_suffix|> println!("Please input your guess.");
let mut guess = String::new(); //variables are immutable by default... | code_fim | medium | {
"lang": "rust",
"repo": "Neats29/rusty",
"path": "/guessing_game/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crowell/radeco-lib path: /src/middle/mod.rs
//! Components processing data in SSA for<|fim_suffix|>iplacement;
pub mod regfile;
pub mod ssa;<|fim_middle|>m.
pub mod cfg;
pub mod dce;
pub mod display;
pub mod dot;
pub mod ir;
pub mod ph | code_fim | medium | {
"lang": "rust",
"repo": "crowell/radeco-lib",
"path": "/src/middle/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>iplacement;
pub mod regfile;
pub mod ssa;<|fim_prefix|>// repo: crowell/radeco-lib path: /src/middle/mod.rs
//! Components processing data in SSA form.
pub mod cfg;
pub mod dce;
pub mod dis<|fim_middle|>play;
pub mod dot;
pub mod ir;
pub mod ph | code_fim | easy | {
"lang": "rust",
"repo": "crowell/radeco-lib",
"path": "/src/middle/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: claytongentry/mail path: /src/oauth2.rs
use jsonwebtoken::{
decode, encode, Algorithm, DecodingKey, EncodingKey, Header, TokenData, Validation,
};
use serde::{Deserialize, Serialize};
use std::env;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
#[derive(Debug, Serialize, Deserialize)]
p... | code_fim | hard | {
"lang": "rust",
"repo": "claytongentry/mail",
"path": "/src/oauth2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let one_hour = Duration::new(60 * 60, 0);
let in_one_hour = SystemTime::now() + one_hour;
let exp = in_one_hour.duration_since(UNIX_EPOCH).unwrap().as_secs();
let claims = Claims { exp: exp };
let key = get_key();
let key_ref = key.as_ref();
encode(
&Header::default(... | code_fim | hard | {
"lang": "rust",
"repo": "claytongentry/mail",
"path": "/src/oauth2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JOE1994/tock path: /capsules/src/text_screen.rs
//! Provides userspace with access to the text screen.
//!
//! Usage:
//! -----
//!
//! You need a screen that provides the `hil::text_screen::TextScreen`
//! trait.
//!
//! ```rust
//! let text_screen = components::text_screen::TextScreenComponent... | code_fim | hard | {
"lang": "rust",
"repo": "JOE1994/tock",
"path": "/capsules/src/text_screen.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check for pending events.
for app in self.apps.iter() {
let current_command = app.enter(|app, _| {
if app.pending_command {
app.pending_command = false;
self.current_app.set(app.appid());
let r = sel... | code_fim | hard | {
"lang": "rust",
"repo": "JOE1994/tock",
"path": "/capsules/src/text_screen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tirust/msp432e4 path: /src/pwm0/_2_fltsrc0.rs
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::_2_FLTSRC0 {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
... | code_fim | hard | {
"lang": "rust",
"repo": "tirust/msp432e4",
"path": "/src/pwm0/_2_fltsrc0.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
#[doc = r"Value of the register as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bit 0 - Fault0 Input"]
#[inline(always)]
pub fn pwm_2_fltsrc0_fault0(&self) -> PWM_2_FLTSRC0_FAULT0R {
let bits = ((self.bits >> 0) & 1) != 0;
... | code_fim | hard | {
"lang": "rust",
"repo": "tirust/msp432e4",
"path": "/src/pwm0/_2_fltsrc0.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub enum Atom {
Unit,
Bool(bool),
Int(i64),
String(String),
}
impl fmt::Display for Atom {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Atom::Int(i) => write!(f, "{}", i),
... | code_fim | hard | {
"lang": "rust",
"repo": "Munksgaard/pdb",
"path": "/src/ast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Munksgaard/pdb path: /src/ast.rs
use serde_derive::{Deserialize, Serialize};
use std::fmt;
#[cfg(test)]
mod test;
pub type Ident = String;
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub enum Ty {
Int,
Bool,
Tuple(Vec<Ty>),
Unit,
String,
Record(Vec<(Iden... | code_fim | hard | {
"lang": "rust",
"repo": "Munksgaard/pdb",
"path": "/src/ast.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum Statement {
Create(Ident, TableDefinition),
Insert(Ident, Expr),
Select(Ident),
Let(Ident, Expr),
Union(Ident, Vec<Ident>, Vec<(Ident, Vec<Ty>)>),
}
impl fmt::Display for Statement {
fn fmt(&self, f: &mut fmt::Formatter<... | code_fim | hard | {
"lang": "rust",
"repo": "Munksgaard/pdb",
"path": "/src/ast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use crate::{
builtins::{int, PyStr},
PyObjectRef,
};
use malachite_bigint::ToBigInt;
#[test]
fn test_add_py_integers() {
Interpreter::without_stdlib(Default::default()).enter(|vm| {
let a: PyObjectRef = vm.... | code_fim | hard | {
"lang": "rust",
"repo": "RustPython/RustPython",
"path": "/vm/src/vm/interpreter.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustPython/RustPython path: /vm/src/vm/interpreter.rs
use super::{setting::Settings, thread, Context, VirtualMachine};
use crate::{
stdlib::{atexit, sys},
PyResult,
};
use std::sync::atomic::Ordering;
/// The general interface for the VM
///
/// # Examples
/// Runs a simple embedded hel... | code_fim | hard | {
"lang": "rust",
"repo": "RustPython/RustPython",
"path": "/vm/src/vm/interpreter.rs",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> flush_std(vm);
exit_code
})
}
}
pub(crate) fn flush_std(vm: &VirtualMachine) {
if let Ok(stdout) = sys::get_stdout(vm) {
let _ = vm.call_method(&stdout, identifier!(vm, flush).as_str(), ());
}
if let Ok(stderr) = sys::get_stderr(vm) {
let _... | code_fim | hard | {
"lang": "rust",
"repo": "RustPython/RustPython",
"path": "/vm/src/vm/interpreter.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if is_dir {
let from_contents_checksum =
from_child.tree_get_contents_checksum().expect("checksum");
let to_contents_checksum = to_child.tree_get_contents_checksum().expect("checksum");
if from_contents_checksum != to_contents... | code_fim | hard | {
"lang": "rust",
"repo": "kelvinfan001/ostree-rs-ext",
"path": "/lib/src/diff.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn diff_recurse(
prefix: &str,
diff: &mut FileTreeDiff,
from: &ostree::RepoFile,
to: &ostree::RepoFile,
) -> Result<()> {
let cancellable = gio::NONE_CANCELLABLE;
let queryattrs = "standard::name,standard::type";
let queryflags = gio::FileQueryInfoFlags::NOFOLLOW_SYMLINKS;
... | code_fim | hard | {
"lang": "rust",
"repo": "kelvinfan001/ostree-rs-ext",
"path": "/lib/src/diff.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kelvinfan001/ostree-rs-ext path: /lib/src/diff.rs
//! Compute the difference between two OSTree commits.
/*
* Copyright (C) 2020 Red Hat, Inc.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*/
use anyhow::{Context, Result};
use fn_error_context::context;
use gio::prelude::*;
use ostree::Re... | code_fim | hard | {
"lang": "rust",
"repo": "kelvinfan001/ostree-rs-ext",
"path": "/lib/src/diff.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TypeTagQuery {
pub fn into_inner(self) -> (TypeTag, Option<u128>) {
self.into()
}
}
pub fn parse(s: &str) -> Result<TypeTagQuery, Error> {
let map_err = |err: Vec<(Loc, String)>| {
anyhow!("Query parsing error:\n\t{:}", {
let strs: Vec<_> = err
... | code_fim | hard | {
"lang": "rust",
"repo": "Krishnacore/move-tools",
"path": "/resource-viewer/src/tte.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match tok {
Tok::LBracket => {
i = {
assert_eq!(lexer.peek(), Tok::NumValue);
let res = match u128::from_str(lexer.content()) {
Ok(i) => Ok(i),
Err(_) => Err(anyhow!("largest number ... | code_fim | hard | {
"lang": "rust",
"repo": "Krishnacore/move-tools",
"path": "/resource-viewer/src/tte.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Krishnacore/move-tools path: /resource-viewer/src/tte.rs
use std::str::FromStr;
use anyhow::{Result, Error, anyhow};
use move_ir_types::location::Loc;
use move_core_types::language_storage::TypeTag;
use lang::lexer::unwrap_spanned_ty;
use move_lang::parser::lexer::{Lexer, Tok};
use move_lang::... | code_fim | hard | {
"lang": "rust",
"repo": "Krishnacore/move-tools",
"path": "/resource-viewer/src/tte.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bmatcuk/adventofcode2019 path: /day06/src/bin/part1.rs
//! --- Day 6: Universal Orbit Map ---
//!
//! You've landed at the Universal Orbit Map facility on Mercury. Because navigation in space often
//! involves transferring between orbits, the orbit maps here are useful for finding efficient
//!... | code_fim | hard | {
"lang": "rust",
"repo": "bmatcuk/adventofcode2019",
"path": "/day06/src/bin/part1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.orbits.as_ref() {
Some(planet) => 1 + planet.borrow().count_orbits(),
None => 0,
}
}
}
fn main() -> Result<(), Box<dyn Error>> {
let file = File::open("input.txt")?;
let reader = BufReader::new(file);
let mut planets: HashMap<_, Rc<RefCe... | code_fim | hard | {
"lang": "rust",
"repo": "bmatcuk/adventofcode2019",
"path": "/day06/src/bin/part1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SuperiorJT/twilight path: /model/src/channel/channel_type.rs
use serde_repr::{Deserialize_repr, Serialize_repr};
#[derive(
Clone, Copy, Debug, Deserialize_repr, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize_repr,
)]
#[repr(u8)]
pub enum ChannelType {
GuildText = 0,
Private = 1,
... | code_fim | hard | {
"lang": "rust",
"repo": "SuperiorJT/twilight",
"path": "/model/src/channel/channel_type.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_variants() {
serde_test::assert_tokens(&ChannelType::GuildText, &[Token::U8(0)]);
serde_test::assert_tokens(&ChannelType::Private, &[Token::U8(1)]);
serde_test::assert_tokens(&ChannelType::GuildVoice, &[Token::U8(2)]);
serde_test::assert_tokens(&Chan... | code_fim | medium | {
"lang": "rust",
"repo": "SuperiorJT/twilight",
"path": "/model/src/channel/channel_type.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hansjorg/rusoto path: /tests/ecs.rs
#![cfg(feature = "ecs")]
extern crate rusoto;
use rusoto::ecs::{ECSClient, ECSError, ListClustersRequest};
use rusoto::credentials::DefaultAWSCredentialsProviderChain;
use rusoto::regions::Region;
#[test]
fn main() {
let credentials = DefaultAWSCredenti... | code_fim | hard | {
"lang": "rust",
"repo": "hansjorg/rusoto",
"path": "/tests/ecs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // http://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListClusters.html
match ecs.list_clusters(&ListClustersRequest::default()) {
Ok(clusters) => {
for arn in clusters.clusterArns.unwrap_or(vec![]) {
println!("arn -> {:?}", arn);
}
... | code_fim | medium | {
"lang": "rust",
"repo": "hansjorg/rusoto",
"path": "/tests/ecs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let credentials = DefaultAWSCredentialsProviderChain::new();
let region = Region::UsEast1;
let mut ecs = ECSClient::new(
credentials,
®ion
);
// http://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListClusters.html
match ecs.list_clusters(&ListClustersR... | code_fim | medium | {
"lang": "rust",
"repo": "hansjorg/rusoto",
"path": "/tests/ecs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>acro::TokenStream,
) -> proc_macro::TokenStream {
MACRO.proc_macro_attribute(stringify!(ctor), args, input)
}
#[doc = " Marks a function as a library/executable destructor. This uses OS-specific"]
#[doc = " linker sections to call a specific function at termination time."]
#[doc = ""]
#[doc = " Multip... | code_fim | hard | {
"lang": "rust",
"repo": "jakobhellermann/watt-contrib",
"path": "/ctor/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakobhellermann/watt-contrib path: /ctor/src/lib.rs
static WASM: &[u8] = include_bytes!("ctor.wasm");
static MACRO: watt::WasmMacro = watt::WasmMacro::new(WASM);
#[doc = " Marks a function or static variable as a library/executable constructor."]
#[doc = " This uses OS-specific linker sections t... | code_fim | hard | {
"lang": "rust",
"repo": "jakobhellermann/watt-contrib",
"path": "/ctor/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crab2313/pci-range path: /src/main.rs
use std::env::args;
use std::process::exit;
fn print_help() {
println!("Usage:");
println!(" pci-range <cell1> <cell2> .. <cell7>");
}
#[derive(Debug)]
struct PCIMap {
high: Option<u32>,
mid: Option<u32>,
low: Option<u32>,
phy_... | code_fim | hard | {
"lang": "rust",
"repo": "crab2313/pci-range",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args().len() != 8 {
print_help();
exit(1);
}
let args: Vec<Option<u32>> = args().skip(1).map(|s|
u32::from_str_radix(s.trim_start_matches("0x"), 16).ok()
).chain(std::iter::repeat(None)).take(7).collect();
let map = PCIMap {
high: args[0],
... | code_fim | hard | {
"lang": "rust",
"repo": "crab2313/pci-range",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: max-ym/kobzar_env path: /src/msg.rs
//! Messaging
use core::marker::PhantomData;
use alloc::rc::Rc;
use crate::thread::Thread;
use crate::path::{Interface, Network};
use core::time::Duration;
use crate::{kobzar_env, KobzarEnv};
/// Receiver is used to receive messages from other selected threa... | code_fim | hard | {
"lang": "rust",
"repo": "max-ym/kobzar_env",
"path": "/src/msg.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<I: Input> Receiver<I> {
/// Try creating receiver for given interface. It will return None if mailbox has no
/// mail that matches interface.
///
/// # Safety
/// Input type cannot be verified when receiving message and thus if an input type does not
/// match the one interfac... | code_fim | hard | {
"lang": "rust",
"repo": "max-ym/kobzar_env",
"path": "/src/msg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alistairmgreen/AdventOfCode2017 path: /day3/src/lib.rs
pub mod part1;
pub mod part2;
pub const PUZZLE_INPUT: usize = 289326;
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
enum Direction {
North,
South,
West,
East,
}
impl Direction {
fn turn_left(&self) -> Direction {
... | code_fim | hard | {
"lang": "rust",
"repo": "alistairmgreen/AdventOfCode2017",
"path": "/day3/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn neighbours(&self) -> Vec<Displacement> {
vec![
Displacement {
north: self.north + 1,
east: self.east,
},
Displacement {
north: self.north + 1,
east: self.east + 1,
},
... | code_fim | hard | {
"lang": "rust",
"repo": "alistairmgreen/AdventOfCode2017",
"path": "/day3/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Displacement {
fn new() -> Displacement {
Displacement { north: 0, east: 0 }
}
fn manhattan_distance(&self) -> i32 {
self.north.abs() + self.east.abs()
}
fn step(&self, direction: &Direction) -> Displacement {
match *direction {
Direction::Nor... | code_fim | hard | {
"lang": "rust",
"repo": "alistairmgreen/AdventOfCode2017",
"path": "/day3/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Narigo/aocrs19 path: /src/aoc09/mod.rs
use crate::intcode_compute::computer_1202;
use std::collections::VecDeque;
use std::fs;
<|fim_suffix|>pub fn boost_02() -> VecDeque<i64> {
let filename = "./src/aoc09/input.txt";
let contents = fs::read_to_string(filename).expect("Something went wrong ... | code_fim | hard | {
"lang": "rust",
"repo": "Narigo/aocrs19",
"path": "/src/aoc09/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn boost_02() -> VecDeque<i64> {
let filename = "./src/aoc09/input.txt";
let contents = fs::read_to_string(filename).expect("Something went wrong reading the file");
let result = computer_1202(&contents, false, &mut VecDeque::from(vec![2]));
result.output
}<|fim_prefix|>// repo: Narigo/aocrs19... | code_fim | hard | {
"lang": "rust",
"repo": "Narigo/aocrs19",
"path": "/src/aoc09/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let client = reqwest::Client::new();
let url = format!("https://api.telegram.org/bot{}/sendMessage", &self.token);
client.post(&url)
.json(&map)
.send()
.await.unwrap();
}
}<|fim_prefix|>// repo: savelev1/telegram-icodrops-parser path: /src/... | code_fim | hard | {
"lang": "rust",
"repo": "savelev1/telegram-icodrops-parser",
"path": "/src/tg_bot/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn send_message(&self, message: &mut Message) {
let mut map = HashMap::new();
let chat_id = &message.chat_id.to_string();
let disable_web_page_preview = &message.disable_web_page_preview.to_string();
let disable_notification = &message.disable_notification.to_... | code_fim | medium | {
"lang": "rust",
"repo": "savelev1/telegram-icodrops-parser",
"path": "/src/tg_bot/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: savelev1/telegram-icodrops-parser path: /src/tg_bot/mod.rs
pub mod message;
use std::collections::HashMap;
use crate::tg_bot::message::Message;
pub struct TgBot {
token: String,
}
impl TgBot {
pub fn new(token: &String) -> TgBot {
TgBot {
token: token.clone(),
... | code_fim | hard | {
"lang": "rust",
"repo": "savelev1/telegram-icodrops-parser",
"path": "/src/tg_bot/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IceSentry/advent_of_code_2020 path: /src/day04.rs
use regex::Regex;
use serde_scan::scan;
use std::collections::HashMap;
fn contains_keys(passport: &HashMap<String, String>) -> bool {
passport.contains_key("byr")
&& passport.contains_key("iyr")
&& passport.contains_ke... | code_fim | hard | {
"lang": "rust",
"repo": "IceSentry/advent_of_code_2020",
"path": "/src/day04.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
pub fn part_1() {
let input = super::parse(INPUTS);
println!("{:?}", input);
let result = super::part_1(&input);
println!("result: {}", result);
assert!(result == 2);
}
#[test]
pub fn part_2_invalid() {
let invalid... | code_fim | hard | {
"lang": "rust",
"repo": "IceSentry/advent_of_code_2020",
"path": "/src/day04.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: suryapandian/rust path: /examples/08.user_input/08_standard_input.rs
use std::io;
fn main() {
<|fim_suffix|> let number: i32 = buffer.trim().parse().unwrap();
println!("number + 1 is {}", number + 1);
}<|fim_middle|> let mut buffer = String::new();
println!("Enter a message:");
... | code_fim | medium | {
"lang": "rust",
"repo": "suryapandian/rust",
"path": "/examples/08.user_input/08_standard_input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let number: i32 = buffer.trim().parse().unwrap();
println!("number + 1 is {}", number + 1);
}<|fim_prefix|>// repo: suryapandian/rust path: /examples/08.user_input/08_standard_input.rs
use std::io;
fn main() {
<|fim_middle|> let mut buffer = String::new();
println!("Enter a message:");
... | code_fim | medium | {
"lang": "rust",
"repo": "suryapandian/rust",
"path": "/examples/08.user_input/08_standard_input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> >> 8) & 0xff) as u8, (x & 0xff) as u8)
}<|fim_prefix|>// repo: jarhill0/rlox path: /src/bits.rs
pub fn to_u16(lo: u8, hi: u8) -> u16 {
<|fim_middle|> (hi as u16) << 8 | lo as u16
}
pub fn from_u16(x: u16) -> (u8, u8) {
(((x | code_fim | medium | {
"lang": "rust",
"repo": "jarhill0/rlox",
"path": "/src/bits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jarhill0/rlox path: /src/bits.rs
pub fn to_u16(lo: u8, hi: u8) -> u16 {
<|fim_suffix|> >> 8) & 0xff) as u8, (x & 0xff) as u8)
}<|fim_middle|> (hi as u16) << 8 | lo as u16
}
pub fn from_u16(x: u16) -> (u8, u8) {
(((x | code_fim | medium | {
"lang": "rust",
"repo": "jarhill0/rlox",
"path": "/src/bits.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n: u32 = read_line().trim().parse().expect("");
println!(
"{}",
if n < 5 {
"few"
} else if n < 10 {
"several"
} else if n < 20 {
"pack"
} else if n < 50 {
"lots"
} else if n < 100 {
"hor... | code_fim | medium | {
"lang": "rust",
"repo": "k124k3n/competitive-programming-answer",
"path": "/timus/1785.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: k124k3n/competitive-programming-answer path: /timus/1785.rs
/*input
40
*/
fn read_line() -> String {
let mut return_ = format!("");
std::io::stdin().read_line(&mut return_).ok();
return_
}
<|fim_suffix|> let n: u32 = read_line().trim().parse().expect("");
println!(
"{... | code_fim | medium | {
"lang": "rust",
"repo": "k124k3n/competitive-programming-answer",
"path": "/timus/1785.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use crate::physics::primitives::vector::Vector2D;
#[test]
fn vector_magnitude() {
assert_eq!(Vector2D::new(5.0, 12.0).magnitude(), 13.0)
}
#[test]
fn vector_addition() {
assert_eq!(
Vector2D::new(1.0, 2.0) + Vector2D::new(-4.0,... | code_fim | hard | {
"lang": "rust",
"repo": "tmccarthy/n-body-rust",
"path": "/src/physics/primitives/vector.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tmccarthy/n-body-rust path: /src/physics/primitives/vector.rs
use core::ops;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::ops::Mul;
use crate::physics::primitives::Scalar;
#[derive(Debug, PartialEq, Copy, Clone)]
pub struct Vector2D {
pub x: Scalar,
pub y: Scalar,
}
impl... | code_fim | hard | {
"lang": "rust",
"repo": "tmccarthy/n-body-rust",
"path": "/src/physics/primitives/vector.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ops::Div<Scalar> for Vector2D {
type Output = Vector2D;
fn div(self, rhs: Scalar) -> Self::Output {
Vector2D {
x: self.x / rhs,
y: self.y / rhs,
}
}
}
impl ops::Mul<Vector2D> for Scalar {
type Output = Vector2D;
fn mul(self, rhs: Vector2D... | code_fim | hard | {
"lang": "rust",
"repo": "tmccarthy/n-body-rust",
"path": "/src/physics/primitives/vector.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlexanderChen1989/hello-tf path: /src/bin/infer_web.rs
use hello_tf::{
infer_client::InferClient, process_client::ProcessClient, InferRequest, InferResponse,
PostProcessRequest, PostProcessResponse, PreProcessRequest, PreProcessResponse,
};
use tokio::runtime::Builder;
use axum::{
e... | code_fim | hard | {
"lang": "rust",
"repo": "AlexanderChen1989/hello-tf",
"path": "/src/bin/infer_web.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn infer(cli: &mut InferClient<Channel>, shape: Vec<u64>, data: Vec<f32>) -> InferResponse {
let req = InferRequest { shape, data };
cli.infer(req).await.unwrap().into_inner()
}
async fn post_process(
cli: &mut ProcessClient<Channel>,
shape: Vec<u64>,
data: Vec<f32>,
) -> PostPr... | code_fim | hard | {
"lang": "rust",
"repo": "AlexanderChen1989/hello-tf",
"path": "/src/bin/infer_web.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: utilForever/BOJ path: /Rust/9298 - Ant Entrapment.rs
use io::Write;
use std::{io, str};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> UnsafeScanner<R> {
pub fn new(reader: R) -> Self {
Sel... | code_fim | hard | {
"lang": "rust",
"repo": "utilForever/BOJ",
"path": "/Rust/9298 - Ant Entrapment.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (min_x, max_x, min_y, max_y) = ants.iter().fold(
(ants[0].0, ants[0].0, ants[0].1, ants[0].1),
|(min_x, max_x, min_y, max_y), (x, y)| {
(min_x.min(*x), max_x.max(*x), min_y.min(*y), max_y.max(*y))
},
);
writeln!(
... | code_fim | hard | {
"lang": "rust",
"repo": "utilForever/BOJ",
"path": "/Rust/9298 - Ant Entrapment.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KevinKelley/nanomorph path: /src/morph.rs
#![crate_name = "nanomorph"]
#![desc = "a tiny morphic implementation on nanoVG"]
#![license = "MIT"]
#![crate_type = "lib"]
#![feature(globs)]
#![allow(non_snake_case_functions)]
#![allow(dead_code)]
#![allow(unused_variable)]
pub use gfx::*;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "KevinKelley/nanomorph",
"path": "/src/morph.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn h(&self) -> f32 { self.bounds.h() }
fn relativeX(&self) -> f32 {
match self.getParent() {
Some(ref owner) => return self.bounds().x() - owner.bounds().x ,
None => return self.bounds().x()
}
}
fn relativeY(&self) -> f32 {
match self.getPare... | code_fim | hard | {
"lang": "rust",
"repo": "KevinKelley/nanomorph",
"path": "/src/morph.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: memorysafety/sudo-rs path: /src/log/simple_logger.rs
use std::io::{Stderr, Write};
#[cfg(feature = "dev")]
use std::{path::Path, sync::Mutex};
use log::Log;
pub trait LoggerWrite {
fn write_log(&self, buf: &[u8]) -> std::io::Result<usize>;
fn flush_log(&self) -> std::io::Result<()>;
}... | code_fim | hard | {
"lang": "rust",
"repo": "memorysafety/sudo-rs",
"path": "/src/log/simple_logger.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_write_and_flush() {
let target = Arc::new(RwLock::new(String::new()));
let logger = SimpleLogger {
target: target.clone(),
prefix: "[test] ",
};
let record = log::Record::builder()
.args(format_args!("Hello World!"... | code_fim | hard | {
"lang": "rust",
"repo": "memorysafety/sudo-rs",
"path": "/src/log/simple_logger.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mime::TEXT_HTML,
Some("css") => mime::TEXT_CSS,
Some("js") => mime::TEXT_JAVASCRIPT,
Some("jpg") => mime::IMAGE_JPEG,
Some("md") => "text/markdown; charset=UTF-8"
.parse::<mime::Mime>()
.unwrap(),
Some("png") => mime::IMAGE_PNG,
Some... | code_fim | hard | {
"lang": "rust",
"repo": "lperson/spotifytops",
"path": "/src/lib/server/helpers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lperson/spotifytops path: /src/lib/server/helpers.rs
use std::collections::hash_map::HashMap;
use std::path::Path;
use std::rc::Rc;
use std::vec::Vec;
use hyper::{Body, Request};
use percent_encoding;
pub fn get_query(request: &Request<Body>) -> Option<HashMap<&str, Option<Rc<String>>>> {
... | code_fim | hard | {
"lang": "rust",
"repo": "lperson/spotifytops",
"path": "/src/lib/server/helpers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_transpose() {
// Mat2
assert_eq!(mat2::A.transpose(),
Mat2::<f64>::new(1.0, 2.0,
3.0, 4.0));
let mut mut_a = mat2::A;
mut_a.transpose_self();
assert_eq!(mut_a, mat2::A.transpose());
// Mat3
assert_eq!(mat3::A.tra... | code_fim | hard | {
"lang": "rust",
"repo": "rsaarelm/cgmath-rs",
"path": "/src/test/matrix.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rsaarelm/cgmath-rs path: /src/test/matrix.rs
// Copyright 2013 The CGMath Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this fil... | code_fim | hard | {
"lang": "rust",
"repo": "rsaarelm/cgmath-rs",
"path": "/src/test/matrix.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
vec![vec!["bat"], vec!["eat", "tea", "ate"], vec!["tan", "nat"]],
group_anagrams(vec![
String::from("eat"),
String::from("tea"),
String::from("tan"),
String::from("ate"),
String::fro... | code_fim | hard | {
"lang": "rust",
"repo": "xcaptain/rust-algorithms",
"path": "/leetcode/src/p49.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xcaptain/rust-algorithms path: /leetcode/src/p49.rs
// https://leetcode-cn.com/problems/group-anagrams/
use std::collections::HashMap;
pub fn group_anagrams(strs: Vec<String>) -> Vec<Vec<String>> {
let mut map: HashMap<String, Vec<String>> = HashMap::new();
for s in strs {
let ... | code_fim | medium | {
"lang": "rust",
"repo": "xcaptain/rust-algorithms",
"path": "/leetcode/src/p49.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *self
}
}
#[repr(transparent)]
pub struct SetImageFeedResult(pub i32);
impl SetImageFeedResult {
pub const Success: Self = Self(0i32);
pub const ChangeDisabled: Self = Self(1i32);
pub const UserCanceled: Self = Self(2i32);
}
impl ::core::marker::Copy for SetImageFeedResult {}
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/System/UserProfile/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/System/UserProfile/mod.rs
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
#[repr(transparent)]
pub struct AccountPictureK... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/System/UserProfile/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reyadrahman/chatbot-5 path: /src/sources/irc.rs
use core::*;
use irc::client::prelude::*;
use serde_json::{self, Value};
use sources::*;
use std::sync::mpsc::Sender;
use std::thread::{self, JoinHandle};
/// A helper enum for IrcSource
enum SourceState {
Disconnected,
Connected(IrcServer... | code_fim | hard | {
"lang": "rust",
"repo": "reyadrahman/chatbot-5",
"path": "/src/sources/irc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // create the event handling thread
let handle = thread::spawn(move || -> SourceResult<()> {
thread_server.identify()?;
let _ = thread_server.for_each_incoming(|message| {
let events = message_to_events(message);
for event in events {... | code_fim | hard | {
"lang": "rust",
"repo": "reyadrahman/chatbot-5",
"path": "/src/sources/irc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: notgull/breadglx path: /src/offload.rs
// MIT/Apache2 License
/*
*Sighs.* I was really hoping I wouldn't have to do this. I try to prevent my code from being opinionated,
which is why I generally use smol primitives. Not only does smol provide compatibility with async-std, it
has smaller pa... | code_fim | hard | {
"lang": "rust",
"repo": "notgull/breadglx",
"path": "/src/offload.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>static OFFLOADER: Lazy<Executor<'static>> = Lazy::new(|| {
// we spawn two threads. one handles the drop calls created in async contexts, the other handles
// hot futures in FFI calls
const THREAD_COUNT: usize = 1;
for i in 0..THREAD_COUNT {
thread::Builder::new()
.nam... | code_fim | medium | {
"lang": "rust",
"repo": "notgull/breadglx",
"path": "/src/offload.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/network/netstack3/core/src/algorithm/port_alloc.rs
found in the LICENSE file.
//! Ephemeral port allocation provider.
//!
//! Defines the [`PortAlloc`] structure and [`PortAllocImpl`] trait, used for
//! ephemeral port allocations in transport protocols.... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/network/netstack3/core/src/algorithm/port_alloc.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Test that for a single flow ID, we get sequential ports that can span
// the entire ephemeral range.
with_fake_rngs(RNG_ROUNDS, |mut rng| {
let fake = FakeImpl { available: FakeAvailable::AllowAll };
let mut alloc = PortAlloc::<FakeImpl>::new(&mut rng);
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/network/netstack3/core/src/algorithm/port_alloc.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Test that if no ports are available, try_alloc must return none.
with_fake_rngs(RNG_ROUNDS, |mut rng| {
let fake = FakeImpl { available: FakeAvailable::DenyAll };
let mut alloc = PortAlloc::<FakeImpl>::new(&mut rng);
let port = alloc.try_alloc(&FakeId... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/network/netstack3/core/src/algorithm/port_alloc.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> //q.pop().await;
//println!("I'll never make it. :(");
}
#[test]
fn it_works() {
execute_one(foo());
}
}<|fim_prefix|>// repo: johnshaw/aoc-2019 path: /common/src/lib.rs
pub mod myasync;
pub mod intcode;
#[cfg(test)]
mod tests {
use super::myasync::*;
use... | code_fim | hard | {
"lang": "rust",
"repo": "johnshaw/aoc-2019",
"path": "/common/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnshaw/aoc-2019 path: /common/src/lib.rs
pub mod myasync;
pub mod intcode;
#[cfg(test)]
mod tests {
use super::myasync::*;
use std::pin::Pin;
async fn print(msg: &str) {
println!("I am printer: {}", msg);
}
async fn run(mut q: Receiver<u32>) {
let v = q.r... | code_fim | medium | {
"lang": "rust",
"repo": "johnshaw/aoc-2019",
"path": "/common/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liufuyang/pingcap-talent-plan path: /building-blocks2/examples/exercise-json/main.rs
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::Cursor;
#[derive(Serialize, Deserialize, Debug)]
struct Move {
x: i32,
y: i32,
}
fn main() {
let point = Move { x: 1, y: 2 };
... | code_fim | hard | {
"lang": "rust",
"repo": "liufuyang/pingcap-talent-plan",
"path": "/building-blocks2/examples/exercise-json/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut file: Cursor<Vec<u8>> = Cursor::new(file);
let doc = bson::decode_document(&mut file).unwrap();
let deserialized: Move = bson::from_bson(bson::Bson::Document(doc)).unwrap();
println!("deserialized from BSON Vec = {:?}", deserialized);
let doc = bson::decode_document(&mut file)... | code_fim | hard | {
"lang": "rust",
"repo": "liufuyang/pingcap-talent-plan",
"path": "/building-blocks2/examples/exercise-json/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vancha/rocket.rs-heroes-from-medium path: /src/schema.rs
table! {
heroes (id) {
id -> Integer,<|fim_suffix|>e -> Nullable<Varchar>,
spotted_photo -> Varchar,
strength_level -> Integer,
}
}<|fim_middle|>
fantasy_name -> Varchar,
real_nam | code_fim | easy | {
"lang": "rust",
"repo": "vancha/rocket.rs-heroes-from-medium",
"path": "/src/schema.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>archar,
strength_level -> Integer,
}
}<|fim_prefix|>// repo: vancha/rocket.rs-heroes-from-medium path: /src/schema.rs
table! {
heroes (id) {
id -> Integer,<|fim_middle|>
fantasy_name -> Varchar,
real_name -> Nullable<Varchar>,
spotted_photo -> V | code_fim | medium | {
"lang": "rust",
"repo": "vancha/rocket.rs-heroes-from-medium",
"path": "/src/schema.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sakamoto-a/bomberhuman path: /src/models/world.rs
}
}
*/ if self.next_bomb_time < 0.0 {
match self.hurry_up.pop() {
Some(next) => {
let next_x = next % 15;
let next_y = next / 15;
let block_position = P... | code_fim | hard | {
"lang": "rust",
"repo": "sakamoto-a/bomberhuman",
"path": "/src/models/world.rs",
"mode": "psm",
"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.