text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> assert::is_true(
"
def f(x=[x for x in [1]]):
return x
f() == [1]",
);
assert::is_true(
"
y = 7
def f(x=y):
y = 1
return x
f() == 7",
);
assert::is_true(
"
def f(x, xs = []):
xs.append(x)
return xs
pre = str(f(8, [6,7]))
f(1)
post = str(f(2))... | code_fim | hard | {
"lang": "rust",
"repo": "indygreg/starlark-rust",
"path": "/starlark/src/eval/tests/call.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hooops/crypto-crawler-rs path: /crypto-ws-client/src/clients/zbg/zbg_swap.rs
use crate::WSClient;
use std::{collections::HashMap, sync::mpsc::Sender, sync::RwLock};
use super::super::ws_client_internal::{MiscMessage, WSClientInternal};
use super::super::{Candlestick, Level3OrderBook, OrderBook,... | code_fim | hard | {
"lang": "rust",
"repo": "hooops/crypto-crawler-rs",
"path": "/crypto-ws-client/src/clients/zbg/zbg_swap.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl BBO for ZbgSwapWSClient {
fn subscribe_bbo(&self, _pairs: &[String]) {
panic!("ZBG does NOT have BBO channel");
}
}
impl OrderBookTopK for ZbgSwapWSClient {
fn subscribe_orderbook_topk(&self, _pairs: &[String]) {
panic!("Bitget does NOT have orderbook snapshot channel");
... | code_fim | hard | {
"lang": "rust",
"repo": "hooops/crypto-crawler-rs",
"path": "/crypto-ws-client/src/clients/zbg/zbg_swap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> panic!("ZBG does NOT have BBO channel");
}
}
impl OrderBookTopK for ZbgSwapWSClient {
fn subscribe_orderbook_topk(&self, _pairs: &[String]) {
panic!("Bitget does NOT have orderbook snapshot channel");
}
}
fn to_candlestick_raw_channel(pair: &str, interval: usize) -> String {
... | code_fim | hard | {
"lang": "rust",
"repo": "hooops/crypto-crawler-rs",
"path": "/crypto-ws-client/src/clients/zbg/zbg_swap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> NativeTlsServer::new(&identity, &pass)
.map_err(|err| Error::from(ErrorKind::TlsError(err)))
}
fn build_iron<H: iron::middleware::Handler>(config: &Config, handler: H, ssl: NativeTlsServer) -> Result<iron::Listening> {
let table = config.get_table("server")
.map_err(|err| Error::f... | code_fim | hard | {
"lang": "rust",
"repo": "themadprofessor/riostu",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ip = table.get("ip")
.ok_or_else(|| ErrorKind::MissingConfigValueTableError("ip".to_string(), "server".to_string()))
.and_then(|v| v.clone().into_str().map_err(ErrorKind::ConfigError))
.map_err(Error::from)?;
let port = table.get("port")
.ok_or_else(|| ErrorKin... | code_fim | hard | {
"lang": "rust",
"repo": "themadprofessor/riostu",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: themadprofessor/riostu path: /src/main.rs
#![recursion_limit="256"]
#[macro_use] extern crate error_chain;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate slog;
extern crate slog_term;
extern crate slog_async;
extern crate slog_perf;
extern crate slog_config;
extern crate iron... | code_fim | hard | {
"lang": "rust",
"repo": "themadprofessor/riostu",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: palango/gdax-rs path: /src/lib.rs
extern crate reqwest;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
extern crate uuid;
extern crate chrono;
use std::fmt::{self, Display};
use std::str::FromStr;
use chrono::{DateTime, Utc, Duration};
use serde::de::Deser... | code_fim | hard | {
"lang": "rust",
"repo": "palango/gdax-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
// #[test]
// fn it_works() {
// let c = Client::new();
// let res = c.get_products();
// println!("res = {:#?}", res);
// assert!(res.is_ok());
// }
//
//
// #[test]
// fn it_... | code_fim | hard | {
"lang": "rust",
"repo": "palango/gdax-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rep_levels = vec![0; 16];
//!
//! let num_values = typed_column_reader.read_batch(
//! 8, // batch size
//! Some(&mut def_levels), // definition levels
//! Some(&mut rep_levels), // repetition levels
//! &mut values // read values
//! );
//!... | code_fim | hard | {
"lang": "rust",
"repo": "asdetrefle/parquet-rs",
"path": "/src/column/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asdetrefle/parquet-rs path: /src/column/mod.rs
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// t... | code_fim | hard | {
"lang": "rust",
"repo": "asdetrefle/parquet-rs",
"path": "/src/column/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Now {:?} will print!", Deep(Printable(7)));
let name = "Peter";
let age = 27;
let peter = Person { name, age };
println!("{:?}", peter);// print struct in 1 line.
println!("{:#?}", peter);// print struct as its definition, this time in 4 lines.
}<|fim_prefix|>// repo: kdnakt/rust-by... | code_fim | hard | {
"lang": "rust",
"repo": "kdnakt/rust-by-example",
"path": "/1/debug.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kdnakt/rust-by-example path: /1/debug.rs
#[derive(Debug)]
struct Printable(i32);
#[derive(Debug)]
struct Deep(Printable);
<|fim_suffix|> println!("{1:?} {0:?} is the {actor:?} name",
"Slater",
"Christian",
actor="actor's");
println!("Now {:?} will print!", Printable(3));
pr... | code_fim | medium | {
"lang": "rust",
"repo": "kdnakt/rust-by-example",
"path": "/1/debug.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
lazy_static!
{
static ref replacer1:Regex=Regex::new(r"[\[\(].*?[\]\)]|\.mkv|\.mp4|END|end").unwrap();
static ref replacer2:Regex=Regex::new(r"[^\w]|\d").unwrap();
}
let afterReplacer1:Cow<str>=replacer1.replace_all(filename,"");
let res:Cow<str>=replacer2.replace_al... | code_fim | hard | {
"lang": "rust",
"repo": "risonakamo/logmover-remote",
"path": "/tests/fuzzy-test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: risonakamo/logmover-remote path: /tests/fuzzy-test.rs
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
use sublime_fuzzy::{FuzzySearch,Scoring};
use regex::{Regex};
use lazy_static::lazy_static;
use std::borrow::Cow;
fn main()
<|fim_suffix|> println!("{}",simplifyName("actualy ju... | code_fim | hard | {
"lang": "rust",
"repo": "risonakamo/logmover-remote",
"path": "/tests/fuzzy-test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emakryo/cmpro path: /xtask/src/lib.rs
use anyhow::{anyhow, Result};
use itertools::Itertools;
use quote::ToTokens;
use std::{
io::Write,
process::{Command, Stdio},
};
use syn::{
parse_file, parse_quote, Attribute, File, ImplItem, ImplItemMethod, Item, ItemEnum, ItemFn,
ItemImpl, ... | code_fim | hard | {
"lang": "rust",
"repo": "emakryo/cmpro",
"path": "/xtask/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ret = String::new();
ret.push(src.chars().next().unwrap());
fn need_space(pre: char, post: char) -> bool {
fn is_token(c: char) -> bool {
c.is_alphanumeric() || c == '_'
}
(is_token(pre) && is_token(post))
|| ((pre == '<' || pre == '>') &... | code_fim | hard | {
"lang": "rust",
"repo": "emakryo/cmpro",
"path": "/xtask/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let mut stdin = rustfmt
.stdin
.take()
.ok_or_else(|| anyhow!("Failed to pipe stdin to rustfmt"))?;
stdin.write_all(src.as_bytes())?;
}
let output = rustfmt.wait_with_output()?;
let out = std::str::from_utf8(&output.stdout)?.to_owned();... | code_fim | hard | {
"lang": "rust",
"repo": "emakryo/cmpro",
"path": "/xtask/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> inodes.fetch_child_nodes_for_node(&root_node.ino)?;
let default_namespace_node = inodes.inodes[&2].clone();
inodes.fetch_child_nodes_for_node(&default_namespace_node.ino)?;
assert_eq!(inodes.inodes.len(), 4 + KUBEFS_OBJECTS.len());
assert_eq!(
inodes.... | code_fim | hard | {
"lang": "rust",
"repo": "patnaikshekhar/KubeFS",
"path": "/src/inode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: patnaikshekhar/KubeFS path: /src/inode.rs
];
#[derive(Debug)]
pub enum KubeFSInodeError {
MissingInode,
}
impl Error for KubeFSInodeError {}
impl Display for KubeFSInodeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Missing Inode")
}
}
#[der... | code_fim | hard | {
"lang": "rust",
"repo": "patnaikshekhar/KubeFS",
"path": "/src/inode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: patnaikshekhar/KubeFS path: /src/inode.rs
,
};
#[derive(Debug, Clone, Copy)]
pub enum KubeFSLevel {
Root,
Namespace,
Object,
File,
}
const MAX_SUPPORTED_NAMESPACES: u64 = 10000;
const KUBEFS_OBJECTS: [&str; 7] = [
"deployments",
"services",
"pods",
"statefulset... | code_fim | hard | {
"lang": "rust",
"repo": "patnaikshekhar/KubeFS",
"path": "/src/inode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ConstantMedium {
pub fn new(boundary: Box<dyn Hitable>, density: f32, texture: Box<dyn Texture>) -> Self {
ConstantMedium {
boundary,
density,
//phase_function: Box::new(Isotropic(texture)),
phase_function: Box::new(Lambertian { albedo: text... | code_fim | hard | {
"lang": "rust",
"repo": "Alekssasho/GarageRay",
"path": "/simple/src/hitable/constant_medium.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alekssasho/GarageRay path: /simple/src/hitable/constant_medium.rs
use crate::hitable::{HitRecord, Hitable, AABB};
use crate::material::*;
use crate::math::*;
use crate::random::*;
use crate::ray::Ray;
use crate::texture::*;
pub struct ConstantMedium {
boundary: Box<dyn Hitable>,
density... | code_fim | hard | {
"lang": "rust",
"repo": "Alekssasho/GarageRay",
"path": "/simple/src/hitable/constant_medium.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ens-ds23/ensembl-client path: /src/assets/browser/app/src/program/execute.rs
use std::collections::HashMap;
use std::rc::Rc;
use dom::webgl::{
WebGLRenderingContext as glctx,
WebGLProgram as glprog,
};
use program::source::{ Source, ProgramSource };
use program::objects::Object;
use pr... | code_fim | hard | {
"lang": "rust",
"repo": "ens-ds23/ensembl-client",
"path": "/src/assets/browser/app/src/program/execute.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn prog_type(&self) -> &ProgramType { &self.pt }
pub fn get_default_group(&self) -> DataGroupIndex {
self.default_group
}
pub fn new_group(&mut self) -> DataGroupIndex {
self.bman.new_group()
}
pub fn add_vertices(&mut self, group: DataGroupIndex,... | code_fim | hard | {
"lang": "rust",
"repo": "ens-ds23/ensembl-client",
"path": "/src/assets/browser/app/src/program/execute.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for a in &mut self.objects.iter_mut() {
a.clear(ctx);
}
self.default_group = self.bman.new_group();
}
pub fn objects_final(&mut self, ctx: &glctx, e: &mut GLProgData) {
for b in self.bman.batches() {
for a in &mut self.objects.iter_mut() {
... | code_fim | hard | {
"lang": "rust",
"repo": "ens-ds23/ensembl-client",
"path": "/src/assets/browser/app/src/program/execute.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MetadataEndpoint {
pub fn from_config(config: &OAuth2Config) -> Self {
let base = config.issuer.clone();
MetadataEndpoint(Metadata {
authorization_endpoint: base.join("oauth2/authorize").ok(),
token_endpoint: base.join("oauth2/token").ok(),
jwks... | code_fim | medium | {
"lang": "rust",
"repo": "tun-0-9-tap-0-9/matrix-authentication-service",
"path": "/matrix-authentication-service/src/handlers/oauth2/discovery.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
impl<State> Endpoint<State> for MetadataEndpoint
where
State: Clone + Sync + Send + 'static,
{
async fn call(&self, _req: Request<State>) -> tide::Result {
let body = Body::from_json(&self.0)?;
Ok(Response::builder(200)
.body(body)
.content_ty... | code_fim | hard | {
"lang": "rust",
"repo": "tun-0-9-tap-0-9/matrix-authentication-service",
"path": "/matrix-authentication-service/src/handlers/oauth2/discovery.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tun-0-9-tap-0-9/matrix-authentication-service path: /matrix-authentication-service/src/handlers/oauth2/discovery.rs
// Copyright 2021 The Matrix.org Foundation C.I.C.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the ... | code_fim | medium | {
"lang": "rust",
"repo": "tun-0-9-tap-0-9/matrix-authentication-service",
"path": "/matrix-authentication-service/src/handlers/oauth2/discovery.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> {
if self.recv_fut.is_none() {
let recv = self.recv.clone();
self.recv_fut = Some(Box::pin(async move { recv.recv().await.unwrap() }));
}
match self.recv_fut.as_mut().unwrap().as_mut().po... | code_fim | hard | {
"lang": "rust",
"repo": "Keruspe/global-executor",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Keruspe/global-executor path: /src/lib.rs
//! Configure a global executor you can reuse everywhere
#![forbid(unsafe_code)]
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![no_std]
extern crate alloc;
use alloc::boxed::Box;
use async_channel::Receiver;
use core::{
... | code_fim | hard | {
"lang": "rust",
"repo": "Keruspe/global-executor",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Task<T> {
inner: Box<dyn executor_trait::Task>,
recv: ReceiverWrapper<T>,
}
impl<T: 'static> Task<T> {
pub async fn cancel(self) -> Option<T> {
self.inner.cancel().await?;
Some(self.recv.await)
}
}
impl<T> fmt::Debug for Task<T> {
fn fmt(&self, f: &mut fmt:... | code_fim | hard | {
"lang": "rust",
"repo": "Keruspe/global-executor",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: newAM/r3 path: /src/r3_port_riscv_test_driver/src/uart_k210.rs
//! The UART driver compatible with QEMU `sifive_e` machine
//! (RISC-V Board compatible with SiFive E SDK).
use core::fmt;
use k210_hal::prelude::*;
use nb::block;
use riscv::interrupt;
static mut UART: Option<fn(u8)> = None;
#[co... | code_fim | hard | {
"lang": "rust",
"repo": "newAM/r3",
"path": "/src/r3_port_riscv_test_driver/src/uart_k210.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Write for SerialWrapper {
fn write_str(&mut self, s: &str) -> fmt::Result {
for byte in s.as_bytes() {
if *byte == '\n' as u8 {
(self.0)('\r' as u8);
}
(self.0)(*byte);
}
Ok(())
}
}<|fim_prefix|>// repo: newAM/r... | code_fim | hard | {
"lang": "rust",
"repo": "newAM/r3",
"path": "/src/r3_port_riscv_test_driver/src/uart_k210.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
Self: Sized,
{
RecvDestFrom { socket: self, buf }
}
}
impl<S> UdpSocketRedirExt for S where S: UdpSocketRedir {}
/// Future for `recv_dest_from`
pub struct RecvDestFrom<'a, S: 'a> {
socket: &'a S,
buf: &'a mut [u8],
}
impl<'a, S: 'a> Future for RecvDestFrom<'a,... | code_fim | hard | {
"lang": "rust",
"repo": "shadowsocks/shadowsocks-rust",
"path": "/crates/shadowsocks-service/src/local/redir/redir_ext.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<S> UdpSocketRedirExt for S where S: UdpSocketRedir {}
/// Future for `recv_dest_from`
pub struct RecvDestFrom<'a, S: 'a> {
socket: &'a S,
buf: &'a mut [u8],
}
impl<'a, S: 'a> Future for RecvDestFrom<'a, S>
where
S: UdpSocketRedir,
{
type Output = io::Result<(usize, SocketAddr, Socke... | code_fim | hard | {
"lang": "rust",
"repo": "shadowsocks/shadowsocks-rust",
"path": "/crates/shadowsocks-service/src/local/redir/redir_ext.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadowsocks/shadowsocks-rust path: /crates/shadowsocks-service/src/local/redir/redir_ext.rs
//! Extension trait for `TcpListener` and `UdpSocket`
use std::{
future::Future,
io,
net::SocketAddr,
pin::Pin,
task::{Context, Poll},
};
use async_trait::async_trait;
use shadowsock... | code_fim | hard | {
"lang": "rust",
"repo": "shadowsocks/shadowsocks-rust",
"path": "/crates/shadowsocks-service/src/local/redir/redir_ext.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Frizi/advent2019 path: /day1/src/main.rs
type DynResult<T> = Result<T, Box<dyn std::error::Error>>;
fn main() -> DynResult<()> {
let input = std::fs::read("day1-input.txt")?;
let total: DynResult<u32> = input
.split(|t| *t as char == '\n')
.map(|line| -> DynResult<u32> {... | code_fim | medium | {
"lang": "rust",
"repo": "Frizi/advent2019",
"path": "/day1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn fuel_for_module_adjusted(initial_mass: u32) -> u32 {
let mut total = 0;
let mut extra_mass = initial_mass;
loop {
extra_mass = fuel_for_mass(extra_mass);
total += extra_mass;
if extra_mass == 0 {
return total;
}
}
}<|fim_prefix|>// repo: Frizi... | code_fim | medium | {
"lang": "rust",
"repo": "Frizi/advent2019",
"path": "/day1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut total = 0;
let mut extra_mass = initial_mass;
loop {
extra_mass = fuel_for_mass(extra_mass);
total += extra_mass;
if extra_mass == 0 {
return total;
}
}
}<|fim_prefix|>// repo: Frizi/advent2019 path: /day1/src/main.rs
type DynResult<T> =... | code_fim | medium | {
"lang": "rust",
"repo": "Frizi/advent2019",
"path": "/day1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bottlerocket-os/bottlerocket path: /sources/api/netdog/src/addressing/static_address.rs
use ipnet::IpNet;
use serde::Deserialize;
use snafu::ResultExt;
use std::collections::BTreeSet;
use std::convert::TryFrom;
use std::net::IpAddr;
#[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fiel... | code_fim | hard | {
"lang": "rust",
"repo": "bottlerocket-os/bottlerocket",
"path": "/sources/api/netdog/src/addressing/static_address.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod error {
use snafu::Snafu;
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)))]
pub(crate) enum Error {
#[snafu(display("Invalid route destination, must be 'default' or a valid IP address prefix. Received '{}': {}", input, source))]
InvalidRouteDestination {
... | code_fim | hard | {
"lang": "rust",
"repo": "bottlerocket-os/bottlerocket",
"path": "/sources/api/netdog/src/addressing/static_address.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: temoto/iodin path: /cmd/iodin/src/logger.rs
//! Simple logger module.
use log::{LevelFilter, Metadata, Record, SetLoggerError};
struct SimpleLogger;
impl log::Log for SimpleLogger {
fn enabled(&self, _metadata: &Metadata) -> bool {
<|fim_suffix|> fn log(&self, record: &Record) {
... | code_fim | easy | {
"lang": "rust",
"repo": "temoto/iodin",
"path": "/cmd/iodin/src/logger.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub fn init(max_level: LevelFilter) -> Result<(), SetLoggerError> {
log::set_boxed_logger(Box::new(SimpleLogger)).map(|()| log::set_max_level(max_level))
}<|fim_prefix|>// repo: temoto/iodin path: /cmd/iodin/src/logger.rs
//! Simple logger module.
use log::{LevelFilter, Metadata, Record, SetLogger... | code_fim | hard | {
"lang": "rust",
"repo": "temoto/iodin",
"path": "/cmd/iodin/src/logger.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn flush(&self) {}
}
pub fn init(max_level: LevelFilter) -> Result<(), SetLoggerError> {
log::set_boxed_logger(Box::new(SimpleLogger)).map(|()| log::set_max_level(max_level))
}<|fim_prefix|>// repo: temoto/iodin path: /cmd/iodin/src/logger.rs
//! Simple logger module.
use log::{LevelFilter, Meta... | code_fim | medium | {
"lang": "rust",
"repo": "temoto/iodin",
"path": "/cmd/iodin/src/logger.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::iter::FromIterator;
if value.b.is_some() {
match String::from_utf8(value.b.expect("dynamodb sdk error").to_vec()) {
Ok(x) => Value::String(x),
_ => panic!()
}
}
else if value.bool.is_some() {
Value::Bool(value.bool.expect("dynamodb ... | code_fim | hard | {
"lang": "rust",
"repo": "colbyn/dynamodb_data",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: colbyn/dynamodb_data path: /src/lib.rs
#![allow(unused)]
//! DynamoDB Data Utilities
//!
//! API Example:
//! ```
//! use dynamodb_data::*;
//! use std::collections::HashMap;
//!
//! let payload: HashMap<String, rusoto_dynamodb::AttributeValue> = fields!{
//! id => ::uuid::Uuid::new_v4(),
... | code_fim | hard | {
"lang": "rust",
"repo": "colbyn/dynamodb_data",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>///////////////////////////////////////////////////////////////////////////////
// INTERNAL - ATTRIBUTE-VALUE
///////////////////////////////////////////////////////////////////////////////
fn json_to_attribute_value(value: Value) -> AttributeValue {
use std::iter::FromIterator;
match value {
... | code_fim | hard | {
"lang": "rust",
"repo": "colbyn/dynamodb_data",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the u8 representation of the source.
pub fn memory(&self) -> &[u8] {
&self.0
}
}<|fim_prefix|>// repo: Kerollmops/reustmann path: /src/program.rs
use std::{fs, io};
use std::path::Path;
/// A set of instructions that can be given to an interpreter.
pub struct Program(Vec<u8>)... | code_fim | medium | {
"lang": "rust",
"repo": "Kerollmops/reustmann",
"path": "/src/program.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Construct a program from a list of instructions (mnemonic).
pub fn from_iter<I: IntoIterator<Item=u8>>(iter: I) -> Program {
Program(iter.into_iter().collect())
}
/// Get the u8 representation of the source.
pub fn memory(&self) -> &[u8] {
&self.0
}
}<|fim_pref... | code_fim | hard | {
"lang": "rust",
"repo": "Kerollmops/reustmann",
"path": "/src/program.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kerollmops/reustmann path: /src/program.rs
use std::{fs, io};
use std::path::Path;
/// A set of instructions that can be given to an interpreter.
pub struct Program(Vec<u8>);
<|fim_suffix|> /// Get the u8 representation of the source.
pub fn memory(&self) -> &[u8] {
&self.0
... | code_fim | hard | {
"lang": "rust",
"repo": "Kerollmops/reustmann",
"path": "/src/program.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn set_initial_state(
&mut self,
state: std::collections::HashMap<String, serde_json::Value>,
) {
self.previous_twin_state = Some(state);
self.inner = Inner::SendRequest;
}
pub(crate) fn report_twin_state_handle(&self) -> ReportTwinStateHandle {
... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/iotedge",
"path": "/edge-modules/api-proxy-module/rust-sdk/azure-iot-mqtt/src/twin_state/reported.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (_, _) => current.clone(),
}
}
let mut result: std::collections::HashMap<_, _> = Default::default();
for (key, previous_value) in previous {
if let Some(current_value) = current.get(key) {
if previous_value != current_value {
result.ins... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/iotedge",
"path": "/edge-modules/api-proxy-module/rust-sdk/azure-iot-mqtt/src/twin_state/reported.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/iotedge path: /edge-modules/api-proxy-module/rust-sdk/azure-iot-mqtt/src/twin_state/reported.rs
BackOff,
EndBackOff(std::pin::Pin<Box<tokio::time::Sleep>>),
Idle,
SendRequest,
}
impl State {
pub(crate) fn new(max_back_off: std::time::Duration, keep_alive: std::time::Dur... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/iotedge",
"path": "/edge-modules/api-proxy-module/rust-sdk/azure-iot-mqtt/src/twin_state/reported.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ergoplatform/sigma-rust path: /ergoscript-compiler/src/lexer.rs
// Initial version is copied from https://github.com/arzg/eldiro
// Checkout https://arzg.github.io/lang/ for description
mod token_kind;
pub use token_kind::TokenKind;
use logos::Logos;
use std::convert::TryFrom;
use std::ops::Ran... | code_fim | medium | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergoscript-compiler/src/lexer.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let kind = self.inner.next()?;
let text = self.inner.slice();
let range = {
let StdRange { start, end } = self.inner.span();
let start = TextSize::try_from(start).unwrap();
let end = TextSize::try_from(end).unwrap();
TextRange::new(... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergoscript-compiler/src/lexer.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linebender/piet path: /piet-coregraphics/src/ct_helpers.rs
//! Wrappers around CF/CT types, with nice interfaces.
#![allow(clippy::upper_case_acronyms)]
use std::ffi::c_void;
use std::rc::Rc;
use core_foundation::{
array::{CFArray, CFArrayRef, CFIndex},
attributed_string::CFMutableAtt... | code_fim | hard | {
"lang": "rust",
"repo": "linebender/piet",
"path": "/piet-coregraphics/src/ct_helpers.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match family {
FontFamilyInner::SansSerif | FontFamilyInner::SystemUi => {
create_system_font(kCTFontSystemFontType, size)
}
//TODO: on 10.15 + we should be using new york here
//FIXME: font::new_from_name actually never fails
FontFamilyInner::Serif ... | code_fim | hard | {
"lang": "rust",
"repo": "linebender/piet",
"path": "/piet-coregraphics/src/ct_helpers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>//#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
//pub struct CredentialSchema {
// pub id: String,
// pub attributes: Vec<String>,
//}
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct EstablishmentBundle {
pub service_id: u32,
pub address: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "ecafkoob/ockam",
"path": "/implementations/rust/ockam/ockam_examples/example_projects/okta/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ecafkoob/ockam path: /implementations/rust/ockam/ockam_examples/example_projects/okta/src/lib.rs
#[macro_use]
extern crate serde_big_array;
big_array! { BigArray; }
use ockam::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Messages {
OktaL... | code_fim | hard | {
"lang": "rust",
"repo": "ecafkoob/ockam",
"path": "/implementations/rust/ockam/ockam_examples/example_projects/okta/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const ENTRANT_COUNT:usize = 5; // We can make this dynamic but that would complexify a fair bit
impl Pack for Lottery {
const LEN: usize = 1 + 32 + 8 + 32 + 32 * ENTRANT_COUNT;
fn unpack_from_slice(src: &[u8]) -> Result<Self, ProgramError> {
let src = array_ref![src, 0, 233];
... | code_fim | hard | {
"lang": "rust",
"repo": "chanakyap/solanalotto",
"path": "/program/src/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chanakyap/solanalotto path: /program/src/state.rs
use solana_program::{
program_pack::{IsInitialized, Pack, Sealed},
program_error::ProgramError,
pubkey::Pubkey,
};
use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs};
#[derive(Debug)]
pub struct Lottery {
... | code_fim | hard | {
"lang": "rust",
"repo": "chanakyap/solanalotto",
"path": "/program/src/state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purluno/rust-examples path: /src/fib1.rs
pub fn run() {
println!("fib(10) = {}", fib(10));
}
<|fim_suffix|> let mut a = 0;
let mut b = 1;
for _ in 0..n {
let c = a + b;
a = b;
b = c;
}
a
}<|fim_middle|>fn fib(n: i64) -> i64 {
| code_fim | easy | {
"lang": "rust",
"repo": "purluno/rust-examples",
"path": "/src/fib1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut a = 0;
let mut b = 1;
for _ in 0..n {
let c = a + b;
a = b;
b = c;
}
a
}<|fim_prefix|>// repo: purluno/rust-examples path: /src/fib1.rs
pub fn run() {
println!("fib(10) = {}", fib(10));
}
<|fim_middle|>fn fib(n: i64) -> i64 {
| code_fim | easy | {
"lang": "rust",
"repo": "purluno/rust-examples",
"path": "/src/fib1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>et::SocketAddr;
///
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
/// let contents = fs::read("address.txt").await?;
/// let foo: SocketAddr = String::from_utf8_lossy(&contents).parse()?;
/// Ok(())
/// }
/// ```
pub async fn read(path: impl AsRef... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/tokio",
"path": "/tokio/src/fs/read.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tokio-rs/tokio path: /tokio/src/fs/read.rs
use crate::fs::asyncify;
use std::{io, path::Path};
/// Reads the entire contents of a file into a bytes vector.
///
/// This is an async version of [`std::fs::read`][std]
///
/// [std]: std::fs::read
///
/// This is a convenience function for using [... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/tokio",
"path": "/tokio/src/fs/read.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pbertoni89/playground path: /rustground/hello_cargo/src/main.rs
use std::thread;
fn demo_playground() {
let condition = true;
let number = if condition {
5
} else {
6 // "six" -> error!!! static check fails
};
println!("number is {}", number)
}
/**
* https:... | code_fim | hard | {
"lang": "rust",
"repo": "pbertoni89/playground",
"path": "/rustground/hello_cargo/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // iterate over every character `c` in input
let output: String = input
.chars()
.map(
|c| {
if c == '1' {
'0'
} else if c == '0' {
'1'
} else {
c
... | code_fim | hard | {
"lang": "rust",
"repo": "pbertoni89/playground",
"path": "/rustground/hello_cargo/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Document {
pub fn parse(input: &str) -> Result<Self, parser::Error> {
parser::Parser::parse(input)
}
/// Creates an empty document
pub fn new() -> Self {
let list = LinkedList::new(intrusive::TableAdapter::new());
// reserve space for 10 tables
let are... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/toml_edit",
"path": "/src/document.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Document::new()
}
}
pub(crate) const ROOT_HEADER: &'static str = "$root$";
impl Document {
pub fn parse(input: &str) -> Result<Self, parser::Error> {
parser::Parser::parse(input)
}
/// Creates an empty document
pub fn new() -> Self {
let list = LinkedList::ne... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/toml_edit",
"path": "/src/document.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gitter-badger/toml_edit path: /src/document.rs
// WARNING: we're using unsafe code here (raw pointers)
// until a better approach is found
// (not involving replacing every pointer with Rc<RefCell<T>>).
// Note, however, that the public API is safe to use.
// Current design:
// There are four m... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/toml_edit",
"path": "/src/document.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn step(&mut self) -> LengthCounterResult {
if self.enabled {
self.counter -= 1;
}
if self.enabled && self.counter == 0 {
self.enabled = false;
return LengthCounterResult::DisableChannel;
}
LengthCounterResult::None
... | code_fim | medium | {
"lang": "rust",
"repo": "p4ddy1/gbemulator",
"path": "/lib_gbemulation/src/apu/channel/length_counter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: p4ddy1/gbemulator path: /lib_gbemulation/src/apu/channel/length_counter.rs
pub struct LengthCounter {
enabled: bool,
counter: u16,
counter_size: u16,
}
pub enum LengthCounterResult {
None,
DisableChannel,
}
impl LengthCounter {
pub fn new(counter_size: u16) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "p4ddy1/gbemulator",
"path": "/lib_gbemulation/src/apu/channel/length_counter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: howl111/WASI path: /tools/witx/src/main.rs
use glob::glob;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process;
use structopt::{clap::AppSettings, StructOpt};
use witx::{load, Document, Documentation};
/// Validate and process witx files
#[derive(StructOpt, D... | code_fim | hard | {
"lang": "rust",
"repo": "howl111/WASI",
"path": "/tools/witx/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Generated {}", md_path.display());
}
Err(e) => {
eprintln!("{}", e);
if verbose {
println!("{:?}", e);
}
pro... | code_fim | hard | {
"lang": "rust",
"repo": "howl111/WASI",
"path": "/tools/witx/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn main() {
let args = Args::from_args();
pretty_env_logger::init();
let verbose = args.verbose;
match args.cmd {
Command::Docs { input } => {
for file in glob(&input).expect("Failed to read glob pattern") {
match file {
Ok(path)... | code_fim | hard | {
"lang": "rust",
"repo": "howl111/WASI",
"path": "/tools/witx/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tokio::fs::write(&file_name, &body)
.await
.map_err(|e| {
log::error!("error writing file: {}", e);
warp::reject::reject()
})
.map(|_| "Success".to_string())
}
async fn list_dir_handler(path_to_working_dir: Arc<PathBuf>) -> Result<String, warp:... | code_fim | hard | {
"lang": "rust",
"repo": "anicicn84/Rust_REST_API",
"path": "/src/bin/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anicicn84/Rust_REST_API path: /src/bin/server.rs
//! An REST API implementation in Rust for CLI and GET/POST/DELETE file requests.
use futures::{StreamExt, TryFutureExt};
use structopt::StructOpt;
use warp::Filter;
use std::{path::PathBuf, sync::Arc};
#[derive(StructOpt)]
struct Arguments {
... | code_fim | hard | {
"lang": "rust",
"repo": "anicicn84/Rust_REST_API",
"path": "/src/bin/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eddyb/finchers path: /src/endpoint/wrapper/mod.rs
//! Built-in wrappers.
mod after_apply;
mod and_then;
mod before_apply;
mod map;
mod or_reject;
mod recover;
mod then;
mod try_chain;
mod with_spawner;
pub use self::after_apply::{after_apply, AfterApply};
pub use self::and_then::{and_then, And... | code_fim | hard | {
"lang": "rust",
"repo": "eddyb/finchers",
"path": "/src/endpoint/wrapper/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
F: Func<Self::Output> + 'a,
F::Out: Future + 'a,
{
self.wrap(then(f))
}
#[allow(missing_docs)]
fn and_then<F>(self, f: F) -> <AndThen<Self::Output, F> as Wrapper<'a, Self>>::Endpoint
where
F: Func<Self::Output> + 'a,
F::Out: TryFuture<... | code_fim | hard | {
"lang": "rust",
"repo": "eddyb/finchers",
"path": "/src/endpoint/wrapper/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> is `0`", x),
_ => println!("It doesn't matter what they are"),
}
}
}<|fim_prefix|>// repo: RevelationOfTuring/Rust-exercise path: /src/match_tuple.rs
//元组可以在 match 中解构
#[cfg(test)]
mod tests {
#[test]
fn test_match() {
// let p<|fim_middle|>air = (1, 1);
le... | code_fim | medium | {
"lang": "rust",
"repo": "RevelationOfTuring/Rust-exercise",
"path": "/src/match_tuple.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RevelationOfTuring/Rust-exercise path: /src/match_tuple.rs
//元组可以在 match 中解构
#[cfg(test)]
mod tests {
#[test]
fn test_match() {
// let pair = (1, 1);
let pair = (0, 1);
match pair {
(0, x) => println!(<|fim_suffix|> is `0`", x),
_ => println... | code_fim | medium | {
"lang": "rust",
"repo": "RevelationOfTuring/Rust-exercise",
"path": "/src/match_tuple.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mareq/event-store-rs path: /event-store/src/testhelpers.rs
//! Test helpers. Do not use in application code.
use adapters::PgQuery;
use prelude::*;
use r2d2::{self, Pool};
use r2d2_postgres::postgres::types::ToSql;
use r2d2_postgres::{PostgresConnectionManager, TlsMode};
use redis::Client as Re... | code_fim | hard | {
"lang": "rust",
"repo": "mareq/event-store-rs",
"path": "/event-store/src/testhelpers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let manager =
PostgresConnectionManager::new("postgres://postgres@localhost:5430", TlsMode::None)
.unwrap();
let pool = r2d2::Pool::new(manager).unwrap();
let conn = pool.get().unwrap();
conn.batch_execute(&format!("CREATE DATABASE \"{}\"", db_id))
.unwrap();... | code_fim | hard | {
"lang": "rust",
"repo": "mareq/event-store-rs",
"path": "/event-store/src/testhelpers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frewsxcv/rgis path: /rgis-file-loader/src/jobs.rs
pub struct LoadFileJob<F: geo_file_loader::FileLoader> {
pub file_loader: F,
pub name: String,
pub source_crs: String,
}
pub struct LoadFileJobOutcome {
pub feature_collection: geo_projected::Unprojected<geo_features::FeatureColl... | code_fim | medium | {
"lang": "rust",
"repo": "frewsxcv/rgis",
"path": "/rgis-file-loader/src/jobs.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> Box::pin(async move {
Ok(LoadFileJobOutcome {
feature_collection: geo_projected::Unprojected::new(self.file_loader.load()?),
name: self.name,
source_crs: self.source_crs,
})
})
}
}<|fim_prefix|>// repo: frewsxcv/rg... | code_fim | medium | {
"lang": "rust",
"repo": "frewsxcv/rgis",
"path": "/rgis-file-loader/src/jobs.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/privacy/ctor.rs
// Verify that a type is considered reachable when its constructor is
// reachable. The auxiliary library is constructed so that all types are
// shadowed and cannot be named directly, while their constructors are
// reexported. Regression test for ... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/privacy/ctor.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ctor_aux::s.f();
ctor_aux::x.g();
ctor_aux::y.g();
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/privacy/ctor.rs
// Verify that a type is considered reachable when its constructor is
// reachable. The auxiliary library is constructed so that all types are
// shadowed and cannot be na... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/privacy/ctor.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>i::PathAndQuery::from_static(
"/org.interledger.stream.proto.IlpOverHttpService/SendMoney",
);
self.inner.unary(request.into_request(), path, codec).await
}
}
impl<T: Clone> Clone for IlpOverHttpServiceClient<T> {
fn clone(&self) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "elmurci/xpring-rs",
"path": "/lib/protos/generated/org.interledger.stream.proto.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elmurci/xpring-rs path: /lib/protos/generated/org.interledger.stream.proto.rs
/// Defines the fields required to initiate a STREAM payment.
/// Next field: 4
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SendPaymentRequest {
/// The destination PP to pay.
#[prost(string, tag =... | code_fim | hard | {
"lang": "rust",
"repo": "elmurci/xpring-rs",
"path": "/lib/protos/generated/org.interledger.stream.proto.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
user_id: Uuid::default(),
session_id_num_pics_pairs: Vec::<(Uuid, u8)>::with_capacity(10),
}
}
}<|fim_prefix|>// repo: olivereanderson/safari_stats path: /user-stats/src/writing.rs
use itertools::Itertools;
use std::fmt::{Display, Formatter};
use uuid::U... | code_fim | hard | {
"lang": "rust",
"repo": "olivereanderson/safari_stats",
"path": "/user-stats/src/writing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: olivereanderson/safari_stats path: /user-stats/src/writing.rs
use itertools::Itertools;
use std::fmt::{Display, Formatter};
use uuid::Uuid;
#[derive(PartialEq, Debug)]
pub(crate) struct UserBestStats {
pub(crate) user_id: Uuid,
pub(crate) session_id_num_pics_pairs: Vec<(Uuid, u8)>,
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "olivereanderson/safari_stats",
"path": "/user-stats/src/writing.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Linear operation for Vector
pub trait LinearOp<T: Vector, S: Vector> {
fn apply(&self, rhs: &T) -> S;
}
// =============================================================================
// Implementation for primitive types
// =======================================================================... | code_fim | medium | {
"lang": "rust",
"repo": "ninkoze/Peroxide",
"path": "/src/traits/math.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn sub_vec<'a, 'b>(&'a self, rhs: &'b Self) -> Self {
self - rhs
}
fn mul_scalar<T: Into<f64>>(&self, rhs: T) -> Self {
self * rhs.into()
}
}
impl Normed for f64 {
type Scalar = f64;
fn norm(&self, _kind: Norm) -> Self::Scalar {
self.abs()
}
f... | code_fim | medium | {
"lang": "rust",
"repo": "ninkoze/Peroxide",
"path": "/src/traits/math.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ninkoze/Peroxide path: /src/traits/math.rs
use std::convert::Into;
/// Mathematical Vector
///
/// # Description
/// Vector has two operations : addition, scalar multiplication.
/// And a space of the vector should closed for that operations.
pub trait Vector {
fn add_vec<'a, 'b>(&'a self, ... | code_fim | hard | {
"lang": "rust",
"repo": "ninkoze/Peroxide",
"path": "/src/traits/math.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match first_letter {
'a' => first_letter.to_string() + &input + "-hay",
'e' => first_letter.to_string() + &input + "-hay",
'i' => first_letter.to_string() + &input + "-hay",
'o' => first_letter.to_string() + &input + "-hay",
'u' => first_letter.to_string() + &in... | code_fim | medium | {
"lang": "rust",
"repo": "justinzhf/projects-of-prl-book",
"path": "/string_example/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let first_letter: char = input.remove(0);
match first_letter {
'a' => first_letter.to_string() + &input + "-hay",
'e' => first_letter.to_string() + &input + "-hay",
'i' => first_letter.to_string() + &input + "-hay",
'o' => first_letter.to_string() + &input + "-... | code_fim | medium | {
"lang": "rust",
"repo": "justinzhf/projects-of-prl-book",
"path": "/string_example/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: justinzhf/projects-of-prl-book path: /string_example/src/main.rs
use std::io;
fn main() {
let mut input = String::new();
println!("Please input a word.");
io::stdin().read_line(&mut input).
expect("Error");
input = input.trim().to_string();
println!("{}", convert_str... | code_fim | medium | {
"lang": "rust",
"repo": "justinzhf/projects-of-prl-book",
"path": "/string_example/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_pixel(&self, x: u32, y: u32) -> Color {
let (width, height) = self.0.dimensions();
return match self.2 {
TextureMode::Clamp => rgba_to_color(
self.0
.get_pixel(clamp(x, 0, width - 1), clamp(y, 0, height - 1)),
),
TextureMode::Repeat => rgba_to_color(self.0.get_pixel(x % w... | code_fim | hard | {
"lang": "rust",
"repo": "SolarLiner/gargantua",
"path": "/gargantua/src/texture.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cx = x.floor();
let cy = y.floor();
let fx = x - cx;
let fy = y - cy;
let pix11 = self.get_pixel(cx as u32, cy as u32);
let pix12 = self.get_pixel(cx as u32 + 1, cy as u32);
let pix21 = self.get_pixel(cx as u32 + 1, cy as u32);
let pix22 = self.get_pixel(cx as u32 + 1, cy as u32 + 1);... | code_fim | hard | {
"lang": "rust",
"repo": "SolarLiner/gargantua",
"path": "/gargantua/src/texture.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.