text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: m1el/memdmp path: /src/memory.rs
use core::ffi::c_void;
use core::ptr::null_mut;
use crate::syscalls::*;
pub struct RegionWalker {
ptr: *mut c_void,
}
<|fim_suffix|>impl Iterator for RegionWalker {
type Item = MEMORY_BASIC_INFORMATION;
fn next(&mut self) -> Option<Self:... | code_fim | medium | {
"lang": "rust",
"repo": "m1el/memdmp",
"path": "/src/memory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let status = NtQueryVirtualMemory(
!0 as _, self.ptr,
MEMORY_INFORMATION_CLASS::MemoryBasicInformation,
&mut mbi as *mut MEMORY_BASIC_INFORMATION as _,
mbi_len, &mut return_length);
assert!(mbi_len == return_lengt... | code_fim | hard | {
"lang": "rust",
"repo": "m1el/memdmp",
"path": "/src/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let peer_public = io.peer_key_pair().public().clone();
io.add_input_message(Message::Cluster(ClusterMessage::NodePublicKey(NodePublicKey {
node_id: peer_public.into(),
confirmation_plain: peer_confirmation_plain.into(),
confirmation_signed_session: peer_confirmation_signed.into(),
})));
i... | code_fim | hard | {
"lang": "rust",
"repo": "yijie37/DaQiao",
"path": "/bridge/parity-ethereum/secret-store/src/key_server_cluster/io/handshake.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yijie37/DaQiao path: /bridge/parity-ethereum/secret-store/src/key_server_cluster/io/handshake.rs
nodes each holding its own `self_key_pair`.
///!
///! Handshake process:
///! 1) both nodes are generating random `KeyPair` (`session_key_pair`), which will be used for channel encryption
///! 2) bot... | code_fim | hard | {
"lang": "rust",
"repo": "yijie37/DaQiao",
"path": "/bridge/parity-ethereum/secret-store/src/key_server_cluster/io/handshake.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn is_same<T>(a: &T, b: &T) -> bool {
a as *const T == b as *const T
}
fn main() {
let filename = &mut PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
filename.push("inputs/10_1.txt");
println!("Reading {}", filename.display());
let input = fs::read_to_string(filename).expec... | code_fim | hard | {
"lang": "rust",
"repo": "asterycs/aoc2019",
"path": "/src/bin/10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asterycs/aoc2019 path: /src/bin/10.rs
use std::collections::HashMap;
use std::collections::VecDeque;
use std::env;
use std::fs;
use std::hash::{Hash, Hasher};
use std::ops;
use std::path::PathBuf;
#[derive(Eq, Debug, Clone, Copy)]
struct Coord {
x: isize,
y: isize,
}
impl Coord {
f... | code_fim | hard | {
"lang": "rust",
"repo": "asterycs/aoc2019",
"path": "/src/bin/10.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main1() {
for n in 2..100_000_u64 {
let temp = n * (n-1) / 2;
for b in 2..n {
if temp == b * (b - 1) {
println!("n:{} b:{}", n, b);
break;
}
}
}
}
// n:4 b:3
// n:21 b:15
// n:120 b:85
// n:697 b:493
// n:4060 b:287... | code_fim | hard | {
"lang": "rust",
"repo": "sonygod/rust-project-euler",
"path": "/euler100/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sonygod/rust-project-euler path: /euler100/src/main.rs
use std::time::SystemTime;
fn main() {
/*
let start = SystemTime::now();
let sq = 0.5_f64.sqrt();
for n in 1000_000_000_000_u64.. {
let b = (sq * (n as f64) + (1.0 - sq)) as u64;
if n * (n-1) == 2 * b * (b - ... | code_fim | medium | {
"lang": "rust",
"repo": "sonygod/rust-project-euler",
"path": "/euler100/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
B: for<'a> Buffer<'a, S, T>,
{
if self.domain() != DataDomain::Time || self.is_complex() {
self.mark_vector_as_invalid();
self.number_space.to_complex();
self.domain.to_freq();
return Err((
ErrorReason::InputMust... | code_fim | hard | {
"lang": "rust",
"repo": "liebharc/basic_dsp",
"path": "/vector/src/vector_types/time_freq/time_to_freq.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.domain.to_freq();
Self::FreqResult::rededicate_from_force(self)
}
fn fft<B>(self, buffer: &mut B) -> Self::FreqResult
where
B: for<'a> Buffer<'a, S, T>,
{
let mut result = self.plain_fft(buffer);
result.fft_shift();
result
}
fn... | code_fim | hard | {
"lang": "rust",
"repo": "liebharc/basic_dsp",
"path": "/vector/src/vector_types/time_freq/time_to_freq.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liebharc/basic_dsp path: /vector/src/vector_types/time_freq/time_to_freq.rs
use super::super::{
Buffer, DataDomain, DspVec, ErrorReason, FrequencyDomainOperations, InsertZerosOpsBuffered,
MetaData, NumberSpace, RealNumberSpace, RededicateForceOps, ResizeOps, TimeDomain,
TimeDomainOpe... | code_fim | hard | {
"lang": "rust",
"repo": "liebharc/basic_dsp",
"path": "/vector/src/vector_types/time_freq/time_to_freq.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MYMAIDAN/SpotifyClient path: /src/spotify/authorize.rs
use oauth2::{Client, StandardToken, State, Token, Url};
use oauth2_examples::{config_from_args, listen_for_code};
use reqwest::header::{HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE};
use serde::{Deserialize, Serialize};
use std::fmt;
const ... | code_fim | hard | {
"lang": "rust",
"repo": "MYMAIDAN/SpotifyClient",
"path": "/src/spotify/authorize.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>(redirect_url);
let state = State::new_random();
let auth_url = client.authorize_url(&state);
println!("Browse to: {}", auth_url);
let received = listen_for_code(8080).await.unwrap();
let token = client.exchange_code(received.code)
.with_client(&received_client)
... | code_fim | hard | {
"lang": "rust",
"repo": "MYMAIDAN/SpotifyClient",
"path": "/src/spotify/authorize.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Latias94/rust-practice path: /leetcode/src/s0046_permutations.rs
struct Solution;
//leetcode submit region begin(Prohibit modification and deletion)
impl Solution {
pub fn permute(nums: Vec<i32>) -> Vec<Vec<i32>> {
let len = nums.len();
let mut result = Vec::new();
l... | code_fim | hard | {
"lang": "rust",
"repo": "Latias94/rust-practice",
"path": "/leetcode/src/s0046_permutations.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let nums = vec![1, 2, 3];
let mut ans: Vec<Vec<i32>> = [
[1, 2, 3],
[1, 3, 2],
[2, 1, 3],
[2, 3, 1],
[3, 1, 2],
[3, 2, 1],
]
.iter()
.map(|v| v.to_vec())
.collect();
let mut res ... | code_fim | hard | {
"lang": "rust",
"repo": "Latias94/rust-practice",
"path": "/leetcode/src/s0046_permutations.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct Test;
impl FnOnce<(u32, u32)> for Test {
type Output = u32;
extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 {
a + b
}
}
fn main() {
assert_eq!(Test(1u32, 2u32), 3u32);
}<|fim_prefix|>// repo: theduke/rust path: /src/test/run-pass/issue-33687.rs
// Copyri... | code_fim | medium | {
"lang": "rust",
"repo": "theduke/rust",
"path": "/src/test/run-pass/issue-33687.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theduke/rust path: /src/test/run-pass/issue-33687.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http:... | code_fim | medium | {
"lang": "rust",
"repo": "theduke/rust",
"path": "/src/test/run-pass/issue-33687.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kenkoooo/ProgrammingContestLibrary path: /rust/src/union_find.rs
struct UnionFind {
parent: Vec<usize>,
sizes: Vec<usize>,
size: usize,
}
impl UnionFind {
fn new(n: usize) -> UnionFind {
UnionFind {
parent: (0..n).map(|i| { i }).collect::<Vec<usize>>(),
... | code_fim | hard | {
"lang": "rust",
"repo": "kenkoooo/ProgrammingContestLibrary",
"path": "/rust/src/union_find.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: togatoga/screwsat path: /examples/simple.rs
use std::vec;
use screwsat::solver::*;
use screwsat::util;
fn main() {
{
// Create a default Solver struct
let mut solver = Solver::default();
// A problem is (x1 v ¬x5 v x4) ∧ (¬x1 v x5 v x3 v x4) ∧ (x3 v x4)
let c... | code_fim | hard | {
"lang": "rust",
"repo": "togatoga/screwsat",
"path": "/examples/simple.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let clauses = cnf.clauses;
// Create a new Solver struct
let mut solver = Solver::new(variable_num, &clauses);
let status = solver.solve(None);
// Unsat: A problem is UNSATISFIABLE
println!("{:?}", status);
}
{
// Set the time limitation
... | code_fim | hard | {
"lang": "rust",
"repo": "togatoga/screwsat",
"path": "/examples/simple.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marianhlavac/knapsack-problem path: /src/solvers/fptas.rs
use parser::{Knapsack, KnapItem};
use solvers::dynamic;
use std::f32;
pub fn solve(knap: Knapsack, accuracy: f32) -> Knapsack {
// Find the largest price in knapsack
let max_price = knap.items.iter().fold(0, |acc, &x| if x.price ... | code_fim | hard | {
"lang": "rust",
"repo": "marianhlavac/knapsack-problem",
"path": "/src/solvers/fptas.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Fix the result price
solution.price = f32::floor(solution.price as f32 * ratio) as u16;
solution
}<|fim_prefix|>// repo: marianhlavac/knapsack-problem path: /src/solvers/fptas.rs
use parser::{Knapsack, KnapItem};
use solvers::dynamic;
use std::f32;
pub fn solve(knap: Knapsack, accura... | code_fim | medium | {
"lang": "rust",
"repo": "marianhlavac/knapsack-problem",
"path": "/src/solvers/fptas.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fry/n2k-gen path: /n2k/src/fast_packet.rs
#[derive(Debug, Copy, Clone)]
pub enum FastPacketError {
UnexpectedFrameIndex { index: usize, expected: usize },
PacketTooBig { actual: usize, expected: usize },
}
/// Identifier for fast packets that are being reassembled
pub type FastPacketIde... | code_fim | hard | {
"lang": "rust",
"repo": "fry/n2k-gen",
"path": "/n2k/src/fast_packet.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // let new_size = self.data.len() + data.len();
// if new_size > self.total_size {
// return Err(FastPacketError::PacketTooBig {
// expected: self.total_size,
// actual: new_size,
// });
// }
self.data.extend_from_sli... | code_fim | hard | {
"lang": "rust",
"repo": "fry/n2k-gen",
"path": "/n2k/src/fast_packet.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// async fn append_entries(
// mut self,
// _: context::Context,
// request: AppendEntriesReq,
// ) -> AppendEntriesResp {
// let (tx, rx) = oneshot::channel();
// let event = RPCEvent::AppendEntries(AppendEntriesEvent::Request { request, reply: tx });
// ... | code_fim | medium | {
"lang": "rust",
"repo": "Shuumatsu/raft",
"path": "/src/rpc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shuumatsu/raft path: /src/rpc.rs
use crate::protocol::{AppendEntriesReq, AppendEntriesResp, RequestVoteReq, RequestVoteResp};
#[tarpc::service]
pub trait Raft {
async fn request_vote(request: RequestVoteReq) -> RequestVoteResp;
async fn append_entries(request: AppendEntriesReq) -> Appe... | code_fim | medium | {
"lang": "rust",
"repo": "Shuumatsu/raft",
"path": "/src/rpc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>eader structure"]
impl crate::Readable for LPTIM_PIDR_SPEC {}
#[doc = "`reset()` method sets LPTIM_PIDR to value 0x0012_0011"]
impl crate::Resettable for LPTIM_PIDR_SPEC {
const RESET_VALUE: Self::Ux = 0x0012_0011;
}<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp153/lpt... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32mp1/src/stm32mp153/lptim1/lptim_pidr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct LPTIM_PIDR_SPEC;
impl crate::RegisterSpec for LPTIM_PIDR_SPEC {
type Ux = u32;
}
#[doc = "`read()` method returns [`lptim_pidr::R`](R) reader structure"]
impl crate::Readable for LPTIM_PIDR_SPEC {}
#[doc = "`reset()` metho... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32mp1/src/stm32mp153/lptim1/lptim_pidr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp153/lptim1/lptim_pidr.rs
#[doc = "Register `LPTIM_PIDR` reader"]
pub type R = crate::R<LPTIM_PIDR_SPEC>;
#[doc = "Field `P_ID` reader - P_ID"]
pub type P_ID_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - P_ID"]
#[inline(a... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32mp1/src/stm32mp153/lptim1/lptim_pidr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytebuddha/bevy_tiled_world path: /src/systems/spawn/utils.rs
use bevy::prelude::*;
use bevy_tilemap::prelude::*;
use std::path::PathBuf;
use crate::Map;
pub fn get_grid_topology(map: &tiled::Map) -> GridTopology {
match map.orientation {
tiled::Orientation::Orthogonal => GridTopo... | code_fim | hard | {
"lang": "rust",
"repo": "bytebuddha/bevy_tiled_world",
"path": "/src/systems/spawn/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn merge_paths(mut image: PathBuf, mut relative_to: PathBuf) -> PathBuf {
image.pop();
loop {
if relative_to.starts_with("..") {
image.pop();
image = image;
relative_to = relative_to.into_iter().skip(1).collect();
} else {
image.p... | code_fim | hard | {
"lang": "rust",
"repo": "bytebuddha/bevy_tiled_world",
"path": "/src/systems/spawn/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>l_ip_address::local_ip().expect("local ip").to_string());
}<|fim_prefix|>// repo: Aimable-rich/breeze path: /metrics/src/ip.rs
pub fn encode_addr(addr: &str) -> String {
addr.replac<|fim_middle|>e(".", "_").replace(":", "_")
}
lazy_static! {
pub(crate) static ref LOCAL_IP: String =
encode... | code_fim | medium | {
"lang": "rust",
"repo": "Aimable-rich/breeze",
"path": "/metrics/src/ip.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aimable-rich/breeze path: /metrics/src/ip.rs
pub fn encode_addr(addr: &str) -> String {
addr.replac<|fim_suffix|>e) static ref LOCAL_IP: String =
encode_addr(&local_ip_address::local_ip().expect("local ip").to_string());
}<|fim_middle|>e(".", "_").replace(":", "_")
}
lazy_static! {
... | code_fim | easy | {
"lang": "rust",
"repo": "Aimable-rich/breeze",
"path": "/metrics/src/ip.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>e) static ref LOCAL_IP: String =
encode_addr(&local_ip_address::local_ip().expect("local ip").to_string());
}<|fim_prefix|>// repo: Aimable-rich/breeze path: /metrics/src/ip.rs
pub fn encode_addr(addr: &str) -> String {
addr.replac<|fim_middle|>e(".", "_").replace(":", "_")
}
lazy_static! {
... | code_fim | easy | {
"lang": "rust",
"repo": "Aimable-rich/breeze",
"path": "/metrics/src/ip.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn r<T: 'static>(t: T) -> Val {
debug_assert_ne!(TypeId::of::<T>(), TypeId::of::<Val>());
Rc::new(t) as Val
}
pub trait ValInterface {
fn ref_as<T: 'static>(&self) -> Option<&T>;
fn is<T: 'static>(&self) -> bool;
fn get_meta<T: 'static>(&self) -> Option<&T>;
fn wrap_meta<T: 's... | code_fim | medium | {
"lang": "rust",
"repo": "carrotflakes/gluten",
"path": "/src/data.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: carrotflakes/gluten path: /src/data.rs
use std::rc::Rc;
use std::any::{TypeId, Any};
use crate::error::GlutenError;
use crate::env::Env;
pub use crate::package::Package;
pub type R<T> = Rc<T>;
pub type Val = Rc<dyn Any>;
pub type MyFn = Box<dyn Fn(Vec<Val>) -> Val>; // depricated!
pub type Nati... | code_fim | hard | {
"lang": "rust",
"repo": "carrotflakes/gluten",
"path": "/src/data.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_meta<T: 'static>(&self) -> Option<&T>;
fn wrap_meta<T: 'static>(self, metadata: T) -> Val;
fn unwrap_meta(&self) -> &Val;
}
impl ValInterface for Val {
fn ref_as<T: 'static>(&self) -> Option<&T> {
if let Some(m) = self.downcast_ref::<Meta>() {
m.0.ref_as()
... | code_fim | hard | {
"lang": "rust",
"repo": "carrotflakes/gluten",
"path": "/src/data.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PsypherPunk/advent-of-code path: /2016/22/src/main.rs
use std::collections::HashMap;
use std::fmt::{Display, Formatter, Result};
use std::fs;
type Point = (isize, isize);
struct Cluster {
grid: HashMap<Point, Node>,
}
#[derive(PartialEq)]
struct Node {
size: usize,
used: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "PsypherPunk/advent-of-code",
"path": "/2016/22/src/main.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let &(max_x, max_y) = self.grid.keys().max().unwrap();
let moves = self
.get_viable_pairs()
.iter()
.flat_map(|pair| vec![pair.0, pair.1])
.collect::<Vec<_>>();
let output = (0..=max_x)
.map(|x| {
(0..=max... | code_fim | hard | {
"lang": "rust",
"repo": "PsypherPunk/advent-of-code",
"path": "/2016/22/src/main.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>dp.push((0, a[i]-a[i-1]));
}
}
dp.reverse();
let mut sum = 0;
for &p in &dp {
if sum + p.1 < a[n-1] {
sum += p.1;
} else {
let pos = 1 - (a[n-1] - sum)%2;
println!("{}", if (pos + p.0)%2 == 1 { "First" } else { "Second" });
... | code_fim | medium | {
"lang": "rust",
"repo": "pes-magic/procon",
"path": "/AtCoder/AGC002/E.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> else {
let pos = 1 - (a[n-1] - sum)%2;
println!("{}", if (pos + p.0)%2 == 1 { "First" } else { "Second" });
break
}
}
}<|fim_prefix|>// repo: pes-magic/procon path: /AtCoder/AGC002/E.rs
fn main() {
proconio::input! {
n: usize,
mut a: [u... | code_fim | hard | {
"lang": "rust",
"repo": "pes-magic/procon",
"path": "/AtCoder/AGC002/E.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pes-magic/procon path: /AtCoder/AGC002/E.rs
fn main() {
proconio::input! {
n: usize,
mut a: [usize; n]
}
a.sort();
let mut dp = vec![(0, a[0]); 1];
for i in 1..n {
if <|fim_suffix|>dp.push((0, a[i]-a[i-1]));
}
}
dp.reverse();
let mu... | code_fim | medium | {
"lang": "rust",
"repo": "pes-magic/procon",
"path": "/AtCoder/AGC002/E.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pnkfelix/rust path: /src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
#![feature(generic_associated_types)]
pub trait X {
type Y<'a> where Self: 'a;
fn m(&self) -> Self::Y<'... | code_fim | medium | {
"lang": "rust",
"repo": "pnkfelix/rust",
"path": "/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn h(x: &()) -> &'static () {
x.m()
//[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
//[nll]~^^ ERROR lifetime may not live long enough
}
fn main() {
f(&());
g(&());
h(&());
}<|fim_prefix|>// repo: pnkfelix/rust ... | code_fim | hard | {
"lang": "rust",
"repo": "pnkfelix/rust",
"path": "/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cargo-generate/cargo-generate path: /src/git/mod.rs
//! Handle `--git` and related flags
use std::path::{Path, PathBuf};
use std::{io, ops::Sub, thread::sleep, time::Duration};
use anyhow::Result;
use git2::{build::RepoBuilder, FetchOptions, ProxyOptions, Repository, RepositoryInitOptions};
us... | code_fim | hard | {
"lang": "rust",
"repo": "cargo-generate/cargo-generate",
"path": "/src/git/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let url = gitconfig::find_gitconfig()?.map_or_else(
|| url.to_owned(),
|gitcfg| {
gitconfig::resolve_instead_url(url, gitcfg)
.expect("correct configuration")
.unwrap_or_else(|| url.to_owned())
},
)... | code_fim | hard | {
"lang": "rust",
"repo": "cargo-generate/cargo-generate",
"path": "/src/git/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>, 1);
points.insert('o', 1);
points.insert('p', 3);
points.insert('q', 10);
points.insert('r', 1);
points.insert('s', 1);
points.insert('t', 1);
points.insert('u', 1);
points.insert('v', 4);
points.insert('w', 4);
points.inser... | code_fim | hard | {
"lang": "rust",
"repo": "mipli/exercism",
"path": "/scrabble-score/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mipli/exercism path: /scrabble-score/src/lib.rs
use std::collections::{HashMap};
use lazy_static::*;
lazy_static! {
static ref POINTS: HashMap<char, u64> = {
let mut points = HashMap::default();
points.insert('a', 1);
points.insert('b', 3);
points.insert('c',... | code_fim | hard | {
"lang": "rust",
"repo": "mipli/exercism",
"path": "/scrabble-score/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>points.insert('x', 8);
points.insert('y', 4);
points.insert('z', 10);
points
};
}
pub fn score(word: &str) -> u64 {
word.to_lowercase().chars()
.fold(0, |acc, c| acc + get_points(&c))
}
fn get_points(c: &char) -> &u64 {
POINTS.get(c).unwrap_or(&0)
}<|fim_prefi... | code_fim | hard | {
"lang": "rust",
"repo": "mipli/exercism",
"path": "/scrabble-score/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elauffenburger/sixty-five-oh-too path: /src/cpu/instr/or.rs
use super::Cpu;
use super::InstrResult;
use super::super::addr;
use self::addr::AddrResult;
use std::fmt;
enum OrType {
LogicalExclusive,
LogicalInclusive,
}
pub mod eor {
use super::Cpu;
use super::InstrResult;
u... | code_fim | hard | {
"lang": "rust",
"repo": "elauffenburger/sixty-five-oh-too",
"path": "/src/cpu/instr/or.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn ind_x(cpu: &mut Cpu) -> Box<InstrResult> {
let addr_result = addr::ind_x(cpu);
ora(addr_result, 2, 6)
}
pub fn ind_y(cpu: &mut Cpu) -> Box<InstrResult> {
let addr_result = addr::ind_y(cpu);
ora(addr_result, 2, 5)
}
pub fn ora(addr_result: Addr... | code_fim | hard | {
"lang": "rust",
"repo": "elauffenburger/sixty-five-oh-too",
"path": "/src/cpu/instr/or.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = match self.or_type {
OrType::LogicalExclusive => cpu.reg_acc ^ value,
OrType::LogicalInclusive => cpu.reg_acc | value,
};
cpu.reg_acc = result;
cpu.reg_status.zero = result == 0;
cpu.reg_status.negative = result < 0;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "elauffenburger/sixty-five-oh-too",
"path": "/src/cpu/instr/or.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Formatted address to bind the HTTP server to
pub fn address(&self) -> String {
format!("{}:{}", &self.networking.host, &self.networking.port)
}
#[allow(dead_code)]
pub fn default_host() -> String {
return "0.0.0.0".to_string();
}
#[allow(dead_code)]
pu... | code_fim | hard | {
"lang": "rust",
"repo": "kyle-mccarthy/fn-rs",
"path": "/fn-core/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FunctionConfig {
#[allow(dead_code)]
pub fn new(
method: String,
route: String,
handler: String,
cmd: Option<String>,
runtime: String,
) -> FunctionConfig {
FunctionConfig {
method,
route,
handler,
... | code_fim | hard | {
"lang": "rust",
"repo": "kyle-mccarthy/fn-rs",
"path": "/fn-core/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kyle-mccarthy/fn-rs path: /fn-core/src/config.rs
use failure::Fail;
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::BufReader;
use uuid::Uuid;
use std::process::Command;
#[derive(Debug, Fail)]
pub enum ConfigError {
#[fail(display = "IO Error {}", _0)]
IOError(std:... | code_fim | hard | {
"lang": "rust",
"repo": "kyle-mccarthy/fn-rs",
"path": "/fn-core/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jplevyak/sdk path: /src/dfx/src/commands/canister/request_status.rs
use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::lib::waiter::wait... | code_fim | hard | {
"lang": "rust",
"repo": "jplevyak/sdk",
"path": "/src/dfx/src/commands/canister/request_status.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Specifies the format for displaying the method's return result.
#[clap(long,
possible_values(&["idl", "raw", "pp"]))]
output: Option<String>,
}
pub async fn exec(env: &dyn Environment, opts: RequestStatusOpts) -> DfxResult {
let request_id =
RequestId::from_str(&opts.r... | code_fim | hard | {
"lang": "rust",
"repo": "jplevyak/sdk",
"path": "/src/dfx/src/commands/canister/request_status.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kevinreedy/delivery-cli path: /src/delivery/command/review.rs
//
// Copyright:: Copyright (c) 2016 Chef Software, Inc.
// License:: Apache License, Version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License... | code_fim | hard | {
"lang": "rust",
"repo": "kevinreedy/delivery-cli",
"path": "/src/delivery/command/review.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line in review.messages.iter() {
sayln("white", line);
}
match try!(project::handle_review_result(&review, &review_opts.no_open)) {
Some(url) => {sayln("magenta", &url)},
None => {}
}
Ok(0)
}
fn edit_change(config: &Config,
review: &ReviewRe... | code_fim | hard | {
"lang": "rust",
"repo": "kevinreedy/delivery-cli",
"path": "/src/delivery/command/review.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /src/exchange/coinbase/client/websocket.rs
use async_trait::async_trait;
use std::{collections::HashMap, pin::Pin, task::Poll};
use futures::{
stream::{SplitStream, Stream},
SinkExt, StreamExt,
};
use serde::{Deserialize, Serialize};
use tokio::net::TcpStream;
... | code_fim | hard | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/src/exchange/coinbase/client/websocket.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (channels, product_ids) = match &subscription.as_slice()[0] {
CoinbaseSubscription::Level2(product_id) => (
vec![Channel::Name(ChannelType::Level2)],
vec![product_id.clone()],
),
CoinbaseSubscription::Heartbeat(product_id) => ... | code_fim | hard | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/src/exchange/coinbase/client/websocket.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>cause you can't define
// a const using a function (like Duration::seconds). Tried using lazy_static to make it
// a static, but that gave me type errors, so whatever: it's just hard-coded in here
start + Duration::seconds(1000000000)
}<|fim_prefix|>// repo: coriolinus/exercism-rs path: /giga... | code_fim | medium | {
"lang": "rust",
"repo": "coriolinus/exercism-rs",
"path": "/gigasecond/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coriolinus/exercism-rs path: /gigasecond/src/lib.rs
extern crate chrono;
use chrono::*;
/// Return a DateTime 1 Gigasecond (10e9) seconds after the one given.
pub fn after<Tz:<|fim_suffix|>cause you can't define
// a const using a function (like Duration::seconds). Tried using lazy_static t... | code_fim | medium | {
"lang": "rust",
"repo": "coriolinus/exercism-rs",
"path": "/gigasecond/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = vec!["test".to_owned(),"test2".to_owned()];
let output = input.clone();
let x = ProcessConfig::new("tac").run((input,output));
assert_eq!(x,Verdict::WrongOutput);
println!("{:?}", x);
}<|fim_prefix|>// repo: vldm/OlyTester path: /src/main.rs
extern crate time;
extern crate lib... | code_fim | easy | {
"lang": "rust",
"repo": "vldm/OlyTester",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vldm/OlyTester path: /src/main.rs
extern crate time;
extern crate libc;
mod process;
use process::{ProcessConfig, Verdict};
<|fim_suffix|> let input = vec!["test".to_owned(),"test2".to_owned()];
let output = input.clone();
let x = ProcessConfig::new("tac").run((input,output));
assert... | code_fim | easy | {
"lang": "rust",
"repo": "vldm/OlyTester",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davehorner/playwright-rust path: /src/api/file_chooser.rs
pub use crate::imp::file_hooser::FileChooser;
use crate::{
api::{element_handle::SetInputFilesBuilder, ElementHandle, Page},
imp::utils::File
};
impl FileChooser {
/// Returns input element associated with this file chooser.
... | code_fim | hard | {
"lang": "rust",
"repo": "davehorner/playwright-rust",
"path": "/src/api/file_chooser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns whether this file chooser accepts multiple files.
fn is_multiple(&self) -> bool { self.is_multiple }
/// Returns page this file chooser belongs to.
fn page(&self) -> Page { Page::new(self.page.clone()) }
/// Sets the value of the file input this chooser is associated with.... | code_fim | medium | {
"lang": "rust",
"repo": "davehorner/playwright-rust",
"path": "/src/api/file_chooser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ReeCocho/camp-misty path: /src/multiplayer/net_play.rs
use super::packets::*;
use crate::game::game_state::*;
use crate::game::killer_user::*;
use crate::game::victim_user::*;
use crate::util::*;
/// Play the game with another user over the internet.
///
/// Takes in our 'player_type' and a 'st... | code_fim | medium | {
"lang": "rust",
"repo": "ReeCocho/camp-misty",
"path": "/src/multiplayer/net_play.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Wait for other player to tell us their move
println!("Waiting for the other player move...");
let other_player_move = read_over_tcp::<MovePacket>(stream);
// Submit moves to the game state
let res = if player_type == PlayerType::Killer {
state.play(
(other_playe... | code_fim | medium | {
"lang": "rust",
"repo": "ReeCocho/camp-misty",
"path": "/src/multiplayer/net_play.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run(
pool: ConnectionPool,
store: Option<Arc<Store>>,
search: DeploymentSearch,
current: bool,
pending: bool,
used: bool,
) -> Result<(), anyhow::Error> {
let deployments = search.find(pool, current, pending, used)?;
let ids: Vec<_> = deployments.iter().map(|d| d.loc... | code_fim | medium | {
"lang": "rust",
"repo": "graphprotocol/graph-node",
"path": "/node/src/manager/commands/info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: graphprotocol/graph-node path: /node/src/manager/commands/info.rs
use std::sync::Arc;
use graph::{components::store::StatusStore, data::subgraph::status, prelude::anyhow};
use graph_store_postgres::{connection_pool::ConnectionPool, Store};
<|fim_suffix|> if deployments.is_empty() {
... | code_fim | hard | {
"lang": "rust",
"repo": "graphprotocol/graph-node",
"path": "/node/src/manager/commands/info.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wjlewis/just_text path: /src/lib/note/expr.rs
pub type Span = (usize, usize);
<|fim_suffix|>pub enum TextElement {
Prose(Span),
Link { title: Span, href: Span },
Mono(Span),
}<|fim_middle|>pub struct Note {
pub paragraphs: Vec<Paragraph>,
}
pub struct Paragraph {
pub parts:... | code_fim | medium | {
"lang": "rust",
"repo": "wjlewis/just_text",
"path": "/src/lib/note/expr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub enum TextElement {
Prose(Span),
Link { title: Span, href: Span },
Mono(Span),
}<|fim_prefix|>// repo: wjlewis/just_text path: /src/lib/note/expr.rs
pub type Span = (usize, usize);
pub struct Note {
pub paragraphs: Vec<Paragraph>,
}
<|fim_middle|>pub struct Paragraph {
pub parts:... | code_fim | easy | {
"lang": "rust",
"repo": "wjlewis/just_text",
"path": "/src/lib/note/expr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn movlpd_4() {
run_test(&Instruction { mnemonic: Mnemonic::MOVLPD, operand1: Some(IndirectScaledIndexed(RAX, RBX, Four, Some(OperandSize::Qword), None)), operand2: Some(Direct(XMM7)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, b... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/instr_movlpd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_movlpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
<|f... | code_fim | medium | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/instr_movlpd.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ops-l/zCore path: /zircon-syscall/src/debug.rs
use super::*;
impl Syscall<'_> {
pub fn sys_debug_write(&self, buf: UserInPtr<u8>, len: usize) -> ZxResult {
info!("debug.write: buf=({:?}; {:#x})", buf, len);
let d<|fim_suffix|>d(
&self,
handle: HandleValue,
... | code_fim | medium | {
"lang": "rust",
"repo": "ops-l/zCore",
"path": "/zircon-syscall/src/debug.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "debug.read: handle={:#x}, buf=({:?}; {:#x})",
handle, buf, buf_size
);
buf.write_cstring("HelloWorld\n")?;
actual.write(11)?;
Ok(())
}
}<|fim_prefix|>// repo: ops-l/zCore path: /zircon-syscall/src/debug.rs
use super::*;
impl Syscall<'_> {
pub fn sys_... | code_fim | hard | {
"lang": "rust",
"repo": "ops-l/zCore",
"path": "/zircon-syscall/src/debug.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>r.align_byte();
let bits = reader.read_ub8(5)?;
let x_min = reader.read_sb(bits)?;
let x_max = reader.read_sb(bits)?;
let y_min = reader.read_sb(bits)?;
let y_max = reader.read_sb(bits)?;
Ok(Self {
x_min,
x_max,
y_min,
... | code_fim | medium | {
"lang": "rust",
"repo": "djcsdy/wildflower-codec",
"path": "/src/decode/tags/common/rectangle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: djcsdy/wildflower-codec path: /src/decode/tags/common/rectangle.rs
use crate::decode::bit_read::BitRead;
use std::io::Result;
/// An axis-aligned rectangle.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub struct Rectangle {
pub x_min: i32,
pub x_max: i32,
pub y_min: i32,
... | code_fim | medium | {
"lang": "rust",
"repo": "djcsdy/wildflower-codec",
"path": "/src/decode/tags/common/rectangle.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ead_sb(bits)?;
let y_max = reader.read_sb(bits)?;
Ok(Self {
x_min,
x_max,
y_min,
y_max,
})
}
}<|fim_prefix|>// repo: djcsdy/wildflower-codec path: /src/decode/tags/common/rectangle.rs
use crate::decode::bit_read::BitRead;
use std... | code_fim | hard | {
"lang": "rust",
"repo": "djcsdy/wildflower-codec",
"path": "/src/decode/tags/common/rectangle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(str::from_utf8(&result.stdout).unwrap(), "nil\n");
assert!(result.status.success());
}<|fim_prefix|>// repo: glugg23/rox path: /tests/nil.rs
use std::process::Command;
use std::str;
#[test]
fn literal() {
<|fim_middle|> let result = Command::new("cargo")
.args(&[
... | code_fim | hard | {
"lang": "rust",
"repo": "glugg23/rox",
"path": "/tests/nil.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: glugg23/rox path: /tests/nil.rs
use std::process::Command;
use std::str;
#[test]
fn literal() {
<|fim_suffix|> assert_eq!(str::from_utf8(&result.stdout).unwrap(), "nil\n");
assert!(result.status.success());
}<|fim_middle|> let result = Command::new("cargo")
.args(&[
... | code_fim | hard | {
"lang": "rust",
"repo": "glugg23/rox",
"path": "/tests/nil.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Autumin/fuchsia path: /src/diagnostics/archivist/src/internal_logging.rs
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
<|fim_suffix|> fn log(&self, record: &Record<'_>) {
... | code_fim | hard | {
"lang": "rust",
"repo": "Autumin/fuchsia",
"path": "/src/diagnostics/archivist/src/internal_logging.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Initialize internal logging.
pub fn init(app_name: &'static str) {
let logger = Box::leak(Box::new(Logger { app_name }));
set_logger(logger).unwrap();
set_max_level(LevelFilter::Info);
}<|fim_prefix|>// repo: Autumin/fuchsia path: /src/diagnostics/archivist/src/internal_logging.rs
// Copy... | code_fim | hard | {
"lang": "rust",
"repo": "Autumin/fuchsia",
"path": "/src/diagnostics/archivist/src/internal_logging.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Terkwood/BUGOUT path: /micro-sync/src/lib.rs
mod components;
pub mod player;
mod repo;
pub mod stream;
mod sync;
mod time;
mod to_history;
<|fim_suffix|>const REDIS_URL: &str = "redis://redis/";
pub fn create_redis_client() -> Rc<Client> {
Rc::new(Client::open(REDIS_URL).expect("redis clien... | code_fim | medium | {
"lang": "rust",
"repo": "Terkwood/BUGOUT",
"path": "/micro-sync/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>const REDIS_URL: &str = "redis://redis/";
pub fn create_redis_client() -> Rc<Client> {
Rc::new(Client::open(REDIS_URL).expect("redis client"))
}<|fim_prefix|>// repo: Terkwood/BUGOUT path: /micro-sync/src/lib.rs
mod components;
pub mod player;
mod repo;
pub mod stream;
mod sync;
mod time;
mod to_hist... | code_fim | medium | {
"lang": "rust",
"repo": "Terkwood/BUGOUT",
"path": "/micro-sync/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// fn visit(c: &str, d: i32, hm:&HashMap<&str, Vec<&str>>) -> i32 {
// let mut ct = d;
// let kids =
// match hm.get(c) {
// Some(kids) => {
// for k in kids {
// ct += visit(k,d+1,hm);
// }
// },
// None => {}
// };
// r... | code_fim | hard | {
"lang": "rust",
"repo": "snagy/advent_of_code_2019",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// #[derive(Debug, Clone, Copy, Hash)]
// struct Vector2 {
// x: i64,
// y: i64
// }
// impl PartialEq for Vector2 {
// fn eq(&self, other: &Self) -> bool {
// self.x == other.x && self.y == other.y
// }
// }
// impl Eq for Vector2 { }
// fn day_13() {
// let mut codes = load... | code_fim | hard | {
"lang": "rust",
"repo": "snagy/advent_of_code_2019",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snagy/advent_of_code_2019 path: /src/main.rs
at params[0]
//println!("output = codes[{}] ({})", params[0], get_safe(¶ms[0]));
inout(true, get_safe(¶ms[0]));
*i += 2;
//return (get_safe(¶ms[0]), false)
},
... | code_fim | hard | {
"lang": "rust",
"repo": "snagy/advent_of_code_2019",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for info in add_info {
ipfs.cat(&info.Hash).expect("Error catting");
}
ipfs.version().expect("Error getting version");
}<|fim_prefix|>// repo: leavehouse/rust-ipfs-api path: /wireshark_capture/api_call.rs
extern crate ipfs_api;
use ipfs_api::IpfsApi;
use std::path::Path;
<|fim_midd... | code_fim | hard | {
"lang": "rust",
"repo": "leavehouse/rust-ipfs-api",
"path": "/wireshark_capture/api_call.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leavehouse/rust-ipfs-api path: /wireshark_capture/api_call.rs
extern crate ipfs_api;
use ipfs_api::IpfsApi;
use std::path::Path;
fn main() {
<|fim_suffix|> ipfs.version().expect("Error getting version");
}<|fim_middle|> let mut ipfs = IpfsApi::default();
let add_info = ipfs.add(&[Pat... | code_fim | hard | {
"lang": "rust",
"repo": "leavehouse/rust-ipfs-api",
"path": "/wireshark_capture/api_call.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const ID_SCE: u32 = 0; /* Single Channel Element */
pub const ID_CPE: u32 = 1; /* Channel Pair Element */
pub const ID_CCE: u32 = 2; /* Coupling Channel Element */
pub const ID_LFE: u32 = 3; /* LFE Channel Element */
pub const ID_DSE: u32 = 4; /* Not yet supported */
pub const ID_PCE: u32 = 5; /* Not ... | code_fim | hard | {
"lang": "rust",
"repo": "beaulac/alac-enc.rs",
"path": "/src/alac_constants.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beaulac/alac-enc.rs path: /src/alac_constants.rs
/**
* Lossless Definitions
*/
pub const CODEC_FORMAT: *const str = "alac";
pub const ALAC_VERSION: u32 = 0;
pub const COMPATIBLE_VERSION: u32 = ALAC_VERSION;
pub const DEFAULT_FRAME_SIZE: u32 = 4096;
<|fim_suffix|>pub const ID_SCE: u32 = 0; /*... | code_fim | hard | {
"lang": "rust",
"repo": "beaulac/alac-enc.rs",
"path": "/src/alac_constants.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> .write(format!("{} - {}", filename, e).as_bytes())
.unwrap();
return;
}
};
if content.len() == 0 {
std::io::stderr().write("Empty file".as_bytes()).unwrap();
return;
}
let mut words: usize = 0;
for i in content.chars() {
if i == ' ' {
words += 1;
}
}... | code_fim | medium | {
"lang": "rust",
"repo": "siddharthborderwala/rs-text-exercises",
"path": "/src/word_counter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ap();
return;
}
let mut words: usize = 0;
for i in content.chars() {
if i == ' ' {
words += 1;
}
}
words += 1;
println!("Number of words: {}", words);
}<|fim_prefix|>// repo: siddharthborderwala/rs-text-exercises path: /src/word_counter.rs
use std::io::Write;
fn main() {
... | code_fim | medium | {
"lang": "rust",
"repo": "siddharthborderwala/rs-text-exercises",
"path": "/src/word_counter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: siddharthborderwala/rs-text-exercises path: /src/word_counter.rs
use std::io::Write;
fn main() {
let filename = match std::env::args().nth(1) {
Some(name) => name,
None => {
std::io::stderr()
.write(b"Please enter the file<|fim_suffix|> .write(format!("{} - {}", filen... | code_fim | medium | {
"lang": "rust",
"repo": "siddharthborderwala/rs-text-exercises",
"path": "/src/word_counter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check that the value is a valid cell state.
let cell_state_value = args.compile(compiler, 0)?.as_int()?;
// Treat the signed integer as an unsigned integer, and build a
// condition testing whether that value is less than the number of cell
// states. (A negative... | code_fim | hard | {
"lang": "rust",
"repo": "HactarCE/NDCA",
"path": "/src/functions/convert.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Branch based on the whether the cell state is in range.
compiler.build_conditional(
condition,
// The cell state is in range.
|_| Ok(()),
// The cell state is out of range.
|c| Ok(self.out_of_range_error.compile(c)),
)?... | code_fim | hard | {
"lang": "rust",
"repo": "HactarCE/NDCA",
"path": "/src/functions/convert.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HactarCE/NDCA path: /src/functions/convert.rs
//! Conversion functions.
use inkwell::IntPredicate;
use std::rc::Rc;
use super::super::ast::{
ArgValues, ErrorPointRef, FnSignature, Function, FunctionKind, RuleMeta, UserFunction,
};
use super::super::compiler::{Compiler, Value};
use super::s... | code_fim | hard | {
"lang": "rust",
"repo": "HactarCE/NDCA",
"path": "/src/functions/convert.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: passivetotal/rust_api path: /src/lib.rs
#![allow(non_snake_case)]
#![doc(html_logo_url = "https://s3-us-west-1.amazonaws.com/passivetotal-website/public/core-pt-logo-sm.png",
html_favicon_url = "https://passivetotal.org/static/img/favicon/png",
html_root_url = "https://passivetotal... | code_fim | hard | {
"lang": "rust",
"repo": "passivetotal/rust_api",
"path": "/src/lib.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.