text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: nicholastmosher/k8-api path: /src/k8-client/src/native/mod.rs
mod client;
mod config;
mod stream;
mod wstream;
<|fim_suffix|>pub mod prelude {
pub use isahc::prelude::*;
}<|fim_middle|>pub use client::K8Client;
pub mod http {
pub use isahc::http::*;
}
| code_fim | medium | {
"lang": "rust",
"repo": "nicholastmosher/k8-api",
"path": "/src/k8-client/src/native/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: exonum/exonum path: /test-suite/testkit/tests/supervisor/mod.rs
// Copyright 2020 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://ww... | code_fim | hard | {
"lang": "rust",
"repo": "exonum/exonum",
"path": "/test-suite/testkit/tests/supervisor/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn stop_service(
&self,
mut context: ExecutionContext<'_>,
instance_id: InstanceId,
) -> Self::Output {
context
.supervisor_extensions()
.initiate_stopping_service(instance_id)
}
fn freeze_service(
&self,
mut context:... | code_fim | hard | {
"lang": "rust",
"repo": "exonum/exonum",
"path": "/test-suite/testkit/tests/supervisor/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Service for Supervisor {
// We place this code before transactions in order to not run it in the same block when
// the migration is initiated.
fn before_transactions(&self, mut context: ExecutionContext<'_>) -> Result<(), ExecutionError> {
let current_migrations: Vec<_> = Schema:... | code_fim | hard | {
"lang": "rust",
"repo": "exonum/exonum",
"path": "/test-suite/testkit/tests/supervisor/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paarasg/Rust-Projects path: /file_read_shortcut/src/main.rs
use std::io::{self, Read};
use std::fs::File;
fn main() {
match read_from_file() {
Ok(s) => println!("The content of the file is {}", s),
Err(err) => panic!("Couldn't read the file {:?}", err),
};
}
fn read_fro... | code_fim | medium | {
"lang": "rust",
"repo": "paarasg/Rust-Projects",
"path": "/file_read_shortcut/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read_from_file()->Result<String, io::Error> {
let mut f = File::open("hello.txt")?;
let mut s = String::new();
f.read_to_string(&mut s)?;
Ok(s)
}
fn short_read_from_file()->Result<String, io::Error> {
let mut s = String::new();
File::open("hello.txt")?.read_to_string(&mut s)?;
... | code_fim | medium | {
"lang": "rust",
"repo": "paarasg/Rust-Projects",
"path": "/file_read_shortcut/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if filtered.len() != allowed.len() {
return vec![];
}
allowed
}
fn is_valid(identifier: String) -> bool {
let char_vec: Vec<char> = identifier.chars().collect();
let allowed_vec: Vec<bool> = char_vec.iter()
.map(|&x| char::is_numeri... | code_fim | hard | {
"lang": "rust",
"repo": "milendd/RustHomeworks",
"path": "/01/solution/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: milendd/RustHomeworks path: /01/solution/src/lib.rs
/// Необходимо е CodeIdentifier да имплементира Debug, за да можем да го
/// използваме в тестови assertion-и.
///
#[derive(Debug)]
pub struct CodeIdentifier {
// Каквито полета ви трябват
data: Vec<String>
}
impl CodeIdentifier {
... | code_fim | hard | {
"lang": "rust",
"repo": "milendd/RustHomeworks",
"path": "/01/solution/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 46bit/comms path: /src/room/broadcast.rs
use std::hash::Hash;
use std::collections::HashSet;
use futures::{Future, Sink, Stream, Poll, Async, AsyncSink};
use super::*;
pub struct Broadcast<I, C>
where I: Clone + Send + PartialEq + Eq + Hash + Debug + 'static,
C: Sink + Stream + 's... | code_fim | hard | {
"lang": "rust",
"repo": "46bit/comms",
"path": "/src/room/broadcast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<I, C> Future for Broadcast<I, C>
where I: Clone + Send + PartialEq + Eq + Hash + Debug + 'static,
C: Sink + Stream + 'static,
C::SinkItem: Clone
{
type Item = Room<I, C>;
type Error = ();
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
let mut room =... | code_fim | hard | {
"lang": "rust",
"repo": "46bit/comms",
"path": "/src/room/broadcast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let poll_complete_list = self.poll_complete_list.drain(..).collect::<Vec<_>>();
for id in poll_complete_list {
let ready_client = match room.client_mut(&id) {
Some(ready_client) => ready_client,
None => continue,
};
match ... | code_fim | hard | {
"lang": "rust",
"repo": "46bit/comms",
"path": "/src/room/broadcast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let set = Self::new();
let mut iter_bank = IterBank::new(|| set.iterator_maker());
for (i, phase) in fun.0.iter().enumerate() {
// prime every _other_ phase
if i % 2 == 1 { set.prime(phase, &mut iter_bank) }
match phase {
... | code_fim | medium | {
"lang": "rust",
"repo": "nyeogmi/moogle",
"path": "/src/test_props/shared_structures/to_one.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let xs = T::prepare(&f);
fwd_correct_len(xs.fwd().iter().collect(), xs.fwd().len())
}
#[quickcheck]
fn test_pair_unique(f: Routine) -> bool {
let xs = T::prepare(&f);
pair_unique(xs.fwd().iter().collect())
}
#[quickcheck]
fn test_fwd_unique(f: Routine) -> bool {
let xs = T::prepare(&... | code_fim | hard | {
"lang": "rust",
"repo": "nyeogmi/moogle",
"path": "/src/test_props/shared_structures/to_one.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nyeogmi/moogle path: /src/test_props/shared_structures/to_one.rs
// NOTE: These test modules are written in a way that's intended to make use of rustc
// Specifically, if you see "unused import", you can probably bet that the property listed here
// is not provided (or at least not tested for)
/... | code_fim | hard | {
"lang": "rust",
"repo": "nyeogmi/moogle",
"path": "/src/test_props/shared_structures/to_one.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shirataki2/booru-rs-v1 path: /booru-lib/src/models/post.rs
use serde_with::{serde_as, DefaultOnNull};
use crate::models::common::*;
use crate::models::serde::SpaceDelimited;
use crate::error::BooruError;
use std::path::Path;
#[serde_as]
#[derive(Debug, Clone, Deserialize)]
pub struct Post {
... | code_fim | hard | {
"lang": "rust",
"repo": "Shirataki2/booru-rs-v1",
"path": "/booru-lib/src/models/post.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn save_ratio(&self, path: &Path, ratio_limit: f64) -> Result<(), BooruError> {
if !path.is_dir() {
return Err(BooruError::PathIsNotDirectory(path.to_str().unwrap().to_string()))
}
let filename = format!("{}.{}", self.id, self.file_ext);
let path = path.... | code_fim | hard | {
"lang": "rust",
"repo": "Shirataki2/booru-rs-v1",
"path": "/booru-lib/src/models/post.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsIUnicharOutputStream.rs
//
// DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIUnicharOutputStream.idl
//
#[repr(C)]
pub struct nsIUnicharOutputStream {
vtable: *const nsIUnicharOutputStreamVTable,
/// This field is a phantomdata to e... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIUnicharOutputStream.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl nsIUnicharOutputStream {
#[inline]
pub fn coerce<T: nsIUnicharOutputStreamCoerce>(&self) -> &T {
T::coerce_from(self)
}
}
impl ::std::ops::Deref for nsIUnicharOutputStream {
type Target = nsISupports;
#[inline]
fn deref(&self) -> &nsISupports {
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIUnicharOutputStream.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: penguin-wwy/Jatcher path: /src/config.rs
use serde::{Deserialize, Serialize};
use std::os::raw::c_char;
use std::ffi::CStr;
use std::fs::File;
use std::io::Read;
use std::mem::transmute;
use logger::error;
use std::sync::Once;
use simple_logging::log_to_file;
use std::path::{Path, PathBuf};
use ... | code_fim | hard | {
"lang": "rust",
"repo": "penguin-wwy/Jatcher",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct ConfigParser {
init: Once,
config: Option<Box<Configuration>>,
path: Option<String>
}
static mut CONFIG_BOX: ConfigParser = ConfigParser {
init: Once::new(),
config: None,
path: None
};
#[no_mangle]
#[allow(unused_must_use)]
pub unsafe extern "C" fn parse_config(path: *con... | code_fim | hard | {
"lang": "rust",
"repo": "penguin-wwy/Jatcher",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mthh/chit path: /src/chit/owners.rs
use colored::*;
use super::extract;
use super::format;
use super::sources::crates;
use super::sources::get;
pub fn print_owners(crate_name: String) {
let width = format::get_width();
println!(
"{} {}...",
"Searching for".magenta(),
... | code_fim | hard | {
"lang": "rust",
"repo": "mthh/chit",
"path": "/src/chit/owners.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lines = format_owner_details("ownerName1", owner);
assert_eq!(lines[0].len(), 21);
assert_eq!(lines[1].len(), 8);
assert_eq!(lines[2].len(), 9);
assert_eq!(lines.len(), 3);
}
}<|fim_prefix|>// repo: mthh/chit path: /src/chit/owners.rs
use colored::*;
use s... | code_fim | hard | {
"lang": "rust",
"repo": "mthh/chit",
"path": "/src/chit/owners.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jascha-N/carguino path: /carguino-build/src/lib.rs
#[macro_use] extern crate error_chain;
extern crate bindgen;
#[macro_use] extern crate lazy_static;
extern crate regex;
#[macro_use] extern crate serde_derive;
extern crate serde_json;
<|fim_suffix|>#[doc(hidden)]
pub mod config;
mod error;
mod... | code_fim | medium | {
"lang": "rust",
"repo": "Jascha-N/carguino",
"path": "/carguino-build/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[doc(hidden)]
pub mod config;
mod error;
mod prefs;<|fim_prefix|>// repo: Jascha-N/carguino path: /carguino-build/src/lib.rs
#[macro_use] extern crate error_chain;
extern crate bindgen;
#[macro_use] extern crate lazy_static;
extern crate regex;
#[macro_use] extern crate serde_derive;
extern crate serde_... | code_fim | medium | {
"lang": "rust",
"repo": "Jascha-N/carguino",
"path": "/carguino-build/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samuel-messing/adventofcode-2020 path: /day_4/src/main.rs
use regex::Regex;
use std::collections::HashMap;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
#[derive(Debug)]
struct Passport {
byr: Option<i32>,
iyr: Option<i32>,
eyr: Option<i32>,
hgt: Option<S... | code_fim | hard | {
"lang": "rust",
"repo": "samuel-messing/adventofcode-2020",
"path": "/day_4/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut num_valid = 0;
for passport in passports {
if passport.is_valid() {
num_valid += 1;
}
}
println!("The answer to part one is: {}", num_valid);
}
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where
P: AsRef<Path>,
{
l... | code_fim | hard | {
"lang": "rust",
"repo": "samuel-messing/adventofcode-2020",
"path": "/day_4/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn create_texture_from_surface(&self, surface: &surface::Surface) -> SdlResult<Texture> {
let result = unsafe { ll::SDL_CreateTextureFromSurface(self.raw, surface.raw()) };
if result == ptr::null() {
Err(get_error())
} else {
Ok(Texture { raw: result... | code_fim | hard | {
"lang": "rust",
"repo": "drbawb/rust-sdl2",
"path": "/src/sdl2/render.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drbawb/rust-sdl2 path: /src/sdl2/render.rs
enum RendererParent {
Surface(Surface),
Window(Window)
}
#[allow(raw_pointer_derive)]
pub struct Renderer {
raw: *const ll::SDL_Renderer,
parent: Option<RendererParent>,
owned: bool
}
#[unsafe_destructor]
impl Drop for Renderer {
... | code_fim | hard | {
"lang": "rust",
"repo": "drbawb/rust-sdl2",
"path": "/src/sdl2/render.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_blend_mode(&self, blend: BlendMode) -> SdlResult<()> {
let ret = unsafe { ll::SDL_SetTextureBlendMode(self.raw, FromPrimitive::from_i64(blend as i64).unwrap()) };
if ret == 0 { Ok(()) }
else { Err(get_error()) }
}
pub fn get_blend_mode(&self) -> SdlResult<B... | code_fim | hard | {
"lang": "rust",
"repo": "drbawb/rust-sdl2",
"path": "/src/sdl2/render.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jturner314/nditer path: /src/adapters/map.rs
use crate::{NdAccess, NdProducer, NdReshape, NdSource, NdSourceRepeat};
use ndarray::Axis;
/// A producer that maps the falues of the inner iterator with the closure.
///
/// This struct is created by the `map` method on `NdProducer`. See its
/// doc... | code_fim | hard | {
"lang": "rust",
"repo": "jturner314/nditer",
"path": "/src/adapters/map.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe impl<T, F> NdAccess for Map<T, F>
where
T: NdAccess,
{
type Dim = T::Dim;
type Ptr = T::Ptr;
impl_ndaccess_methods_for_wrapper!(inner);
}
unsafe impl<T, F, B> NdSourceRepeat for Map<T, F>
where
F: Fn(T::Item) -> B,
T: NdSourceRepeat,
{
}<|fim_prefix|>// repo: jturner314/ndi... | code_fim | hard | {
"lang": "rust",
"repo": "jturner314/nditer",
"path": "/src/adapters/map.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pnoken/tools path: /crates/formatter/tests/spec_test.rs
use core::create_app;
use rome_formatter::{format_file, FormatOptions};
use std::fs;
use std::path::Path;
/// Tests that format a given input file, results in the expected formatted output.
///
/// The input and the expected output are sto... | code_fim | hard | {
"lang": "rust",
"repo": "pnoken/tools",
"path": "/crates/formatter/tests/spec_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(
expected_file.is_file(),
"The expected output '{}' must exist and be a file.",
expected_file.display(),
);
let result = format_file(file_path, FormatOptions::default(), &app);
let expected_output = fs::read_to_string(expected_file).unwrap();
assert_eq!(&expected_output, result.code()... | code_fim | medium | {
"lang": "rust",
"repo": "pnoken/tools",
"path": "/crates/formatter/tests/spec_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EdenEast/repo path: /src/cmd/config.rs
use anyhow::Result;
use clap::CommandFactory;
use repo_cli::prelude::*;
use std::{path::PathBuf, str::FromStr};
use super::{ConfigCmd, Run};
impl Run for ConfigCmd {
fn run(self) -> anyhow::Result<()> {
let mut workspace = Workspace::new()?;
... | code_fim | hard | {
"lang": "rust",
"repo": "EdenEast/repo",
"path": "/src/cmd/config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !self.edit && !self.list && !self.name_only {
ConfigCmd::command().print_long_help()?;
}
Ok(())
}
fn get_value(&self, name: &str, config: &Config) {
let location = match (self.local, self.global) {
(true, false) => Some(Location::Local),... | code_fim | hard | {
"lang": "rust",
"repo": "EdenEast/repo",
"path": "/src/cmd/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: haze/dawn path: /model/src/channel/message/flags.rs
use bitflags::bitflags;
bitflags! {
pub struct MessageFlags: u64 {
const CROSSPOSTED = 1;
const IS_CROSSPOST = 1 << 1;
const SUPPRESS_EMBEDS = 1 << 2;
const SOURCE_MESSAGE_DELETED = 1 << 3;
const URG... | code_fim | medium | {
"lang": "rust",
"repo": "haze/dawn",
"path": "/model/src/channel/message/flags.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl<'de> Deserialize<'de> for MessageFlags {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
Ok(Self::from_bits_truncate(u64::deserialize(deserializer)?))
}
}
impl Serialize for MessageFlags {
fn serialize<S>(&self, serial... | code_fim | medium | {
"lang": "rust",
"repo": "haze/dawn",
"path": "/model/src/channel/message/flags.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = match self {
DnsCache::Disable => 0,
DnsCache::Timeout(duration) => duration.as_secs() as i64,
DnsCache::Forever => -1,
};
// Use unsafe API, because safe API doesn't let us set to -1.
unsafe {
match curl_sys::cur... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/isahc",
"path": "/src/config/dns.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagebind/isahc path: /src/config/dns.rs
//! Configuration of DNS resolution.
use super::SetOpt;
use curl::easy::Easy2;
use std::{net::IpAddr, time::Duration};
/// DNS caching configuration.
///
/// The default configuration is for caching to be enabled with a 60 second
/// entry timeout.
///
/... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/isahc",
"path": "/src/config/dns.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yuiki/bist path: /src/network.rs
#[allow(dead_code)]
#[derive(Clone)]
pub enum Network {
Mainnet,
Testnet,
Regtest,
}
impl Network {
pub fn magic_bytes(&self) -> u32 {
match self {
Network::Mainnet => 0xD9B4BEF9,
Network::Testnet => 0x0709110B,
... | code_fim | hard | {
"lang": "rust",
"repo": "Yuiki/bist",
"path": "/src/network.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>seed.bitcoin.jonasschnelli.ch",
"seed.tbtc.petertodd.org",
"seed.testnet.bitcoin.sprovoost.nl",
"testnet-seed.bluematt.me",
"bitcoin-testnet.bloqseeds.net",
],
Network::Regtest => vec![]
}
}
}<|fim_prefix|>... | code_fim | hard | {
"lang": "rust",
"repo": "Yuiki/bist",
"path": "/src/network.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bestform/aoc2020 path: /src/aoc5.rs
use std::fs;
pub(crate) fn run() {
let contents = fs::read_to_string("src/input/05a.txt")
.expect("Something went wrong reading the file");
let mut highest_seat = 0;
let mut found_seats = vec![];
<|fim_suffix|> //println!("{}: low... | code_fim | hard | {
"lang": "rust",
"repo": "bestform/aoc2020",
"path": "/src/aoc5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn find_seat(seq: &str, total_rows: i32, total_seats: i32) -> i32 {
let mut current_row_low = 0;
let mut current_row_high = total_rows - 1;
let mut current_seat_low = 0;
let mut current_seat_high = total_seats - 1;
for c in seq.chars() {
match c {
'B' => {
... | code_fim | hard | {
"lang": "rust",
"repo": "bestform/aoc2020",
"path": "/src/aoc5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Debuff {
pub fn new(buff: Buff) -> Self {
return Self {
kind: buff.stats.kind,
effectiveness: buff.effectiveness(),
cooldown: buff.effectiveness(),
};
}
}<|fim_prefix|>// repo: hexgolems/td path: /src/debuffs.rs
use crate::buffs::Buff;
use ... | code_fim | medium | {
"lang": "rust",
"repo": "hexgolems/td",
"path": "/src/debuffs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hexgolems/td path: /src/debuffs.rs
use crate::buffs::Buff;
use crate::buffs::BuffType;
<|fim_suffix|>impl Debuff {
pub fn new(buff: Buff) -> Self {
return Self {
kind: buff.stats.kind,
effectiveness: buff.effectiveness(),
cooldown: buff.effectiven... | code_fim | medium | {
"lang": "rust",
"repo": "hexgolems/td",
"path": "/src/debuffs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args = Cli::from_args();
let content = std::fs::read_to_string(&args.path).expect("File not found..");
println!("{}", content);
println!("`");
println!("`");
println!("`");
println!("`");
println!("`");
println!("`");
// for line in content.lines() {
// ... | code_fim | medium | {
"lang": "rust",
"repo": "saivishnu725/gras",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saivishnu725/gras path: /src/main.rs
use structopt::StructOpt;
#[derive(StructOpt)]
struct Cli {
pattern: String,
#[structopt(parse(from_os_str))]
path: std::path::PathBuf,
}
<|fim_suffix|> let args = Cli::from_args();
let content = std::fs::read_to_string(&args.path).expect(... | code_fim | medium | {
"lang": "rust",
"repo": "saivishnu725/gras",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Iterates over the entries of this record, mutably.
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut Option<Value>)> {
self.fields
.iter_mut()
.map(|(key, value)| (key.as_ref(), value))
}
}
impl Display for Record {
fn fmt(&self, f: &mut Fo... | code_fim | hard | {
"lang": "rust",
"repo": "foxfriends/lumber",
"path": "/src/lumber/record.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foxfriends/lumber path: /src/lumber/record.rs
use super::Value;
use crate::program::evaltree::*;
use std::collections::HashMap;
use std::fmt::{self, Display, Formatter};
/// An implementation of a record which may be incomplete, suitable for Lumber values which
/// may themselves be unbound.
#[... | code_fim | hard | {
"lang": "rust",
"repo": "foxfriends/lumber",
"path": "/src/lumber/record.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Display for Record {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
if self.fields.is_empty() {
write!(f, "{{:}}")
} else {
write!(f, "{{ ")?;
let mut keys_sorted: Vec<_> = self.fields.keys().collect();
keys_sorted.sort();
... | code_fim | hard | {
"lang": "rust",
"repo": "foxfriends/lumber",
"path": "/src/lumber/record.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackweinbender/advent_of_code path: /2018/day05/src/main.rs
use std::collections::LinkedList;
fn main() {
let input = include_str!("input.txt");
println!("Answer #1: {}", compress_polymer(input).len());
println!("Answer #2: {}", get_minimal_compression(input));
}
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "jackweinbender/advent_of_code",
"path": "/2018/day05/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct CharPair(char, char);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_compress_polymer() {
let input = "dabAcCaCBAcCcaDA";
assert_eq!(compress_polymer(input).len(), 10);
}
#[test]
fn test_get_candidate_polymers() {
let input = "dabAcCaCBAcCcaD... | code_fim | hard | {
"lang": "rust",
"repo": "jackweinbender/advent_of_code",
"path": "/2018/day05/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (input, _) = char(' ')(input)?;
let (input, _) = tag("GMT")(input)?;
let (_, hdr_val) = HeaderValue::new(
&source_input[..source_input.len() - input.len()],
HeaderValueType::DateString,
None,
None,
)?;
Ok((input, h... | code_fim | hard | {
"lang": "rust",
"repo": "WangHoi/sipcore",
"path": "/crates/sipmsg/src/headers/parsers/date.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WangHoi/sipcore path: /crates/sipmsg/src/headers/parsers/date.rs
use crate::common::errorparse::SipParseError;
use crate::headers::{
header::{HeaderValue, HeaderValueType},
traits::SipHeaderParser,
};
use nom::{
bytes::complete::{tag, take},
character::complete::{char, digit1},
... | code_fim | hard | {
"lang": "rust",
"repo": "WangHoi/sipcore",
"path": "/crates/sipmsg/src/headers/parsers/date.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: time-rs/time path: /tests/serde/rfc3339.rs
use serde::{Deserialize, Serialize};
use serde_test::{
assert_de_tokens_error, assert_ser_tokens_error, assert_tokens, Configure, Token,
};
use time::macros::datetime;
use time::serde::rfc3339;
use time::OffsetDateTime;
#[derive(Serialize, Deserial... | code_fim | hard | {
"lang": "rust",
"repo": "time-rs/time",
"path": "/tests/serde/rfc3339.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
#[serde(untagged)]
enum Wrapper {
A(Test),
}
assert_eq!(
serde_json::from_str::<Wrapper>("{\"dt\": \"2000-01-01T00:00:00Z\", \"option_dt\": null}")?,
Wrapper::A(Test {
dt: datetime!(2000-01-01 0... | code_fim | hard | {
"lang": "rust",
"repo": "time-rs/time",
"path": "/tests/serde/rfc3339.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const A: &str = r#"{
"date": "2022-05-01T10:20:42.123Z"
}"#;
const B: &str = r#"{
"date": "2022-05-01T10:20:42.123Z",
"maybe_date": "2022-05-01T10:20:42.123Z"
}"#;
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
struct S {
#[serde(with = "t... | code_fim | hard | {
"lang": "rust",
"repo": "time-rs/time",
"path": "/tests/serde/rfc3339.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: openacid/celeritasdb path: /components/epaxos/src/replica/errors.rs
use crate::qpaxos::ReplicaId;
use crate::qpaxos::{QError, StorageFailure};
use storage::StorageError;
quick_error! {
#[derive(Debug, Eq, PartialEq)]
pub enum ReplicaError {
Storage(s: StorageError) {
... | code_fim | hard | {
"lang": "rust",
"repo": "openacid/celeritasdb",
"path": "/components/epaxos/src/replica/errors.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO impl
Self::ReplicaNotFound(_) => QError {
sto: Some(StorageFailure {}),
..Default::default()
},
}
}
}<|fim_prefix|>// repo: openacid/celeritasdb path: /components/epaxos/src/replica/errors.rs
use crate::qpaxos::Replic... | code_fim | hard | {
"lang": "rust",
"repo": "openacid/celeritasdb",
"path": "/components/epaxos/src/replica/errors.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ror 0"]
#[inline]
pub fn ferr0(&self) -> FERR0R {
let bits = {
const MASK: bool = true;
const OFFSET: u8 = 15;
((self.bits >> OFFSET) & MASK as u32) != 0
};
FERR0R { bits }
}
#[doc = "Bits 16:24 - RX Data 1"]
#[inline]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "maximeborges/svd2rust_efm32gg990",
"path": "/src/usart1/rxdoublex.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maximeborges/svd2rust_efm32gg990 path: /src/usart1/rxdoublex.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::RXDOUBLEX {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.reg... | code_fim | hard | {
"lang": "rust",
"repo": "maximeborges/svd2rust_efm32gg990",
"path": "/src/usart1/rxdoublex.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> constant::HANDLE_INVOKE_VIRTUAL => Some(InvokeVirtual),
constant::HANDLE_INVOKE_STATIC => Some(InvokeStatic),
constant::HANDLE_INVOKE_SPECIAL => Some(InvokeSpecial),
constant::HANDLE_NEW_INVOKE_SPECIAL => Some(NewInvokeSpecial),
constant::HANDLE_... | code_fim | hard | {
"lang": "rust",
"repo": "Thinkofname/jas",
"path": "/classfile/src/raw/constant.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> InvokeVirtual,
InvokeStatic,
InvokeSpecial,
NewInvokeSpecial,
InvokeInterface,
}
impl MethodHandleKind {
pub fn as_byte(&self) -> u8 {
use self::MethodHandleKind::*;
match *self {
GetField => constant::HANDLE_GET_FIELD,
GetStatic => constant... | code_fim | hard | {
"lang": "rust",
"repo": "Thinkofname/jas",
"path": "/classfile/src/raw/constant.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Thinkofname/jas path: /classfile/src/raw/constant.rs
use consts::constant;
use indexing::ConstantIndex;
#[derive(Debug, PartialEq)]
pub enum Constant {
Class(ConstantIndex),
FieldRef {
class: ConstantIndex,
signature: ConstantIndex,
},
MethodRef {
class... | code_fim | hard | {
"lang": "rust",
"repo": "Thinkofname/jas",
"path": "/classfile/src/raw/constant.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(cartesian_decoder(&String::from("ABCD")), "ABCD");
}
}<|fim_prefix|>// repo: sogilis/sogilis-katalog path: /cartesian_enigma/rust/src/cartesian_test.rs
#[cfg(test)]
mod cartesian_test {
use super::super::cartesian_decoder;
<|fim_middle|> #[test]
fn decode_single_letter(... | code_fim | medium | {
"lang": "rust",
"repo": "sogilis/sogilis-katalog",
"path": "/cartesian_enigma/rust/src/cartesian_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sogilis/sogilis-katalog path: /cartesian_enigma/rust/src/cartesian_test.rs
#[cfg(test)]
mod cartesian_test {
use super::super::cartesian_decoder;
<|fim_suffix|> assert_eq!(cartesian_decoder(&String::from("AB")), "AB");
}
#[test]
fn decode_two_letters() {
assert_e... | code_fim | easy | {
"lang": "rust",
"repo": "sogilis/sogilis-katalog",
"path": "/cartesian_enigma/rust/src/cartesian_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rillrate-fossil/rillrate path: /pkg-dashboard/rate-app/src/cases/state.rs
use rate_ui::shared_object::{RouterState, SharedObject};
use rate_ui::storage::typed_storage::Storable;
use rill_protocol::io::provider::{EntryId, Path};
use rrpack_basis::manifest::layouts::components::Layout;
use serde::... | code_fim | hard | {
"lang": "rust",
"repo": "rillrate-fossil/rillrate",
"path": "/pkg-dashboard/rate-app/src/cases/state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Storable for CasesState {
fn key() -> &'static str {
module_path!()
}
}
impl RouterState for CasesState {
fn restored(&mut self) {
self.structure.clear();
}
fn on_update(&mut self) {
self.autoselect();
}
}<|fim_prefix|>// repo: rillrate-fossil/rillrat... | code_fim | hard | {
"lang": "rust",
"repo": "rillrate-fossil/rillrate",
"path": "/pkg-dashboard/rate-app/src/cases/state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: himlpplm/rust-tdlib path: /src/types/test_return_error.rs
use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
/// Returns the specified error and ensures that the Error object is used; for testing only. Can be called synchronously
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
... | code_fim | hard | {
"lang": "rust",
"repo": "himlpplm/rust-tdlib",
"path": "/src/types/test_return_error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn error(&self) -> &Error {
&self.error
}
}
#[doc(hidden)]
pub struct RTDTestReturnErrorBuilder {
inner: TestReturnError,
}
impl RTDTestReturnErrorBuilder {
pub fn build(&self) -> TestReturnError {
self.inner.clone()
}
pub fn error<T: AsRef<Error>>(&mut self,... | code_fim | medium | {
"lang": "rust",
"repo": "himlpplm/rust-tdlib",
"path": "/src/types/test_return_error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>//#![deny(unused_import_braces)]
pub mod foo18 {
pub struct A;
}
use foo18::{A};
//#[deny(unused_lifetimes)]
pub fn foo19<'a>() {}
//#Example21
mod foo20 {
pub fn bar() {}
}
//#Example22
fn foo21<T>() -> T { panic!() }
//#Example23
enum Foo22 {
V0(u8),
VBig([u8; 1024]),
}
fn main() {... | code_fim | hard | {
"lang": "rust",
"repo": "Jaxelr/RustTutorial",
"path": "/The Rustc Book/03_3_1_allowed_by_default_lints/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jaxelr/RustTutorial path: /The Rustc Book/03_3_1_allowed_by_default_lints/main.rs
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
//#![feature(unsafe_block_in_unsafe_fn)] //Needs unstable channel
//#![deny(elided_lifetimes_in_paths)] //This po... | code_fim | hard | {
"lang": "rust",
"repo": "Jaxelr/RustTutorial",
"path": "/The Rustc Book/03_3_1_allowed_by_default_lints/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::foo::bar();
match FOO12 {
FOO12 => {},
_ => {},
}
//#Example14
let x: &u32 = &42;
let y = x as *const u32;
//#Example15
let x2 = 42_i32 as i32;
//#Example18
unsafe {
let foo14 = Foo14 { field1: 0, field2: 0 };
let _ = &foo14.fie... | code_fim | hard | {
"lang": "rust",
"repo": "Jaxelr/RustTutorial",
"path": "/The Rustc Book/03_3_1_allowed_by_default_lints/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_cloud_names() -> &'static Vec<&'static str> {
static INSTANCE: Lazy<Vec<&'static str>> =
Lazy::new(|| CONFIG.iter().map(|cc| cc.service_name).collect());
INSTANCE.deref()
}
pub fn get_cloud_config(service: &str) -> Result<&'static CloudConfig, Error> {
let cc = CONFIG.iter(... | code_fim | hard | {
"lang": "rust",
"repo": "nestorwheelock/netrange",
"path": "/src/utils/cloud_config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nestorwheelock/netrange path: /src/utils/cloud_config.rs
use crate::sources::{aws, azure, backblaze, cloudflare, digitalocean, gcp, github, google};
use crate::utils::filter_select::RangesWithMetadata;
use anyhow::{bail, Error};
use once_cell::sync::Lazy;
use std::io::Read;
use std::ops::Deref;
... | code_fim | hard | {
"lang": "rust",
"repo": "nestorwheelock/netrange",
"path": "/src/utils/cloud_config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FauxFaux/septid path: /src/sync_client.rs
use std::io;
use std::io::Read;
use std::io::Write;
use anyhow::anyhow;
use anyhow::Context as _;
use anyhow::Result;
use crate::proto::kex;
use crate::proto::packet;
use crate::proto::SessionCrypto;
use crate::MasterKey;
/// A secure pipe over a `Wri... | code_fim | hard | {
"lang": "rust",
"repo": "FauxFaux/septid",
"path": "/src/sync_client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<S: Write> Write for SPipe<S> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
if buf.is_empty() {
return Ok(0);
}
let buf = &buf[..buf.len().min(packet::PACKET_MAX_MESSAGE_LEN)];
self.inner
.write_all(&packet::enpacket(&mut self.cryp... | code_fim | hard | {
"lang": "rust",
"repo": "FauxFaux/septid",
"path": "/src/sync_client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> } else {
let filename = req.uri().path();
root.push(&filename[1..]); // remove leading /
let extension = &(Path::new(filename).extension().and_then(|s| s.to_str()));
debug!("Requesting file {:?}", root.to_str());
match await!(File::open(r... | code_fim | hard | {
"lang": "rust",
"repo": "anlumo/cellardoor",
"path": "/cellardoor/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anlumo/cellardoor path: /cellardoor/src/main.rs
#![feature(await_macro, async_await, futures_api)]
use {
log::{info, debug, error},
hyper::{
// Miscellaneous types from Hyper for working with HTTP.
Body, Request, Response, Server, StatusCode, Method,
// This func... | code_fim | hard | {
"lang": "rust",
"repo": "anlumo/cellardoor",
"path": "/cellardoor/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn comment() {
for d in 0..255u8 {
let c = d as char;
if !"[]><+-,.".contains(c) {
assert_eq!(TokenKind::Comment, TokenKind::from(c));
} else {
assert_ne!(TokenKind::Comment, TokenKind::from(c));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "scowcron/sateko",
"path": "/src/token.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn end_loop() {
assert_eq!(TokenKind::EndLoop, TokenKind::from(']'));
}
#[test]
fn inc_tape() {
assert_eq!(TokenKind::IncTape, TokenKind::from('>'));
}
#[test]
fn dec_tape() {
assert_eq!(TokenKind::DecTape, TokenKind::from('<'));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "scowcron/sateko",
"path": "/src/token.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scowcron/sateko path: /src/token.rs
#[derive(Clone, Debug, PartialEq)]
pub struct Token {
pub kind: TokenKind,
pub pos: InputPosition,
}
#[derive(Clone, Debug, PartialEq)]
pub struct InputPosition {
pub line: usize,
pub pos: usize,
}
#[derive(Clone, Debug, PartialEq)]
pub enum ... | code_fim | hard | {
"lang": "rust",
"repo": "scowcron/sateko",
"path": "/src/token.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> ValueWriter for StringWriter<'a> {
fn write<T: ToString>(&mut self, v: T) -> Result<(), Error> {
self.output.write((v.to_string() + &"\n".to_string()).as_bytes())?;
return self.output.flush();
}
fn write_vec<T: ToString>(&mut self, vec: Vec<T>) -> Result<(), Error> {
... | code_fim | hard | {
"lang": "rust",
"repo": "tdaira/prime-number",
"path": "/src/io/value_writer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tdaira/prime-number path: /src/io/value_writer.rs
use std::io::Write;
use std::io::Error;
use std::io::stdout;
pub trait ValueWriter {
fn write<T: ToString>(&mut self, v: T) -> Result<(), Error>;
fn write_vec<T: ToString>(&mut self, vec: Vec<T>) -> Result<(), Error>;
}
pub struct StdWr... | code_fim | hard | {
"lang": "rust",
"repo": "tdaira/prime-number",
"path": "/src/io/value_writer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> Result<()> {
env_logger::init_from_env(env_logger::Env::default().filter_or("RUST_LOG", "info"));
let opts = Opts::from_args();
let param = Parameter {
v_bit_len: opts.bit_len.to_vec(),
acc_type: opts.acc,
use_sk: opts.use_sk,
intra_index: !opts.no... | code_fim | hard | {
"lang": "rust",
"repo": "zhang-zw123/vchain-demo",
"path": "/vchain-simchain/src/bin/simchain-build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhang-zw123/vchain-demo path: /vchain-simchain/src/bin/simchain-build.rs
#[macro_use]
extern crate log;
use anyhow::{bail, Result};
use std::path::{Path, PathBuf};
use structopt::StructOpt;
use vchain::acc;
use vchain::chain::*;
use vchain::{Digest, Digestible};
use vchain_simchain::SimChain;
... | code_fim | hard | {
"lang": "rust",
"repo": "zhang-zw123/vchain-demo",
"path": "/vchain-simchain/src/bin/simchain-build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The handlebars key for the smaller text message under the heading.
pub const MESSAGE: &'static str = "message";
/// Create a new jumbotron template.
pub fn new(heading: impl Into<String>, message: impl Into<String>) -> Template {
Template::new(TEMPLATE_NAME)
.field(HEADING, heading.into()... | code_fim | medium | {
"lang": "rust",
"repo": "yemily17/Telescope",
"path": "/src/templates/jumbotron.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yemily17/Telescope path: /src/templates/jumbotron.rs
use crate::templates::Template;
/// The template path from the templates directory.
const TEMPLATE_NAME: &'static str = "jumbotron";
<|fim_suffix|>/// The handlebars key for the smaller text message under the heading.
pub const MESSAGE: &'st... | code_fim | medium | {
"lang": "rust",
"repo": "yemily17/Telescope",
"path": "/src/templates/jumbotron.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jolestar/libra path: /client/libra-dev/src/lib.rs
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(clippy::missing_safety_doc)]
<|fim_suffix|>use crate::data:... | code_fim | medium | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/client/libra-dev/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>static_assertions::const_assert_eq!(LIBRA_PUBKEY_SIZE, ED25519_PUBLIC_KEY_LENGTH as u32);
static_assertions::const_assert_eq!(LIBRA_PRIVKEY_SIZE, ED25519_PRIVATE_KEY_LENGTH as u32);
static_assertions::const_assert_eq!(LIBRA_ADDRESS_SIZE, AccountAddress::LENGTH as u32);
static_assertions::const_assert_eq!(... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/client/libra-dev/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Client {
pub fn get_ranked_info(&self, summoner_name: &String) -> Vec<RankedQueue> {
let endpoint = build_endpoint(self, SUMMONER_INFO_BY_NAME_ENDPOINT, &summoner_name);
let endpoint_ref: &str = endpoint.as_ref();
let response = reqwest::get(endpoint_ref).unwrap().text().u... | code_fim | hard | {
"lang": "rust",
"repo": "makinje16/PartyUp",
"path": "/src/league_api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: makinje16/PartyUp path: /src/league_api.rs
use reqwest;
use serde_derive::{Deserialize, Serialize};
use serde_json;
const SUMMONER_INFO_BY_NAME_ENDPOINT: &str =
"https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/";
const RANKED_INFO_BY_SUMMONER_ID_ENDPOINT: &str =
"https:/... | code_fim | hard | {
"lang": "rust",
"repo": "makinje16/PartyUp",
"path": "/src/league_api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rfdonnelly/rvs path: /parser/tests/import.rs
use std::env::current_dir;
use rvs_parser::{Parser, SearchPath};
/// Verify search path priority
#[test]
fn same_filename_different_directory() {
let fixtures = current_dir()
.unwrap()
.join("tests/import/same_filename_different_... | code_fim | medium | {
"lang": "rust",
"repo": "rfdonnelly/rvs",
"path": "/parser/tests/import.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn not_in_search_path() {
let fixtures = current_dir().unwrap().join("tests/import");
let search_path = SearchPath::new(vec![fixtures]);
let parser = Parser::new(search_path);
assert!(parser.parse("import a;").is_err());
}
}<|fim_prefix|>// repo: rfdonne... | code_fim | hard | {
"lang": "rust",
"repo": "rfdonnelly/rvs",
"path": "/parser/tests/import.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (pid, process) in processes_list.iter() {
if process.cmd().len() != 0 {
self.table.get_store().insert_with_values(
None,
&[0, 1, 2, 3, 4, 5],
&[
pid,
// &extr... | code_fim | hard | {
"lang": "rust",
"repo": "nzaharov/rust-course-project",
"path": "/gtk-frontend/src/ui/dashboard/processes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// fn extract_username(environ: &[String]) -> String {
// println!("{:?}", environ);
// let user = environ.iter().find(|line| {
// if line.len() > 9 && &line[..=8] == "USERNAME=" {
// return true;
// }
// false
// });
// let user = match user {
// ... | code_fim | hard | {
"lang": "rust",
"repo": "nzaharov/rust-course-project",
"path": "/gtk-frontend/src/ui/dashboard/processes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nzaharov/rust-course-project path: /gtk-frontend/src/ui/dashboard/processes.rs
use crate::ui::common::table::Table;
use crate::ui::Refresh;
use gtk::prelude::*;
use sysinfo::{ProcessExt, SystemExt};
pub struct Processes {
pub table: Table,
}
impl Processes {
pub fn new() -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "nzaharov/rust-course-project",
"path": "/gtk-frontend/src/ui/dashboard/processes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Debug for ExecutionOutcome {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("ExecutionOutcome")
.field("status", &self.status)
.field("logs", &format_args!("{}", logging::pretty_vec(&self.logs)))
.field("receipt_ids", &format... | code_fim | hard | {
"lang": "rust",
"repo": "zhiwei-w-luo/near-rpc",
"path": "/src/types/transaction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhiwei-w-luo/near-rpc path: /src/types/transaction.rs
use std::fmt;
use std::borrow::Borrow;
use std::hash::{Hash, Hasher};
use borsh::{BorshDeserialize, BorshSerialize};
use crate::types::{AccountId, Balance, Nonce, MerkleHash, MerklePath, CryptoHash, hash, AccessKey, logging, Gas, AccessKeyP... | code_fim | hard | {
"lang": "rust",
"repo": "zhiwei-w-luo/near-rpc",
"path": "/src/types/transaction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn init(&mut self) {
self.hash = self.transaction.get_hash();
}
pub fn get_hash(&self) -> CryptoHash {
self.hash
}
pub fn from_actions(
nonce: Nonce,
signer_id: AccountId,
receiver_id: AccountId,
signer: &dyn Signer,
actions... | code_fim | hard | {
"lang": "rust",
"repo": "zhiwei-w-luo/near-rpc",
"path": "/src/types/transaction.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.