text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let g = Grid::from(grid);
let mut slopes = Vec::new();
slopes.push(g.num_trees_from(1, 1));
slopes.push(g.num_trees_from(3, 1));
slopes.push(g.num_trees_from(5, 1));
slopes.push(g.num_trees_from(7, 1));
slopes.push(g.num_trees_from(1, 2));
slopes.iter().product()
}
#[test]... | code_fim | hard | {
"lang": "rust",
"repo": "fapete/advent_of_code",
"path": "/2020/day3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> error!(sl!(), "{}", err_msg);
let mut status = Status::new();
// FIXME:
status.set_code(Code::NOT_FOUND);
status.set_message("foo".to_string());
return Err(TError::RpcStatus(status));
}
let tx = cfg.tx.as_ref().unw... | code_fim | hard | {
"lang": "rust",
"repo": "jamesodhunt/test-protobuf-ttrpc",
"path": "/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamesodhunt/test-protobuf-ttrpc path: /src/server.rs
// Description: Server side of ttRPC comms
use crate::service::{HelloReply, HelloRequest, ShutdownReply, ShutdownRequest};
use crate::service_ttrpc::{create_my_service, MyService};
use crate::types::HelloService;
use nix::unistd::close;
use t... | code_fim | hard | {
"lang": "rust",
"repo": "jamesodhunt/test-protobuf-ttrpc",
"path": "/src/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // FIXME:
status.set_code(Code::NOT_FOUND);
status.set_message(format!("{:?}", result.err()));
return Err(TError::RpcStatus(status));
}
Ok(ShutdownReply::new())
}
}
pub fn server(service: &HelloService, rx: Receiver<bool>) -> Result<()... | code_fim | hard | {
"lang": "rust",
"repo": "jamesodhunt/test-protobuf-ttrpc",
"path": "/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>g_docs)]
#![deny(warnings)]
#![no_std]<|fim_prefix|>// repo: eldruin/cortex-r path: /src/lib.rs
//! Low level access to Cortex-R proce<|fim_middle|>ssors
//!
//! # Supported Rust version
//!
//! Rust >=1.31.0
#![deny(missin | code_fim | medium | {
"lang": "rust",
"repo": "eldruin/cortex-r",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eldruin/cortex-r path: /src/lib.rs
//! Low level access to Cortex-R processors
//!
//! # Supported Rust version<|fim_suffix|>g_docs)]
#![deny(warnings)]
#![no_std]<|fim_middle|>
//!
//! Rust >=1.31.0
#![deny(missin | code_fim | easy | {
"lang": "rust",
"repo": "eldruin/cortex-r",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eldruin/cortex-r path: /src/lib.rs
//! Low level access to Cortex-R proce<|fim_suffix|>g_docs)]
#![deny(warnings)]
#![no_std]<|fim_middle|>ssors
//!
//! # Supported Rust version
//!
//! Rust >=1.31.0
#![deny(missin | code_fim | medium | {
"lang": "rust",
"repo": "eldruin/cortex-r",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 2color/prisma-engines path: /introspection-engine/connectors/sql-introspection-connector/src/error.rs
use introspection_connector::{ConnectorError, ErrorKind};
use quaint::error::{Error as QuaintError, ErrorKind as QuaintKind};
use thiserror::Error;
use user_facing_errors::introspection_engine::... | code_fim | hard | {
"lang": "rust",
"repo": "2color/prisma-engines",
"path": "/introspection-engine/connectors/sql-introspection-connector/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[error("Connect timed out")]
ConnectTimeout(#[source] QuaintKind),
#[error("Operation timed out ({0})")]
Timeout(String),
#[error("Error opening a TLS connection. {}", cause)]
TlsError {
#[source]
cause: QuaintKind,
},
#[error("Unique constraint violatio... | code_fim | hard | {
"lang": "rust",
"repo": "2color/prisma-engines",
"path": "/introspection-engine/connectors/sql-introspection-connector/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the stored encryption key representation as raw bytes.
fn bytes(&self) -> Vec<u8>;
}<|fim_prefix|>// repo: igorty/encrypted_communicator path: /src/secret/communication_key.rs
use crate::secret::Error;
pub trait CommunicationKey {
fn name(&self) -> String;
<|fim_middle|> fn encrypt(&... | code_fim | hard | {
"lang": "rust",
"repo": "igorty/encrypted_communicator",
"path": "/src/secret/communication_key.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: igorty/encrypted_communicator path: /src/secret/communication_key.rs
use crate::secret::Error;
pub trait CommunicationKey {
fn name(&self) -> String;
<|fim_suffix|> /// Decrypts `encrypted_data`.
/// # Parameters
/// * `encrypted_data` – The data to be decrypted.
fn decrypt(&self, dat... | code_fim | easy | {
"lang": "rust",
"repo": "igorty/encrypted_communicator",
"path": "/src/secret/communication_key.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if grid[y][x] == '+' {
// change direction
match direction {
Down | Up => {
if grid_at(&grid, x + 1, y) != ' ' {
x = x + 1;
direction = Right;
} else if grid_at(&grid, x ... | code_fim | hard | {
"lang": "rust",
"repo": "matthewelse/advent-of-code-2017",
"path": "/day19/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match direction {
Down => y = y + 1,
Up => y = y - 1,
Left => x = x - 1,
Right => x = x + 1,
}
}
}
println!();
println!("{} steps", steps - 1);
}<|fim_prefix|>// repo: matthewelse/advent-of-code-20... | code_fim | hard | {
"lang": "rust",
"repo": "matthewelse/advent-of-code-2017",
"path": "/day19/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matthewelse/advent-of-code-2017 path: /day19/src/main.rs
use std::fs::File;
use std::io::prelude::*;
#[derive(Debug)]
enum Direction {
Down,
Left,
Right,
Up,
}
use self::Direction::*;
fn grid_at(grid: &Vec<Vec<char>>, x: usize, y: usize) -> char {
if y >= grid.len() || x >... | code_fim | hard | {
"lang": "rust",
"repo": "matthewelse/advent-of-code-2017",
"path": "/day19/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laanwj/k210-pac path: /src/sysctl/pll2.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::PLL2 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modif... | code_fim | hard | {
"lang": "rust",
"repo": "laanwj/k210-pac",
"path": "/src/sysctl/pll2.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> const OFFSET: u8 = 10;
((self.bits >> OFFSET) & MASK as u32) as u8
};
CLKODR { bits }
}
#[doc = "Bits 14:19"]
#[inline]
pub fn bwadj(&self) -> BWADJR {
let bits = {
const MASK: u8 = 63;
const OFFSET: u8 = 14;
((se... | code_fim | hard | {
"lang": "rust",
"repo": "laanwj/k210-pac",
"path": "/src/sysctl/pll2.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn write_metadata<W>(writer: &mut W, depth: u8, metadata: &Metadata) -> io::Result<()>
where
W: Write,
{
const N_CHUNK: i32 = 2;
let bin_id = u32::try_from(Bin::metadata_id(depth))
.map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
writer.write_u32::<Litt... | code_fim | hard | {
"lang": "rust",
"repo": "zaeleus/noodles",
"path": "/noodles-csi/src/writer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-csi/src/writer.rs
use std::{
collections::HashMap,
io::{self, Write},
};
use byteorder::{LittleEndian, WriteBytesExt};
use noodles_bgzf as bgzf;
use super::{
index::{
header::ReferenceSequenceNames,
reference_sequence::{bin::Chunk, Bin... | code_fim | hard | {
"lang": "rust",
"repo": "zaeleus/noodles",
"path": "/noodles-csi/src/writer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let timeline = client.timeline(&instance_url, access_token, timeline::Endpoint::Federated);
core.run(timeline.for_each(|s| {
println!("{:#?}", s);
Ok(())
})).chain_err(|| "received error from timeline")
});<|fim_prefix|>// repo: walfie/olifants path: /examples/stream.rs
#[mac... | code_fim | medium | {
"lang": "rust",
"repo": "walfie/olifants",
"path": "/examples/stream.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: walfie/olifants path: /examples/stream.rs
#[macro_use]
extern crate error_chain;
extern crate olifants;
extern crate futures;
extern crate tokio_core;
use futures::Stream;
use olifants::{Client, timeline};
use olifants::error::*;
use tokio_core::reactor::Core;
// Get from environment variable... | code_fim | medium | {
"lang": "rust",
"repo": "walfie/olifants",
"path": "/examples/stream.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>quick_main!(|| -> Result<()> {
let mut core = Core::new().chain_err(|| "could not create Core")?;
let client = Client::new(&core.handle(), "olifants").chain_err(
|| "could not create Client",
)?;
let instance_url = get_env("INSTANCE_URL")?;
let access_token = get_env("ACCESS_T... | code_fim | hard | {
"lang": "rust",
"repo": "walfie/olifants",
"path": "/examples/stream.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// 二項演算子を処理する
fn compile_binop(&mut self, operator: &BinaryOperator, buf: &mut String) {
use super::parser::BinaryOperatorKind::*;
match operator.value {
Add => buf.push_str("+"),
Sub => buf.push_str("-"),
Multi => buf.push_str("*"),
... | code_fim | hard | {
"lang": "rust",
"repo": "TakeZNt/parser",
"path": "/src/compiler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TakeZNt/parser path: /src/compiler.rs
use super::parser::*;
/// 逆ポーランド記法へのコンパイラ
pub struct RpnCompiler;
impl RpnCompiler {
pub fn new() -> Self {
RpnCompiler
}
///
/// 抽象構文木を解析し、逆ポーランド記法の文字列へ変換して返す
///
pub fn compile(&mut self, expr: &Ast) -> String {
l... | code_fim | hard | {
"lang": "rust",
"repo": "TakeZNt/parser",
"path": "/src/compiler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::parser::AstKind::*;
match expr.value {
Num(n) => buf.push_str(&n.to_string()),
Unary {
ref operator,
ref operand,
} => {
self.compile_uniop(operator, buf);
self.compile_inner(oper... | code_fim | hard | {
"lang": "rust",
"repo": "TakeZNt/parser",
"path": "/src/compiler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doyoubi/mylint-rs path: /src/lint/validators/mod.rs
use crate::lint::core::Validator;
// #[macro_use]
// pub mod utils;
<|fim_suffix|>pub fn get_all_validators() -> Vec<Box<dyn Validator>> {
vec![
Box::new(unsafe_code::UnsafeCodeValidator),
Box::new(use_unsafe::UseUnsafeVal... | code_fim | medium | {
"lang": "rust",
"repo": "doyoubi/mylint-rs",
"path": "/src/lint/validators/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_all_validators() -> Vec<Box<dyn Validator>> {
vec![
Box::new(unsafe_code::UnsafeCodeValidator),
Box::new(use_unsafe::UseUnsafeValidator),
Box::new(unwrap_call::UnwrapCallValidator),
Box::new(expect_call::ExpectCallValidator),
Box::new(index_expr::Inde... | code_fim | medium | {
"lang": "rust",
"repo": "doyoubi/mylint-rs",
"path": "/src/lint/validators/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::main]
async fn main() -> anyhow::Result<()> {
let Options { api_base_url } = Options::from_args();
println!("Given API Base URL:");
println!("{}", api_base_url);
let api = Api::new(api_base_url)?;
let mut w_addrs = Vec::new();
for addr_str in io::stdin().lock().lines() {
... | code_fim | medium | {
"lang": "rust",
"repo": "plumenator/coin-mixer-challenge",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: plumenator/coin-mixer-challenge path: /src/main.rs
use std::io::{self, BufRead};
use anyhow::Context;
use structopt::StructOpt;
use coin_mixer_challenge::{address, api::Api, mixer::Mixer, store::Store};
<|fim_suffix|>#[tokio::main]
async fn main() -> anyhow::Result<()> {
let Options { api... | code_fim | medium | {
"lang": "rust",
"repo": "plumenator/coin-mixer-challenge",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/enumset/tests/compile-fail/explicit_repr.rs
use
enumset
:
:
*
;
#
[
derive
(
EnumSetType
)
]
enum
OkayEnumButCantUseFromRepr
{
Variant<|fim_suffix|>m_repr
(
1
)
;
EnumSet
:
:
<
OkayEnumButCantUseFromReprArray
>
:
:
from_repr
(
[
1
]
)
;
}<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/enumset/tests/compile-fail/explicit_repr.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>m_repr
(
1
)
;
EnumSet
:
:
<
OkayEnumButCantUseFromReprArray
>
:
:
from_repr
(
[
1
]
)
;
}<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/enumset/tests/compile-fail/explicit_repr.rs
use
enumset
:
:
*
;
#
[
derive
(
EnumSetType
)
]
enum
OkayEnumButCantUseFromRepr
{
Variant
}
#
[... | code_fim | medium | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/enumset/tests/compile-fail/explicit_repr.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> Drop for TypedArena<T> {
#[unsafe_destructor_blind_to_params]
fn drop(&mut self) {
unsafe {
// Determine how much was filled.
let mut chunks_borrow = self.chunks.borrow_mut();
let mut last_chunk = chunks_borrow.pop().unwrap();
// Drop... | code_fim | hard | {
"lang": "rust",
"repo": "oconnor663/rust",
"path": "/src/libarena/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oconnor663/rust path: /src/libarena/lib.rs
r), op());
// Now that we are done, update the tydesc to indicate that
// the object is there.
*ty_ptr = bitpack_tydesc_ptr(tydesc, true);
&mut *ptr
}
}
/// Allocates a new item in the ar... | code_fim | hard | {
"lang": "rust",
"repo": "oconnor663/rust",
"path": "/src/libarena/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn alloc_copy<T, F>(&self, op: F) -> &mut T
where F: FnOnce() -> T
{
unsafe {
let ptr = self.alloc_copy_inner(mem::size_of::<T>(), mem::align_of::<T>());
let ptr = ptr as *mut T;
ptr::write(&mut (*ptr), op());
&mut *ptr
... | code_fim | hard | {
"lang": "rust",
"repo": "oconnor663/rust",
"path": "/src/libarena/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pspaul/aoc-2020 path: /src/day15.rs
use aoc_runner_derive::{aoc, aoc_generator};
use std::collections::HashMap;
#[aoc_generator(day15)]
fn parse_input_day15(input: &str) -> Vec<usize> {
input.split(',').map(|num| num.parse().unwrap()).collect()
}
fn find_nth_number(numbers: &Vec<usize>, n:... | code_fim | hard | {
"lang": "rust",
"repo": "pspaul/aoc-2020",
"path": "/src/day15.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = "0,3,6";
assert_eq!(part2(&parse_input_day15(input)), 175594);
}
#[test]
fn part2_example_2() {
let input = "1,3,2";
assert_eq!(part2(&parse_input_day15(input)), 2578);
}
#[test]
fn part2_example_3() {
let input = "2,1,3";
... | code_fim | hard | {
"lang": "rust",
"repo": "pspaul/aoc-2020",
"path": "/src/day15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn part2_example_4() {
let input = "1,2,3";
assert_eq!(part2(&parse_input_day15(input)), 261214);
}
#[test]
fn part2_example_5() {
let input = "2,3,1";
assert_eq!(part2(&parse_input_day15(input)), 6895259);
}
#[test]
fn part2_exampl... | code_fim | hard | {
"lang": "rust",
"repo": "pspaul/aoc-2020",
"path": "/src/day15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spacecowboy/scarecrow path: /src/sgd.rs
//! Implementation of stochastic gradient descent.
use loss::*;
use utils::*;
use layers::{LayerUpdates, LayerOut};
use traits::{WeightedLayer, DifferentiableLossFunction, SupervisedTrainer};
use std::collections::LinkedList;
/// Stochastic gradient desc... | code_fim | hard | {
"lang": "rust",
"repo": "spacecowboy/scarecrow",
"path": "/src/sgd.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // backward pass
for ((l, lo), lu) in layers.iter_mut()
.rev()
.zip(outputs.iter().rev())
.zip(updates.iter_mut().rev()) {
let ws = self.weight_step(&l, &lo.inputs, &delta_signal);
... | code_fim | hard | {
"lang": "rust",
"repo": "spacecowboy/scarecrow",
"path": "/src/sgd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut step = vec!(0.0; layer.neuron_count());
// Iterate per neuron bias and contributions from later layers
for (b, ud) in step.iter_mut().zip(delta) {
*b -= self.rate * ud;
}
step
}
}
impl SupervisedTrainer for SGDTrainer {
fn train(&self, l... | code_fim | hard | {
"lang": "rust",
"repo": "spacecowboy/scarecrow",
"path": "/src/sgd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dkushner/quantic path: /quantic_core/src/lib.rs
#![warn(missing_docs, rust_2018_idioms, rust_2018_compatibility)]
extern crate chrono;
extern crate futures;
#[macro_use]
extern crate quantic_derive;
mod time;
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_middle|>#[cfg(test)]
mod te... | code_fim | easy | {
"lang": "rust",
"repo": "dkushner/quantic",
"path": "/quantic_core/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod time;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: dkushner/quantic path: /quantic_core/src/lib.rs
#![warn(missing_docs, rust_2018_idioms, rust_2018_compatibility)]
<|fim_middle|>extern crate chrono;
extern crate futures;
#[mac... | code_fim | medium | {
"lang": "rust",
"repo": "dkushner/quantic",
"path": "/quantic_core/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> resize_term(0, 0);
curs_set(0);
noecho();
win.main.nodelay(true);
win.main.clear();
win.main.border('|', '|', '-', '-', '+', '+', '+', '+');
win.sidebar.attron(Attribute::Bold);
win.sidebar.border('|', '|', '-', '-', '+', '+', '+', '+');
win.sidebar.attroff(Attribute::B... | code_fim | hard | {
"lang": "rust",
"repo": "Start9Labs/cups-cli",
"path": "/src/tui.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn render_sidebar(win: &Windows, data: &[UserData], clear: usize, selected: usize) {
if data.len() < clear {
for i in data.len()..clear {
win.sidebar.mv(i as i32 + 4, 2);
win.sidebar.clrtoeol();
}
}
for (i, user) in data.iter().enumerate() {
win.... | code_fim | hard | {
"lang": "rust",
"repo": "Start9Labs/cups-cli",
"path": "/src/tui.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Start9Labs/cups-cli path: /src/tui.rs
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use failure::Error;
use futures::poll;
use pancurses::*;
use cupslib::{Creds, Message, Pubkey, UserData};
pub struct Windows {
main: Window,
sidebar: Window,
topbar: Window,
f... | code_fim | hard | {
"lang": "rust",
"repo": "Start9Labs/cups-cli",
"path": "/src/tui.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/libsignal-protocol-rs path: /libsignal-protocol/src/crypto/native.rs
use crate::{
crypto::{Crypto, Sha256Hmac, Sha512Digest, SignalCipherType},
errors::InternalError,
};
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct DefaultCrypto;
#[cfg(feature = "crypto-native")]
impl C... | code_fim | medium | {
"lang": "rust",
"repo": "fossabot/libsignal-protocol-rs",
"path": "/libsignal-protocol/src/crypto/native.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
_cipher: SignalCipherType,
_key: &[u8],
_iv: &[u8],
_data: &[u8],
) -> Result<Vec<u8>, InternalError> {
unimplemented!()
}
}
#[cfg(feature = "crypto-native")]
impl Default for DefaultCrypto {
fn default() -> Self { Self }
}<|fim_prefix|>/... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/libsignal-protocol-rs",
"path": "/libsignal-protocol/src/crypto/native.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: umm-csci-3403-fall-2019/lab-9-disemvowel-in-rust-colt5 path: /src/main.rs
fn main() {
println!("Hello, world!");
let s = String::from("Hello, world");
let s_disemvowel = disemvowel(&s);
println!("s was '{}', and without vowels is '{}'.", s, s_disemvowel);
}
fn disemvowel(x:&str... | code_fim | hard | {
"lang": "rust",
"repo": "umm-csci-3403-fall-2019/lab-9-disemvowel-in-rust-colt5",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn empty() {
assert_eq!("", disemvowel(""));
}
#[test]
fn no_vowels() {
assert_eq!("pqrst", disemvowel("pqrst"));
}
#[test]
fn all_vowels() {
assert_eq!("", disemvowel("aeiouAEIOUOIEAuoiea"));
}
#[test]
fn morris_minnesota() {
... | code_fim | hard | {
"lang": "rust",
"repo": "umm-csci-3403-fall-2019/lab-9-disemvowel-in-rust-colt5",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn no_vowels() {
assert_eq!("pqrst", disemvowel("pqrst"));
}
#[test]
fn all_vowels() {
assert_eq!("", disemvowel("aeiouAEIOUOIEAuoiea"));
}
#[test]
fn morris_minnesota() {
assert_eq!("Mrrs, Mnnst", disemvowel("Morris, Minnesota"));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "umm-csci-3403-fall-2019/lab-9-disemvowel-in-rust-colt5",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hummhive/provenance path: /crates/jwt/src/error.rs
#[derive(thiserror::Error, Debug)]
pub enum JwtError {
#[error(transparent)]
Idp(#[from] humm_provenance_idp::error::IdpError),
<|fim_suffix|> #[error(transparent)]
Creation(#[from] jwt_compact::CreationError),
#[error(trans... | code_fim | hard | {
"lang": "rust",
"repo": "hummhive/provenance",
"path": "/crates/jwt/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[error(transparent)]
JwtParse(#[from] jwt_compact::ParseError),
#[error(transparent)]
Creation(#[from] jwt_compact::CreationError),
#[error(transparent)]
Validation(#[from] jwt_compact::ValidationError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}<|fim_prefix... | code_fim | medium | {
"lang": "rust",
"repo": "hummhive/provenance",
"path": "/crates/jwt/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TimeToogo/tunshell path: /tunshell-tests/tests/valid_direct_connection.rs
use reqwest;
use std::collections::HashMap;
use std::time::Duration;
use tokio::runtime::Runtime;
use tokio::time::delay_for;
use tunshell_client as client;
use tunshell_server as server;
#[test]
fn test() {
Runtime::... | code_fim | hard | {
"lang": "rust",
"repo": "TimeToogo/tunshell",
"path": "/tunshell-tests/tests/valid_direct_connection.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut local_config = client::Config::new(
client::ClientMode::Local,
client_key,
"localhost.tunshell.com",
config.tls_port,
config.api_port,
"mock_encryption_key",
true,
false,
);
loca... | code_fim | hard | {
"lang": "rust",
"repo": "TimeToogo/tunshell",
"path": "/tunshell-tests/tests/valid_direct_connection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boybird/adblock-rust path: /benches/bench_url.rs
extern crate criterion;
use criterion::*;
use serde::{Deserialize, Serialize};
use serde_json;
use adblock;
use adblock::url_parser::UrlParser;
#[allow(non_snake_case)]
#[derive(Serialize, Deserialize)]
struct TestRequest {
frameUrl: Strin... | code_fim | hard | {
"lang": "rust",
"repo": "boybird/adblock-rust",
"path": "/benches/bench_url.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn request_extract_hostname(c: &mut Criterion) {
let requests = load_requests();
let requests_len = requests.len();
c.bench(
"throughput-request",
Benchmark::new("hostname+domain extract", move |b| {
b.iter(|| {
let mut successful = 0;
... | code_fim | hard | {
"lang": "rust",
"repo": "boybird/adblock-rust",
"path": "/benches/bench_url.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ben657/aoc-2020 path: /aoc-11/src/main.rs
use std::env;
use std::fs;
mod vec2i;
use vec2i::Vec2;
#[derive(Debug, Clone)]
struct Tile {
seat: bool,
occupied: bool
}
fn is_occupied_in_direction(pos: Vec2, dir: Vec2, state: &Vec<Vec<Tile>>) -> bool {
let height = state.len() as isize... | code_fim | hard | {
"lang": "rust",
"repo": "ben657/aoc-2020",
"path": "/aoc-11/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x2 in x - 1 ..= x + 1 {
if x2 < 0 || x2 > width - 1 || (x2 == x && y2 == y) { continue }
let check_pos = Vec2 {
x: x2,
y: y2
};
if is_oc... | code_fim | hard | {
"lang": "rust",
"repo": "ben657/aoc-2020",
"path": "/aoc-11/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // S = C P C^T + R
let s : N = (&rvec_c.0).mul(&self.mat_p.0).dot(&rvec_c.0) + r.0;
// K = P C^T S^-1 // k is column vector
let vec_k : DVector<N> = (&self.mat_p.0 * &rvec_c.0.transpose()) * s.recip();
// residual = y - C x
let residual = y.0 - (&rvec_c.0 ... | code_fim | hard | {
"lang": "rust",
"repo": "Phaiax/kalmanfilter",
"path": "/kalmanfilter/src/kf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phaiax/kalmanfilter path: /kalmanfilter/src/kf.rs
use std::convert::From;
use alga::general::Real;
use na::{DMatrix, DVector};
use std::ops::Mul;
use nt::{DiscreteSystemMatrix, DiscreteInputMatrix, SystemNoiseVarianceMatrix, StateVector,
CovarianceMatrix, InputVector, Measurement, Me... | code_fim | hard | {
"lang": "rust",
"repo": "Phaiax/kalmanfilter",
"path": "/kalmanfilter/src/kf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // K = P C^T S^-1 // k is column vector
let vec_k : DVector<N> = (&self.mat_p.0 * &rvec_c.0.transpose()) * s.recip();
// residual = y - C x
let residual = y.0 - (&rvec_c.0 * &self.vec_state.0)[(0, 0)];
// x = x + K residual
self.vec_state.0 += &vec_k * res... | code_fim | hard | {
"lang": "rust",
"repo": "Phaiax/kalmanfilter",
"path": "/kalmanfilter/src/kf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kodek16/colang path: /colang/src/backends/mod.rs
//! CO compiler backend interface definition.
//!
//! Backend is a part of the compiler that receives the compiled and type-checked program IR and
//! does something useful with it, for example, translating it into a target language, or executing
... | code_fim | medium | {
"lang": "rust",
"repo": "kodek16/colang",
"path": "/colang/src/backends/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Common interface for CO compiler backends.
pub trait Backend {
/// Process the compiled CO program.
///
/// Backends should report any user-caused errors to the user, and panic only if an internal
/// error occurs. The returned `Result` indicates whether any user-caused errors occurred... | code_fim | medium | {
"lang": "rust",
"repo": "kodek16/colang",
"path": "/colang/src/backends/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: djeedai/druid path: /druid/src/menu.rs
nds::HIDE_APPLICATION,
//! )
//! .hotkey(SysMods::Cmd, "h"),
//! )
//! .append(
//! MenuItem::new(
//! LocalizedString::new("macos-menu-hide-others"),
//! commands::HIDE_OTH... | code_fim | hard | {
"lang": "rust",
"repo": "djeedai/druid",
"path": "/druid/src/menu.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: djeedai/druid path: /druid/src/menu.rs
.append(MenuDesc::new(LocalizedString::new("macos-menu-services")))
//! .append(
//! MenuItem::new(
//! LocalizedString::new("macos-menu-hide-app"),
//! commands::HIDE_APPLICATION,
//! )
... | code_fim | hard | {
"lang": "rust",
"repo": "djeedai/druid",
"path": "/druid/src/menu.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The 'Undo' menu item.
pub fn undo<T: Data>() -> MenuItem<T> {
MenuItem::new(LocalizedString::new("common-menu-undo"), commands::UNDO)
.hotkey(SysMods::Cmd, "z")
}
/// The 'Redo' menu item.
pub fn redo<T: Data>() -> MenuItem<T> {
... | code_fim | hard | {
"lang": "rust",
"repo": "djeedai/druid",
"path": "/druid/src/menu.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.name.split('.').next().unwrap()
}
pub fn extension(&self) -> &str {
if !self.name.contains('.') {
return "";
}
match self.name.split('.').last() {
Some(v) => v,
None => "",
}
}
pub fn name(&self) -> &str {
... | code_fim | hard | {
"lang": "rust",
"repo": "purposed/binman",
"path": "/src/binlib/github/asset.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purposed/binman path: /src/binlib/github/asset.rs
use std::fmt::Debug;
use regex::Regex;
use rood::sys::{Architecture, Platform};
use serde::Deserialize;
fn parse_architecture(name: &str) -> Architecture {
let archs = vec![Architecture::Amd64, Architecture::Arm, Architecture::Arm64];
... | code_fim | medium | {
"lang": "rust",
"repo": "purposed/binman",
"path": "/src/binlib/github/asset.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let plats = vec![Platform::Linux, Platform::Darwin, Platform::Windows];
for plat in plats.iter() {
for plat_value in plat.value().iter() {
let ptn = Regex::new(&format!(r"-{}[-\.]", plat_value)).unwrap();
if ptn.is_match(name) {
return plat.clone();... | code_fim | hard | {
"lang": "rust",
"repo": "purposed/binman",
"path": "/src/binlib/github/asset.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chenziyi2018/py_sql path: /src/node/foreach_node.rs
use crate::ast::RbatisAST;
use crate::node::node::do_child_nodes;
use crate::node::node_type::NodeType;
use rexpr::ast::Node;
use rexpr::runtime::RExprRuntime;
use serde_json::{json, Value};
#[derive(Clone, Debug)]
pub struct ForEachNode {
... | code_fim | hard | {
"lang": "rust",
"repo": "chenziyi2018/py_sql",
"path": "/src/node/foreach_node.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.deinit_ref_mut() {
Ok(()) => (),
Err(err) => {
log::error!("gencmd deinitialization failed inside drop: {}", err);
panic!("gencmd deinitialization failed inside drop: {}", err);
}
}
}
}
// these tests will only pass if there are no other tests that use the global singleto... | code_fim | hard | {
"lang": "rust",
"repo": "TheEdward162/vcgencmd-rs",
"path": "/src/global/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// these tests will only pass if there are no other tests that use the global singleton (such as with --test-threads 1)
#[cfg(test)]
mod test {
use super::{GencmdInitError, GlobalInstance};
#[test]
#[ignore]
fn global_instance_is_unique() {
let instance = GlobalInstance::new().unwrap();
match Gl... | code_fim | hard | {
"lang": "rust",
"repo": "TheEdward162/vcgencmd-rs",
"path": "/src/global/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheEdward162/vcgencmd-rs path: /src/global/mod.rs
use std::{
ffi::CStr,
sync::atomic::{AtomicBool, Ordering as AtomicOrdering},
};
use crate::{error::*, ffi};
#[cfg(feature = "global_singleton")]
pub mod singleton;
static ONE_INSTANCE: AtomicBool = AtomicBool::new(false);
pub struct Global... | code_fim | hard | {
"lang": "rust",
"repo": "TheEdward162/vcgencmd-rs",
"path": "/src/global/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (vtx, idx) = buffers;
let mut normals: Vec<[f32; 3]> = vec![];
let mut vertices: Vec<[f32; 3]> = vec![];
for idx in idx {
let a = vtx[idx[0] as usize];
let b = vtx[idx[1] as usize];
let c = vtx[idx[2] as usize];
vertices.push(a.cast::<f32>().into());
... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/rapier",
"path": "/src_testbed/objects/node.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimforge/rapier path: /src_testbed/objects/node.rs
fg(feature = "dim2")]
use {
bevy::sprite::MaterialMesh2dBundle,
na::{Point2, Vector2},
rapier::geometry::{Ball, Cuboid},
};
#[derive(Clone, Debug)]
pub struct EntityWithGraphics {
pub entity: Entity,
pub color: Point3<f32>,
... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/rapier",
"path": "/src_testbed/objects/node.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimforge/rapier path: /src_testbed/objects/node.rs
e::*;
use bevy::render::mesh::{Indices, VertexAttributeValues};
//use crate::objects::plane::Plane;
use na::{point, Point3, Vector3};
use std::collections::HashMap;
use bevy::pbr::wireframe::Wireframe;
use bevy::render::render_resource::Primit... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/rapier",
"path": "/src_testbed/objects/node.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EmbarkStudios/sentry-rust path: /sentry/examples/tracing-demo.rs
use std::thread;
use std::time::Duration;
use tracing_ as tracing;
use tracing_subscriber::prelude::*;
// cargo run --example tracing-demo
fn main() {
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::laye... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/sentry-rust",
"path": "/sentry/examples/tracing-demo.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> thread::spawn(move || {
thread::sleep(Duration::from_millis(50));
thread_span1();
tracing::error!("Holy shit everything is on fire!");
});
thread::sleep(Duration::from_millis(100));
main_span2()
}
#[tracing::instrument]
fn thread_span1() {
thread::sleep(Dura... | code_fim | medium | {
"lang": "rust",
"repo": "EmbarkStudios/sentry-rust",
"path": "/sentry/examples/tracing-demo.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tracing::debug!("System is booting");
tracing::info!("System is booting");
main_span1();
thread::sleep(Duration::from_millis(100));
}
#[tracing::instrument]
fn main_span1() {
thread::sleep(Duration::from_millis(50));
tracing::warn!("System is warning");
thread::spawn(move |... | code_fim | medium | {
"lang": "rust",
"repo": "EmbarkStudios/sentry-rust",
"path": "/sentry/examples/tracing-demo.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ebottabi/datafuse path: /fusequery/query/src/interpreters/interpreter_setting.rs
// Copyright 2020-2021 The Datafuse Authors.
//
// SPDX-License-Identifier: Apache-2.0.
use std::sync::Arc;
use common_datavalues::DataField;
use common_datavalues::DataSchemaRefExt;
use common_datavalues::DataTyp... | code_fim | medium | {
"lang": "rust",
"repo": "ebottabi/datafuse",
"path": "/fusequery/query/src/interpreters/interpreter_setting.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> "SettingInterpreter"
}
async fn execute(&self) -> Result<SendableDataBlockStream> {
let plan = self.set.clone();
for var in plan.vars {
match var.variable.to_lowercase().as_str() {
// To be compatible with some drivers
"sql_mode"... | code_fim | medium | {
"lang": "rust",
"repo": "ebottabi/datafuse",
"path": "/fusequery/query/src/interpreters/interpreter_setting.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
enable_metrics: true,
job_name: get_default_job_name(),
push_interval_seconds: 10,
}
}
}
#[derive(Deserialize, Serialize, Readable, Writable, Debug, Clone)]
#[serde(crate = "self::serde")]
pub struct CheckpointingConfig {
#[serde(default ... | code_fim | hard | {
"lang": "rust",
"repo": "PersiaML/PERSIA",
"path": "/rust/persia-embedding-config/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PersiaML/PERSIA path: /rust/persia-embedding-config/src/lib.rs
gFileError(String),
}
#[derive(Serialize, Deserialize, Readable, Writable, Debug, Default, Clone)]
#[serde(crate = "self::serde")]
pub struct BoundedUniformInitialization {
pub lower: f32,
pub upper: f32,
}
impl BoundedUnif... | code_fim | hard | {
"lang": "rust",
"repo": "PersiaML/PERSIA",
"path": "/rust/persia-embedding-config/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn parse_embedding_config(config: EmbeddingConfig) -> EmbeddingConfig {
let mut config = config;
let slots_config = &mut config.slots_config;
let feature_groups = &mut config.feature_groups;
let mut slot_name_to_feature_group = HashMap::new();
feature_groups
.iter()
... | code_fim | hard | {
"lang": "rust",
"repo": "PersiaML/PERSIA",
"path": "/rust/persia-embedding-config/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A linear program is either infeasible, unbounded or has a finite optimum.
///
/// This is determined as the result of an algorithm
#[allow(missing_docs)]
#[derive(Eq, PartialEq, Debug)]
pub enum OptimizationResult<F> {
Infeasible,
FiniteOptimum(SparseVector<F, F>),
Unbounded,
}<|fim_prefix... | code_fim | hard | {
"lang": "rust",
"repo": "gaertn/rust-lp",
"path": "/src/algorithm/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gaertn/rust-lp path: /src/algorithm/mod.rs
//! # Algorithms
use crate::algorithm::two_phase::matrix_provider::column::Column;
use crate::algorithm::two_phase::matrix_provider::MatrixProvider;
use crate::algorithm::two_phase::tableau::inverse_maintenance::InverseMaintener;
use crate::algorithm::t... | code_fim | hard | {
"lang": "rust",
"repo": "gaertn/rust-lp",
"path": "/src/algorithm/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A problem formulation of which a relaxation can be solved.
///
/// Implementations of this trait are specialized according to specific properties. E.g. if a
/// specific matrix problem has a trivial basic feasible solution, this can be made clear by
/// implementing a trait that provides this basic... | code_fim | medium | {
"lang": "rust",
"repo": "gaertn/rust-lp",
"path": "/src/algorithm/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Cvec {
pub fn distance(&self, other: &Cvec) -> f64 {
assert!(Rc::ptr_eq(&self.0, &other.0));
unsafe {
sys::puzzle_vector_normalized_distance(&mut self.0.borrow_mut().0, &self.1, &other.1, 1)
}
}
}
impl Drop for Cvec {
fn drop(&mut self) {
unsaf... | code_fim | hard | {
"lang": "rust",
"repo": "george-hopkins/puzzle",
"path": "/src/lib.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: george-hopkins/puzzle path: /src/lib.rs
#![feature(maybe_uninit)]
#[cfg(feature = "jpeg-decoder")]
extern crate jpeg_decoder as jpeg;
use std::cell::RefCell;
use std::mem::MaybeUninit;
use std::rc::Rc;
pub mod sys;
type ContextRef = Rc<RefCell<DropableContext>>;
struct DropableContext(sys::... | code_fim | hard | {
"lang": "rust",
"repo": "george-hopkins/puzzle",
"path": "/src/lib.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kristianhasselknippe/layout-bug-hunter path: /fuse-testing-oracle-server/src/layout_validator/mod.rs
use itertools::Itertools;
use std::iter::Map;
use sdl2::rect::Rect;
use std::collections::HashMap;
use std::collections::HashSet;
use std::hash::{Hash,Hasher};
use std::rc::Rc;
use std::cell::Ref... | code_fim | hard | {
"lang": "rust",
"repo": "kristianhasselknippe/layout-bug-hunter",
"path": "/fuse-testing-oracle-server/src/layout_validator/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for n in self.children_of(n) {
self.print_node(&n);
}
println!("{}Node: {} -- (W:{},H:{}) - (DW:{},DH:{})",
tabs, node.id,
node.node_data.actual_width, node.node_data.actual_height,
node.node_data.render_width, node.no... | code_fim | hard | {
"lang": "rust",
"repo": "kristianhasselknippe/layout-bug-hunter",
"path": "/fuse-testing-oracle-server/src/layout_validator/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn node_set_has_ancestor_of(&self, a: &HashSet<i32>, b: &HashSet<i32>) -> bool {
for n_a in a {
for n_b in b {
let n_a = *n_a;
let n_b = *n_b;
if self.is_ancestor_of(&n_a, &n_b) {
return true
}
... | code_fim | hard | {
"lang": "rust",
"repo": "kristianhasselknippe/layout-bug-hunter",
"path": "/fuse-testing-oracle-server/src/layout_validator/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MysteryBlokHed/twentyone path: /examples/solo_cli.rs
use std::io;
use twentyone::game::get_hand_value;
use twentyone::prelude::*;
/// Turn a card into a 2-character string
fn card_to_printable(card: &[char; 2]) -> String {
format!(
"{}{}",
// Suit
match card[0] {
... | code_fim | hard | {
"lang": "rust",
"repo": "MysteryBlokHed/twentyone",
"path": "/examples/solo_cli.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> && player_value <= 21
|| (player_value <= 21 && dealer_value > 21)
{
println!("Result Hand {}: Win!", i + 1);
} else if player_value < dealer_value || player_value > 21 {
println!("Result Hand {}: Loss.", i + 1);
... | code_fim | hard | {
"lang": "rust",
"repo": "MysteryBlokHed/twentyone",
"path": "/examples/solo_cli.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nopaniers/ming path: /src/serial.rs
//==============================================================================
// Serial Device
//==============================================================================
// #![no_std]
// #![feature(globs)]
// #![feature(lang_items)]
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "nopaniers/ming",
"path": "/src/serial.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
struct SerialPort
{
put_char: u32,
bytes_ready: u32,
cmd: u32,
data_ptr: &'static u32,
data_len: u32
}
static SERIAL_PORT: *mut SerialPort = 0xff002000 as *mut SerialPort;
/*------------------------------------------------------------------------------
* Writing to t... | code_fim | hard | {
"lang": "rust",
"repo": "nopaniers/ming",
"path": "/src/serial.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ClementTsang/bottom path: /src/data_conversion.rs
e out the given value with the returned denominator in order to be able to use it
/// with the returned binary unit (e.g. divide 3000 bytes by 1024 to have a value in KiB).
fn get_mem_binary_unit_and_denominator(bytes: u64) -> (&'static str, f64)... | code_fim | hard | {
"lang": "rust",
"repo": "ClementTsang/bottom",
"path": "/src/data_conversion.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (rx_data, tx_data, total_rx_data, total_tx_data) = match unit_type {
DataUnit::Byte => (
data.network_harvest.rx / 8,
data.network_harvest.tx / 8,
data.network_harvest.total_rx / 8,
data.network_harvest.total_tx / 8,
),
DataUn... | code_fim | hard | {
"lang": "rust",
"repo": "ClementTsang/bottom",
"path": "/src/data_conversion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ClementTsang/bottom path: /src/data_conversion.rs
... */
#[cfg(not(target_os = "windows"))]
pub cache_data: Vec<Point>,
pub swap_data: Vec<Point>,
#[cfg(feature = "zfs")]
pub arc_labels: Option<(String, String)>,
#[cfg(feature = "zfs")]
pub arc_data: Vec<Point>,
... | code_fim | hard | {
"lang": "rust",
"repo": "ClementTsang/bottom",
"path": "/src/data_conversion.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run(args: &ArgMatches) -> Result<(), Box<dyn Error>> {
let repo_path = utils::find_repo()?;
let branch = args.value_of("BRANCH").unwrap().to_string();
let mut branches = refs::branches(&repo_path);
// Create branch
if args.is_present("create") || args.is_present("force-create")... | code_fim | hard | {
"lang": "rust",
"repo": "flomonster/my-git",
"path": "/src/cmd/switch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flomonster/my-git path: /src/cmd/switch.rs
use crate::cmd::branch;
use crate::index::Index;
use crate::objects::{Commit, Hash, Object, Tree};
use crate::{refs, utils};
use clap::ArgMatches;
use std::collections::HashMap;
use std::error::Error;
use std::path::PathBuf;
pub fn switch_branch(
r... | code_fim | hard | {
"lang": "rust",
"repo": "flomonster/my-git",
"path": "/src/cmd/switch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.