text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: jonfast565/quick-copy-rs path: /src/main.rs
#[macro_use]
extern crate clap;
use chrono;
use log::{error, info};
use std::{thread, time};
use clap::Parser;
mod constants;
mod change_detector;
mod configuration;
mod copier;
mod files;
mod paths;
mod tests;
mod utilities;
<|fim_suffix|> info!... | code_fim | hard | {
"lang": "rust",
"repo": "jonfast565/quick-copy-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run_service_mode(_o: ProgramOptions) {
info!("Running in service mode");
error!("Not implemented as a Windows Service");
panic!("Not implemented as a Windows Service");
}
fn run_cycle(o: ProgramOptions) {
let change_detector = ChangeDetector::new(o.clone());
let copier = Copier::ne... | code_fim | hard | {
"lang": "rust",
"repo": "jonfast565/quick-copy-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let font = BuiltinFont::Times_Roman;
let size = Pt(12.0);
let some_text = "This is a test. ";
let some_len = font.text_width(size, some_text);
let n = 500;
assert_eq!(Pt(66.336), some_len);
let mut long_text = String::new();
for _ in 0..n {
long_text = long_text + s... | code_fim | hard | {
"lang": "rust",
"repo": "hummingly/simple-pdf",
"path": "/tests/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let comparision = (a - b).abs() / (a.abs() + b.abs());
println!("Checking if {} and {} is close: {}", a, b, comparision);
comparision < 1e-7
}
#[test]
fn metrics_for_long_string() {
let font = BuiltinFont::Times_Roman;
let size = Pt(12.0);
let some_text = "This is a test. ";
l... | code_fim | medium | {
"lang": "rust",
"repo": "hummingly/simple-pdf",
"path": "/tests/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hummingly/simple-pdf path: /tests/lib.rs
extern crate simple_pdf;
use simple_pdf::units::Pt;
use simple_pdf::{BuiltinFont, FontSource};
<|fim_suffix|>#[test]
fn metrics_for_long_string() {
let font = BuiltinFont::Times_Roman;
let size = Pt(12.0);
let some_text = "This is a test. ";... | code_fim | medium | {
"lang": "rust",
"repo": "hummingly/simple-pdf",
"path": "/tests/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_serialize() {
let branch_node = Node::BranchNode::<u64>(PointerNode::default());
let branch_json = json!({
"BranchNode": {
"x_0": null, "x_1": null, "x_2": null, "x_3": null,
"x_4": null, "x_5": null, "x_6": null, "x_7": n... | code_fim | hard | {
"lang": "rust",
"repo": "Perseus101/RustDAG",
"path": "/lib/src/dag/storage/mpt/node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Perseus101/RustDAG path: /lib/src/dag/storage/mpt/node.rs
use std::fmt;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use serde::de::{Deserialize, Deserializer, EnumAccess, VariantAccess, Visitor};
use serde::ser::{Serialize, Serializer};
use security::hash::hasher::Sha3Hasher;
... | code_fim | hard | {
"lang": "rust",
"repo": "Perseus101/RustDAG",
"path": "/lib/src/dag/storage/mpt/node.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(0x0, get_top_nibble(0x0000_0000_0000_0000));
assert_eq!(0x1, get_top_nibble(0x1000_0000_0000_0000));
assert_eq!(0x2, get_top_nibble(0x2000_0000_0000_0000));
assert_eq!(0x3, get_top_nibble(0x3000_0000_0000_0000));
assert_eq!(0x4, get_top_nibble(0x4000_0000... | code_fim | hard | {
"lang": "rust",
"repo": "Perseus101/RustDAG",
"path": "/lib/src/dag/storage/mpt/node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AntonGepting/tmux-interface-rs path: /src/commands/windows_and_panes/rotate_window.rs
use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
/// Rotate the positions of the panes within a window
///
/// # Manual
///
/// tmux ^3.1:
/// ```text
/// rotate-window [-DUZ] [... | code_fim | hard | {
"lang": "rust",
"repo": "AntonGepting/tmux-interface-rs",
"path": "/src/commands/windows_and_panes/rotate_window.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// `[-Z]`
#[cfg(feature = "tmux_3_1")]
pub keep_zoomed: bool,
/// `[-t target-window]`
#[cfg(feature = "tmux_0_8")]
pub target_window: Option<Cow<'a, str>>,
}
impl<'a> RotateWindow<'a> {
pub fn new() -> Self {
Default::default()
}
/// `[-D]`
#[cfg(featur... | code_fim | hard | {
"lang": "rust",
"repo": "AntonGepting/tmux-interface-rs",
"path": "/src/commands/windows_and_panes/rotate_window.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Iterator for FenceIter<'a> {
type Item = FenceToken<'a>;
fn next(&mut self) -> Option<FenceToken<'a>> {
loop {
let tok = self.split.next()?.trim();
let mut tok_split = tok.split('=');
match tok_split.next().unwrap_or("").trim() {
... | code_fim | hard | {
"lang": "rust",
"repo": "PriceChild/zola",
"path": "/components/rendering/src/markdown/fence.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PriceChild/zola path: /components/rendering/src/markdown/fence.rs
#[derive(Copy, Clone, Debug)]
pub struct Range {
pub from: usize,
pub to: usize,
}
impl Range {
fn parse(s: &str) -> Option<Range> {
match s.find('-') {
Some(dash) => {
let mut from... | code_fim | hard | {
"lang": "rust",
"repo": "PriceChild/zola",
"path": "/components/rendering/src/markdown/fence.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: petrosagg/pubnub-rust path: /pubnub-hyper/tests/history.rs
use log::info;
use pubnub_hyper::core::data::{channel, request};
use pubnub_hyper::runtime::tokio_global::TokioGlobal;
use pubnub_hyper::transport::hyper::Hyper;
use pubnub_hyper::Builder;
use std::fmt::Write;
mod common;
/// Delay exe... | code_fim | hard | {
"lang": "rust",
"repo": "petrosagg/pubnub-rust",
"path": "/pubnub-hyper/tests/history.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pubnub = Builder::with_components(transport, TokioGlobal).build();
let test_channel: channel::Name = format!("my-channel-{}", random_hex_string())
.parse()
.unwrap();
let test_payload = json::object! {
my_payload: "my_value",
};
... | code_fim | hard | {
"lang": "rust",
"repo": "petrosagg/pubnub-rust",
"path": "/pubnub-hyper/tests/history.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 5hadowblad3/healer path: /healer_core/src/context.rs
use std::fmt::Display;
use crate::{
alloc::{Allocator, VmaAllocator},
prog::{Call, Prog},
relation::RelationWrapper,
target::Target,
ty::ResKind,
value::ResValueId,
HashMap,
};
/// A context records useful informa... | code_fim | hard | {
"lang": "rust",
"repo": "5hadowblad3/healer",
"path": "/healer_core/src/context.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Record a generate resource to context.
pub fn record_res(&mut self, kind: &ResKind, id: ResValueId) {
if !self.res_ids.contains_key(kind) {
self.res_ids.insert(kind.clone(), Vec::new());
self.res_kinds.push(kind.clone());
}
self.res_ids.get_mut(k... | code_fim | hard | {
"lang": "rust",
"repo": "5hadowblad3/healer",
"path": "/healer_core/src/context.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
extern crate std;
use super::*;
use quickcheck_macros::quickcheck;
use std::vec::Vec;
#[quickcheck]
fn result_is_sorted(mut v: Vec<i32>) -> bool {
insertion_sort(&mut v);
v.is_sorted()
}
#[quickcheck]
fn result_is_sorted_by_ke... | code_fim | hard | {
"lang": "rust",
"repo": "newAM/r3",
"path": "/src/r3_test_suite/src/utils/sort.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 1..a.len() {
let mut ap = &mut a[0..=i];
while let [.., p1, p2] = ap {
if f(p1, p2) {
break;
}
swap(p1, p2);
ap = ap.split_last_mut().unwrap().1;
}
}
}
#[cfg(test)]
mod tests {
extern crate std;
... | code_fim | hard | {
"lang": "rust",
"repo": "newAM/r3",
"path": "/src/r3_test_suite/src/utils/sort.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: newAM/r3 path: /src/r3_test_suite/src/utils/sort.rs
//! Provides an insertion sort implementation.
use core::{cmp::Ordering, mem::swap};
/// Sort the slice using the insertion sort method.
///
/// # Performance
///
/// It was never faster than `[T]::sort_unstable` for `a.len() > 16`.
pub fn ins... | code_fim | hard | {
"lang": "rust",
"repo": "newAM/r3",
"path": "/src/r3_test_suite/src/utils/sort.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_no_matching_branches() {
let result = get_matching_branches(&String::from("ab"), &vec![String::from("d")]);
assert_eq!(result, [] as [&str; 0]);
}
#[test]
fn test_empty() {
let result = get_matching_branches(
&String::from(""),
... | code_fim | hard | {
"lang": "rust",
"repo": "danifujii/rbranchsearch",
"path": "/src/git.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danifujii/rbranchsearch path: /src/git.rs
use std::collections::HashMap;
use std::process::Command;
use std::str;
use subprocess::Exec;
pub fn get_matching_branches(search: &String, branches: &Vec<String>) -> Vec<String> {
let mut result = Vec::new();
let mut positions = HashMap::new();... | code_fim | hard | {
"lang": "rust",
"repo": "danifujii/rbranchsearch",
"path": "/src/git.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_matching_branches() {
let result = get_matching_branches(
&String::from("ab"),
&vec![String::from("cab"), String::from("ab"), String::from("d")],
);
assert_eq!(result, vec!["ab", "cab"]);
}
#[test]
fn test_no_matching_bra... | code_fim | hard | {
"lang": "rust",
"repo": "danifujii/rbranchsearch",
"path": "/src/git.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: floric/secret-clan path: /backend/benches/database.rs
use criterion::{
black_box, measurement::WallTime, BenchmarkGroup, BenchmarkId, Criterion, SamplingMode,
};
use futures::executor::block_on;
use rand::{distributions::Alphanumeric, prelude::*};
use rand_pcg::Pcg64;
use secret_clan::{model... | code_fim | hard | {
"lang": "rust",
"repo": "floric/secret-clan",
"path": "/backend/benches/database.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn bench_scan_with_sizes(
db_group: &mut BenchmarkGroup<WallTime>,
ctx: &AppContext,
local: &LocalSet,
sizes: Vec<u32>,
) {
for size in sizes {
db_group.bench_with_input(BenchmarkId::new("scan", size), &size, |b, player_count| {
b.iter_custom(|iters| {
... | code_fim | hard | {
"lang": "rust",
"repo": "floric/secret-clan",
"path": "/backend/benches/database.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_body(path: impl AsRef<Path>) -> ModuleResult<Vec<Statement>> {
let path = path.as_ref();
let mut file = fs::File::open(path)?;
let mut buf = String::new();
file.read_to_string(&mut buf)?;
// Parse file
let file_name = path.file_name().and_then(|name| name.to_str());
p... | code_fim | hard | {
"lang": "rust",
"repo": "bwhetherington/rscript",
"path": "/src/parser/resolver.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bwhetherington/rscript path: /src/parser/resolver.rs
use crate::parser::{
ast::{ParseError, Parser, Statement},
lexer::Lexer,
};
use std::{
fmt, fs,
io::{prelude::*, Error},
path::Path,
};
#[derive(Debug)]
pub struct Module {
pub identifier: String,
pub body: Vec<Sta... | code_fim | hard | {
"lang": "rust",
"repo": "bwhetherington/rscript",
"path": "/src/parser/resolver.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in vec![
(2, nested![[1,0]], vec![0, 1]),
(3, nested![[1,0],[0,2]], vec![0]),
(4, nested![[1,0],[1,2],[1,3]], vec![1]),
(6, nested![[0, 3], [1, 3], [2, 3], [4, 3], [5, 4]], vec![3, 4]),
] {
assert_eq!(Solution::find_min_height_trees(i.0, i.1), i.2);
... | code_fim | medium | {
"lang": "rust",
"repo": "HerringtonDarkholme/leetcode",
"path": "/src/min_height_trees.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/min_height_trees.rs
pub struct Solution;
use std::collections::VecDeque;
// key point:
// 1. we count all edges and push all leaf nodes to a vec!
// 2. for all nodes in leaf vecs, pop them and delete the node and edge from tree
// 3. for the new tree, lis... | code_fim | hard | {
"lang": "rust",
"repo": "HerringtonDarkholme/leetcode",
"path": "/src/min_height_trees.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_variables() {
let path = PathBuf::from("tests/test_data/variables-test.spd");
let calculated = spyder::run_file(&path, false);
assert_eq!(calculated.expect("error"), 21)
}<|fim_prefix|>// repo: delosrogers/spyder path: /tests/code_exec.rs
// Copyright 2021 The Spyder Authors.
... | code_fim | hard | {
"lang": "rust",
"repo": "delosrogers/spyder",
"path": "/tests/code_exec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: delosrogers/spyder path: /tests/code_exec.rs
// Copyright 2021 The Spyder Authors.
// Use of this source code is governed by the MIT License which can be
// found in the LICENSE file.
<|fim_suffix|>#[test]
fn test_multiplication() {
let path = PathBuf::from("tests/test_data/multiplication-t... | code_fim | medium | {
"lang": "rust",
"repo": "delosrogers/spyder",
"path": "/tests/code_exec.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = PathBuf::from("tests/test_data/call-test.spd");
let calculated = spyder::run_file(&path, false);
assert!(calculated.is_ok());
assert_eq!(calculated.expect("error"), 50)
}
#[test]
fn test_variables() {
let path = PathBuf::from("tests/test_data/variables-test.spd");
let c... | code_fim | hard | {
"lang": "rust",
"repo": "delosrogers/spyder",
"path": "/tests/code_exec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sut = functions::Group::create("ax
bx
cx");
assert_eq!(sut.all_answered('a'), false);
assert_eq!(sut.any_answered('a'), true);
assert_eq!(sut.all_answered('x'), true);
assert_eq!(sut.any_answered('x'), true);
assert_eq!(sut.all_answered('... | code_fim | easy | {
"lang": "rust",
"repo": "Wowo10/AdventOfCode2020",
"path": "/day6/tests/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Wowo10/AdventOfCode2020 path: /day6/tests/test.rs
extern crate day6;
#[cfg(test)]
mod test_module {
use day6::functions;
<|fim_suffix|> let sut = functions::Group::create("ax
bx
cx");
assert_eq!(sut.all_answered('a'), false);
assert_eq!(sut.any_an... | code_fim | easy | {
"lang": "rust",
"repo": "Wowo10/AdventOfCode2020",
"path": "/day6/tests/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AdaShoelace/rustic-tac-toe path: /src/main.rs
pub mod state;
pub mod player;
pub mod util;
pub mod board;
pub mod app;
pub mod board_checker;
pub mod my_checker;
use {
player::Player,
app::App,
std::io,
crate::{
my_checker::MyChecker,
board_checker::{
... | code_fim | medium | {
"lang": "rust",
"repo": "AdaShoelace/rustic-tac-toe",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(not(feature = "test"))]
let checker: Box<dyn BoardChecker> = Box::new(MyChecker);
let players = get_new_players();
App::new(players.0, players.1, checker)
.run();
}
fn get_new_players() -> (Player, Player) {
let mut ret = (None, None);
(0..2).for_each(|i| {
... | code_fim | medium | {
"lang": "rust",
"repo": "AdaShoelace/rustic-tac-toe",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut bytes = vec![];
bytes.extend(&self.index.to_be_bytes());
bytes.extend(&self.timestamp.0.to_be_bytes());
bytes.extend(&self.parent_hash.to_bytes());
bytes.extend(&self.nonce.to_be_bytes());
bytes.extend(self.payload.as_bytes());
bytes.extend(&... | code_fim | hard | {
"lang": "rust",
"repo": "vyorkin/blk",
"path": "/src/block.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn mine(&mut self) {
for nonce_attempt in 0..u64::MAX {
self.nonce = nonce_attempt;
let hash = self.hash();
if self.check_difficulty(&hash) {
self.hash = hash;
break;
}
}
}
pub fn check_difficu... | code_fim | hard | {
"lang": "rust",
"repo": "vyorkin/blk",
"path": "/src/block.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vyorkin/blk path: /src/block.rs
use crate::{ByteHash, Hashable, Timestamp};
use std::{
convert::TryInto,
fmt::{self, Debug, Formatter},
};
pub struct Block {
pub index: u32,
pub timestamp: Timestamp,
pub hash: ByteHash,
pub parent_hash: ByteHash,
pub nonce: u64,
... | code_fim | hard | {
"lang": "rust",
"repo": "vyorkin/blk",
"path": "/src/block.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl<T> ops::$t2<T> for BitBoard where u64: ops::$t2<T> {
#[inline]
fn $f2(&mut self, shift: T) { (self.0).$f2(shift) }
}
)+ }
}
forward_sh_impl! {
Shl shl ShlAssign shl_assign
Shr shr ShrAssign shr_assign
}
impl_bit_set! { BitBoard !0 => Square }
imp... | code_fim | hard | {
"lang": "rust",
"repo": "hexe-rs/Hexe",
"path": "/hexe_core/src/board/bit_board/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hexe-rs/Hexe path: /hexe_core/src/board/bit_board/mod.rs
//! A bitmap chess board representation.
//!
//! `BitBoard` conveniently represents chess boards as 64-bit integers. Each bit
//! represents an individual square. Occupancy is represented by the value of
//! each bit.
//!
//! For example, ... | code_fim | hard | {
"lang": "rust",
"repo": "hexe-rs/Hexe",
"path": "/hexe_core/src/board/bit_board/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AsRef<BitBoard> for u64 {
#[inline(always)]
fn as_ref(&self) -> &BitBoard {
unsafe { self.into_unchecked() }
}
}
impl AsMut<BitBoard> for u64 {
#[inline(always)]
fn as_mut(&mut self) -> &mut BitBoard {
unsafe { self.into_unchecked() }
}
}
impl From<Square> fo... | code_fim | hard | {
"lang": "rust",
"repo": "hexe-rs/Hexe",
"path": "/hexe_core/src/board/bit_board/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn compile_to_native_code<W: Write>(byte_code: &ByteCode, out: &mut W) {
match *byte_code {
ByteCode::Add(num) => { write_all(out, &format!(" add byte [rsp], {}\n", num)); },
ByteCode::Sub(num) => { write_all(out, &format!(" sub byte [rsp], {}\n", num)); },
ByteCode::MoveRight(num) => { wr... | code_fim | hard | {
"lang": "rust",
"repo": "dnseitz/rustration",
"path": "/src/compile/bytecode.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dnseitz/rustration path: /src/compile/bytecode.rs
// compile/bytecode.rs
// Rustration
//
// Created by Daniel Seitz on 1/12/17
use std::collections::VecDeque;
use super::compiler::Label;
use std::io::Write;
#[derive(Debug)]
pub enum ByteCode {
Add(isize),
Sub(isize),
MoveRight(isize),
... | code_fim | hard | {
"lang": "rust",
"repo": "dnseitz/rustration",
"path": "/src/compile/bytecode.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ByteProgram {
program: byte_code,
}
}
}
impl From<ByteProgram> for VecDeque<ByteCode> {
fn from(byte_program: ByteProgram) -> Self {
byte_program.program
}
}
fn emit_prelude<W: Write>(out: &mut W) {
write_all(out, "global start\n");
write_all(out, "\n");
write_all(out, "sec... | code_fim | hard | {
"lang": "rust",
"repo": "dnseitz/rustration",
"path": "/src/compile/bytecode.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Redblueflame/gluesql path: /src/executor/aggregate/hash.rs
use std::convert::{TryFrom, TryInto};
use crate::data::Value;
use crate::executor::evaluate::Evaluated;
use crate::result::{Error, Result};
<|fim_suffix|> match evaluated {
Evaluated::LiteralRef(l) => Value::try_from... | code_fim | hard | {
"lang": "rust",
"repo": "Redblueflame/gluesql",
"path": "/src/executor/aggregate/hash.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match evaluated {
Evaluated::LiteralRef(l) => Value::try_from(*l)?.try_into(),
Evaluated::Literal(l) => Value::try_from(l)?.try_into(),
Evaluated::ValueRef(v) => (*v).try_into(),
Evaluated::Value(v) => v.try_into(),
Evaluated::StringRef(s... | code_fim | hard | {
"lang": "rust",
"repo": "Redblueflame/gluesql",
"path": "/src/executor/aggregate/hash.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/tests/spec_test.rs
use rome_formatter_test::spec::{SpecSnapshot, SpecTestFile};
use rome_js_formatter::context::JsFormatOptions;
use rome_js_syntax::{JsFileSource, ModuleKind};
use std::path::Path;
mod language {
include!("language.rs");
}
<|fim_s... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_js_formatter/tests/spec_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let Some(test_file) = SpecTestFile::try_from_file(spec_input_file, root_path) else { return; };
let mut source_type: JsFileSource = test_file.input_file().as_path().try_into().unwrap();
if file_type != "module" {
source_type = source_type.with_module_kind(ModuleKind::Script);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_js_formatter/tests/spec_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let output = Command::new("irptransmogrifier.sh")
.args(&["render", "--random", "-p", "-P", &protocol.name])
.output()
.expect("Failed to execute irptransmogrifier.sh");
if !output.status.success() {
continue;
}
let result =... | code_fim | hard | {
"lang": "rust",
"repo": "mandrean/linux-infrared",
"path": "/irp/generate_test_data/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mandrean/linux-infrared path: /irp/generate_test_data/src/main.rs
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
use std::process::Command;
mod output;
use output::{Node, Rule};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct TestData {
... | code_fim | hard | {
"lang": "rust",
"repo": "mandrean/linux-infrared",
"path": "/irp/generate_test_data/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[actix_rt::test]
async fn test_fetch_jwks() {
let authority =
std::env::var("AUTHORITY").expect(|_| "https://dev-babm2h9u.us.auth0.com/".to_string());
let jwks = fetch_jwks(&format!(
"{}{}",
authority.as_str(),
".well-known/jwks.json"
))
.await
.expect(... | code_fim | hard | {
"lang": "rust",
"repo": "chenyanming/btc_address_server",
"path": "/src/auth.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chenyanming/btc_address_server path: /src/auth.rs
use actix_web_httpauth::extractors::bearer::{BearerAuth, Config};
use actix_web_httpauth::extractors::AuthenticationError;
use actix_web::dev::ServiceRequest;
use actix_web::Result;
use crate::error::ServiceError;
use alcoholic_jwt::{token_kid... | code_fim | hard | {
"lang": "rust",
"repo": "chenyanming/btc_address_server",
"path": "/src/auth.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lpxxn/rust_example path: /z_10_pattern/deref_demo1/src/main.rs
use std::ops::Deref;
fn main() {
let bar = Bar { f: Foo {} };
bar.do_something();
println!("Hello, world!");
}
struct Foo {}
impl Foo {
fn do_something(&self) {
<|fim_suffix|>struct Bar {
f: Foo,
}
impl Deref fo... | code_fim | easy | {
"lang": "rust",
"repo": "lpxxn/rust_example",
"path": "/z_10_pattern/deref_demo1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Foo: do something...");
}
}
struct Bar {
f: Foo,
}
impl Deref for Bar {
type Target = Foo;
fn deref(&self) -> &Foo {
&self.f
}
}<|fim_prefix|>// repo: lpxxn/rust_example path: /z_10_pattern/deref_demo1/src/main.rs
use std::ops::Deref;
fn main() {
let ba... | code_fim | easy | {
"lang": "rust",
"repo": "lpxxn/rust_example",
"path": "/z_10_pattern/deref_demo1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Client '{}' has connected. (endpoint: {})", name, endpoint);
},
UiEvents::ParticipantUnregistered(endpoint, name) => {
println!("Client '{}' has disconnected. (endpoint: {})", name, endpoint);
},
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/Project-Midas",
"path": "/src/ui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
//We must also check ui_event_queue and see if we need to change the UI
match self.message_receiver.recv_timeout(Duration::from_micros(0)) {
Ok(event) => match event {
UiEvents::ChangeStatusTo(status, _endpoint, name) => match status {
Parti... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/Project-Midas",
"path": "/src/ui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/Project-Midas path: /src/ui.rs
use crate::messages::{ParticipantStatus, UiEvents, HostEvent};
use std::time::Duration;
use crossbeam_channel::{Sender, Receiver};
use crossterm::event::{read, Event, poll};
pub struct Panel {
//For events sent from the host
//ui_event_queue: Ev... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/Project-Midas",
"path": "/src/ui.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oshunter/fuchsia path: /third_party/rust_crates/vendor/tokio/tests/support/mock_file.rs
#![allow(clippy::unnecessary_operation)]
use std::collections::VecDeque;
use std::fmt;
use std::fs::{Metadata, Permissions};
use std::io;
use std::io::prelude::*;
use std::io::SeekFrom;
use std::path::PathBu... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/third_party/rust_crates/vendor/tokio/tests/support/mock_file.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn sync_all(&self) -> io::Result<()> {
use self::Call::*;
let mut s = self.shared.lock().unwrap();
match s.calls.pop_front() {
Some(SyncAll(ret)) => ret,
Some(op) => panic!("expected next call to be {:?}; was sync_all", op),
None => pan... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/third_party/rust_crates/vendor/tokio/tests/support/mock_file.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattheww/microbit-text path: /src/scrolling.rs
//! Support for scrolling sequences of 5×5 images horizontally.
//!
//! Each kind of scrolling sequence is represented by a type implementing
//! [`Animate`] (for controlling the sequence) and [`Render`] (for displaying
//! it).
//!
//! To create a ... | code_fim | hard | {
"lang": "rust",
"repo": "mattheww/microbit-text",
"path": "/src/scrolling.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the brightness value for a single LED in the current state.
///
/// Use this to implement `Render`.
fn current_brightness_at(&self, x: usize, y: usize) -> u8 {
if self.state().index > self.length() {return 0}
let state = self.state();
let (index, x) = if... | code_fim | hard | {
"lang": "rust",
"repo": "mattheww/microbit-text",
"path": "/src/scrolling.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0 {
(acc + 1, d)
} else {
(acc, prev)
}
);
let ans = if m > 0 {
m + 2
} else if p == 0 {
0
} else {
2
};
println!("{}", ans);
}<|fim_prefix|>// repo: wotsushi/competitive-programming path: /etc/t... | code_fim | hard | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/etc/tkppc4_1/d.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wotsushi/competitive-programming path: /etc/tkppc4_1/d.rs
#![allow(non_snake_case)]
fn main() {
let N: usize = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse().unwrap()
};
let A: Vec<i64> = {
<|... | code_fim | hard | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/etc/tkppc4_1/d.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> events.sort_by(|e1, e2| e1.0.cmp(&e2.0));
let mut fraction_created: Vec<f32> = Vec::with_capacity(self.duration as usize);
let n: f32 = self.nodes.len() as f32;
let mut deleted_edges: i32 = 0;
let mut created_edges: i32 = 0;
let mut n_links: i32 = 0;
... | code_fim | hard | {
"lang": "rust",
"repo": "grodino/graphia",
"path": "/src/graph.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: grodino/graphia path: /src/graph.rs
use std::convert::TryFrom;
use std::io::Error;
use std::ops::Range;
use std::{fmt, fs};
#[derive(Debug)]
pub struct Contact {
pub couple: (i32, i32),
pub start: i32,
pub end: i32,
}
/// Describe the format of list of contacts in a Graph
///
/// *... | code_fim | hard | {
"lang": "rust",
"repo": "grodino/graphia",
"path": "/src/graph.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NakedSolidSnake/C_Microservices path: /src/services/rust_service/main.rs
use std::env;
use std::fs::File;
use std::io::Write;
use std::net::UdpSocket;
fn main() -> std::io::Result<()>{
<|fim_suffix|> let socket = UdpSocket::bind(server_conf)?;
loop{
let mut buf = [0; 1024];
... | code_fim | hard | {
"lang": "rust",
"repo": "NakedSolidSnake/C_Microservices",
"path": "/src/services/rust_service/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let socket = UdpSocket::bind(server_conf)?;
loop{
let mut buf = [0; 1024];
let (amt, src) = socket.recv_from(&mut buf)?;
let buf = &mut buf[..amt];
buf.reverse();
socket.send_to(message.as_bytes(), &src)?;
}
}<|fim_prefix|>// repo: NakedSolidSnake/C... | code_fim | medium | {
"lang": "rust",
"repo": "NakedSolidSnake/C_Microservices",
"path": "/src/services/rust_service/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let server_conf = format!("127.0.0.1:{}", port.to_string());
let socket = UdpSocket::bind(server_conf)?;
loop{
let mut buf = [0; 1024];
let (amt, src) = socket.recv_from(&mut buf)?;
let buf = &mut buf[..amt];
buf.reverse();
socket.send_to(message.as_by... | code_fim | hard | {
"lang": "rust",
"repo": "NakedSolidSnake/C_Microservices",
"path": "/src/services/rust_service/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Card {
suite: Suite::Hearts,
value: Value::Two,
}
}
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub enum Suite {
Hearts,
Spades,
Diamonds,
Clubs,
}
impl Suite {
pub fn from_str(txt: &str) -> Result<Suite> {
if txt.len() != ... | code_fim | hard | {
"lang": "rust",
"repo": "thomas9911/pokeren",
"path": "/pokeren_rust/src/structs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomas9911/pokeren path: /pokeren_rust/src/structs.rs
use crate::rules::what_is_hand;
pub type Result<T> = std::result::Result<T, HandError>;
#[derive(Debug, PartialEq)]
pub struct HandError {
info: String,
}
impl std::fmt::Display for HandError {
fn fmt(&self, f: &mut std::fmt::Forma... | code_fim | hard | {
"lang": "rust",
"repo": "thomas9911/pokeren",
"path": "/pokeren_rust/src/structs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let blkio = BlockIoBuilder::new()
.with_read_iops(vec![LinuxThrottleDevice {
major: 8,
minor: 0,
rate: 102400,
}])
.build();
Blkio::apply(&tmp, &blkio).expect("apply blkio");
let content = fs::read... | code_fim | hard | {
"lang": "rust",
"repo": "sasurau4/youki",
"path": "/src/cgroups/v1/blkio.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sasurau4/youki path: /src/cgroups/v1/blkio.rs
use std::{
fs::{self},
path::Path,
};
use crate::cgroups::{
common::{self, CGROUP_PROCS},
v1::Controller,
};
use oci_spec::{LinuxBlockIo, LinuxResources};
const CGROUP_BLKIO_THROTTLE_READ_BPS: &str = "blkio.throttle.read_bps_device"... | code_fim | hard | {
"lang": "rust",
"repo": "sasurau4/youki",
"path": "/src/cgroups/v1/blkio.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redox-os/orbtk path: /orbtk_widgets/src/behaviors/mouse_behavior.rs
use crate::{api::prelude::*, proc_macros::*};
#[derive(Debug, Copy, Clone)]
enum Action {
Press(Mouse),
Release(Mouse),
Scroll(Point),
}
/// The `MouseBehaviorState` handles the `MouseBehavior` widget.
#[derive(Def... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/orbtk",
"path": "/orbtk_widgets/src/behaviors/mouse_behavior.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.name("MouseBehavior")
.delta(0.0)
.pressed(false)
.on_mouse_down(move |ctx, m| {
ctx.send_message(Action::Press(m), id);
false
})
.on_mouse_up(move |ctx, m| {
ctx.send_message(Action::R... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/orbtk",
"path": "/orbtk_widgets/src/behaviors/mouse_behavior.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samscott89/swagger-github-rs path: /src/models/commit_comments.rs
/*
* GitHub
*
* Powerful collaboration, code review, and code management for open source and private projects.
*
* OpenAPI spec version: v3
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
#[all... | code_fim | hard | {
"lang": "rust",
"repo": "samscott89/swagger-github-rs",
"path": "/src/models/commit_comments.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_updated_at(&mut self, updated_at: String) {
self.updated_at = Some(updated_at);
}
pub fn with_updated_at(mut self, updated_at: String) -> CommitComments {
self.updated_at = Some(updated_at);
self
}
pub fn updated_at(&self) -> Option<&String> {
self.updated_at.as_ref(... | code_fim | hard | {
"lang": "rust",
"repo": "samscott89/swagger-github-rs",
"path": "/src/models/commit_comments.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Snafu)]
enum Error {
#[snafu(display("Input length must be divisible by the length of the first line"))]
UnevenLines,
#[snafu(display("Could not read data from stdin: {}", source))]
ReadStdin { source: std::io::Error },
#[snafu(display("Input must contain a newline"))]
... | code_fim | medium | {
"lang": "rust",
"repo": "timotree3/aoc-2020",
"path": "/day3-pt1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read_grid() -> Result<Grid, Error> {
let mut data = Vec::new();
std::io::stdin().read_to_end(&mut data).context(ReadStdin)?;
let line_length = data
.iter()
.position(|&b| b == b'\n')
.context(ZeroLinebreaks)?;
ensure!(data.len() % (line_length + 1) == 0, UnevenLi... | code_fim | hard | {
"lang": "rust",
"repo": "timotree3/aoc-2020",
"path": "/day3-pt1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: timotree3/aoc-2020 path: /day3-pt1/src/main.rs
use std::io::Read;
use snafu::{ensure, OptionExt, ResultExt, Snafu};
fn main() -> Result<(), Error> {
let grid = read_grid()?;
let mut x = 0;
let mut line_start = 0;
let mut trees = 0;
while line_start != grid.data.len() {
... | code_fim | medium | {
"lang": "rust",
"repo": "timotree3/aoc-2020",
"path": "/day3-pt1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmerdich/rust-bindgen path: /tests/expectations/tests/packed-n-with-padding.rs
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C, packed(2))]
#[derive(Debug, Default, Copy, Clone)]
pub struct Packed {
pub a: ::std::os::raw::c_char,... | code_fim | hard | {
"lang": "rust",
"repo": "jmerdich/rust-bindgen",
"path": "/tests/expectations/tests/packed-n-with-padding.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>:std::ptr::null::<Packed>())).c as *const _ as usize },
4usize,
concat!("Offset of field: ", stringify!(Packed), "::", stringify!(c))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<Packed>())).d as *const _ as usize },
6usize,
concat!("Offset of field: ", st... | code_fim | hard | {
"lang": "rust",
"repo": "jmerdich/rust-bindgen",
"path": "/tests/expectations/tests/packed-n-with-padding.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Component for Boid {
type Storage = VecStorage<Self>;
}<|fim_prefix|>// repo: dfangx/boids path: /src/backup/boid.rs
use amethyst::{
ecs::prelude::{
Component,
VecStorage,
},
};
<|fim_middle|>#[derive(PartialEq, Clone)]
pub struct Boid {
position: Vector2<f32>,
v... | code_fim | medium | {
"lang": "rust",
"repo": "dfangx/boids",
"path": "/src/backup/boid.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dfangx/boids path: /src/backup/boid.rs
use amethyst::{
ecs::prelude::{
Component,
VecStorage,
},
};
<|fim_suffix|>impl Component for Boid {
type Storage = VecStorage<Self>;
}<|fim_middle|>#[derive(PartialEq, Clone)]
pub struct Boid {
position: Vector2<f32>,
v... | code_fim | medium | {
"lang": "rust",
"repo": "dfangx/boids",
"path": "/src/backup/boid.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: compiler-explorer/compiler-explorer path: /examples/rust/Sum_over_array_(Raw_pointers_aligned).rs
// Compile with -C opt-level=3 -C target-cpu=native to see autovectorization
<|fim_suffix|>// assumes input is aligned on 64-byte boundary and that
// input's length is a multiple of 64.
pub fn sum... | code_fim | easy | {
"lang": "rust",
"repo": "compiler-explorer/compiler-explorer",
"path": "/examples/rust/Sum_over_array_(Raw_pointers_aligned).rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> (0..input.0.len())
.map(|i| unsafe { *input.0.as_ptr().add(i) })
.sum()
}<|fim_prefix|>// repo: compiler-explorer/compiler-explorer path: /examples/rust/Sum_over_array_(Raw_pointers_aligned).rs
// Compile with -C opt-level=3 -C target-cpu=native to see autovectorization
<|fim_middle|... | code_fim | hard | {
"lang": "rust",
"repo": "compiler-explorer/compiler-explorer",
"path": "/examples/rust/Sum_over_array_(Raw_pointers_aligned).rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mubelotix/gleam-io-automation path: /extension/src/bot_logic.rs
ngs.".to_string());
}
if (settings.auto_retweet || settings.auto_tweet || settings.auto_follow_twitter) && auths.get("twitter").is_none() {
return Err(Warning("You enabled a Twitter automation feature in... | code_fim | hard | {
"lang": "rust",
"repo": "Mubelotix/gleam-io-automation",
"path": "/extension/src/bot_logic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Tweet on Twitter
if let Err(e) = window.open_with_url(&url) {
err_next(format!(
"Failed to open a new window: {:?}",
e
));
continue;
... | code_fim | hard | {
"lang": "rust",
"repo": "Mubelotix/gleam-io-automation",
"path": "/extension/src/bot_logic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sleep(Duration::from_secs(15)).await;
(twitter_value.clone(), true, true)
} else {
next();
continue;
}
}
RequestType::TwitterTweet(data_included) => {
if ... | code_fim | hard | {
"lang": "rust",
"repo": "Mubelotix/gleam-io-automation",
"path": "/extension/src/bot_logic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for operand_info {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
::protobuf::reflect::ProtobufValueRef::Message(self)
}
}
#[derive(PartialEq,Clone,Default)]
pub struct operand_info... | code_fim | hard | {
"lang": "rust",
"repo": "richinseattle/crashflow",
"path": "/src/stdframe.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: richinseattle/crashflow path: /src/stdframe.rs
|m: &std_frame| { &m.rawbytes },
|m: &mut std_frame| { &mut m.rawbytes },
));
fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage... | code_fim | hard | {
"lang": "rust",
"repo": "richinseattle/crashflow",
"path": "/src/stdframe.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: richinseattle/crashflow path: /src/stdframe.rs
new::<std_frame>(
"std_frame",
fields,
file_descriptor_proto()
)
})
}
}
fn default_instance() -> &'static std_frame {
static mut instanc... | code_fim | hard | {
"lang": "rust",
"repo": "richinseattle/crashflow",
"path": "/src/stdframe.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FreskyZ/fff-lang path: /src/codegen/vm/statement.rs
// Statement generation
use codemap::Span;
use message::CodegenMessage;
use lexical::SeperatorKind;
use lexical::LitValue;
use lexical::NumLitValue;
use syntax::Block;
use syntax::Statement;
use syntax::Expr;
use syntax::VarD... | code_fim | hard | {
"lang": "rust",
"repo": "FreskyZ/fff-lang",
"path": "/src/codegen/vm/statement.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let continue_addr = sess.codes.next_id();
let _ = gen_expr(while_stmt.expr, sess); // always reeval the expression
sess.loops.push_loop(None, continue_addr);
gen_block(while_stmt.body, sess, true);
sess.codes.emit(Code::Goto(continue_addr));
let while_refill_addr = sess.... | code_fim | hard | {
"lang": "rust",
"repo": "FreskyZ/fff-lang",
"path": "/src/codegen/vm/statement.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: menuan/whecko path: /src/main.rs
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
use log::{info, error};
use rand::distributions::{Distribution, Uniform};
use rand::thread_rng;
<|fim_suffix|>fn greet(req: HttpRequest) -> impl Responder {
let mut rng = thread_rng();
let di... | code_fim | medium | {
"lang": "rust",
"repo": "menuan/whecko",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn start_server() -> Result<(), std::io::Error> {
HttpServer::new(|| {
App::new()
.route("/", web::get().to(greet))
.route("/about", web::get().to(whoami))
.route("/hello/{name}", web::get().to(greet))
}).bind("0.0.0.0:8000")?.run()
}
fn main() {
en... | code_fim | hard | {
"lang": "rust",
"repo": "menuan/whecko",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zephyrchien/cf-subscribe-wasm path: /src/lib.rs
mod kv;
mod http;
mod crud;
mod types;
mod error;
mod utils;
use cfg_if::cfg_if;
use wasm_bindgen::prelude::*;
use types::*;
cfg_if! {
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
if #[cfg(f... | code_fim | hard | {
"lang": "rust",
"repo": "zephyrchien/cf-subscribe-wasm",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if path == *subscribe_path && method == "GET"{
return Ok(crud::subscribe(&ctx, &form).await?);
}
if path == *get_path && method == "GET" {
return Ok(crud::fetch(&ctx, &form).await?)
}
if path == *put_path && method == "POST" {
return Ok(crud::register(&ctx... | code_fim | hard | {
"lang": "rust",
"repo": "zephyrchien/cf-subscribe-wasm",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arranf/DailyProgrammer path: /370/src/main.rs
use std::io;
fn main() {
println!("Please input a UPC number");
// Allocate on the heap to read unknown input size
let mut number = String::new();
io::stdin().read_line(&mut number)
.expect("Failed to read UPC number");
... | code_fim | hard | {
"lang": "rust",
"repo": "arranf/DailyProgrammer",
"path": "/370/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Index: {}, I: {}, C: {}", i+offset, i, c);
// no need to error check here as we checked that all are valid base 10 digits above
let digit = c.to_digit(10).unwrap();
// 1st, 3rd, 5th
if ((i + offset) % 2) == 0 {
sum += digit * 3;
} else ... | code_fim | medium | {
"lang": "rust",
"repo": "arranf/DailyProgrammer",
"path": "/370/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VulkanWorks/korangar path: /src/input/event.rs
use cgmath::Vector2;
#[derive(Copy, Clone, Debug)]
pub enum UserEvent {
CameraZoom(f32),
CameraRotate(f32),
ToggleShowFramesPerSecond,
ToggleShowMap,
ToggleShowObjects,
ToggleShowEntities,
ToggleShowAmbientLight,
Tog... | code_fim | hard | {
"lang": "rust",
"repo": "VulkanWorks/korangar",
"path": "/src/input/event.rs",
"mode": "psm",
"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.