text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: shadowsocks/shadowsocks-rust path: /crates/shadowsocks-service/src/acl/sub_domains_tree.rs
use std::{
collections::HashMap,
fmt::{self, Debug},
};
#[derive(Debug, Clone)]
struct DomainPart {
included: bool,
children: HashMap<String, DomainPart>,
}
impl DomainPart {
fn new()... | code_fim | hard | {
"lang": "rust",
"repo": "shadowsocks/shadowsocks-rust",
"path": "/crates/shadowsocks-service/src/acl/sub_domains_tree.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn insert(&mut self, value: &str) {
let mut current_map = &mut self.0;
let mut last_included = None;
for part in value.rsplit('.') {
let entry = current_map
.entry(part.to_ascii_lowercase())
.or_insert_with(DomainPart::new);
... | code_fim | hard | {
"lang": "rust",
"repo": "shadowsocks/shadowsocks-rust",
"path": "/crates/shadowsocks-service/src/acl/sub_domains_tree.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<idna::Errors> for Error {
fn from(err: idna::Errors) -> Error {
ConvertToPunycode(err)
}
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Error {
Network(err)
}
}<|fim_prefix|>// repo: rekby/rust-whois2 path: /src/errors.rs
use std::fmt::D... | code_fim | hard | {
"lang": "rust",
"repo": "rekby/rust-whois2",
"path": "/src/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rekby/rust-whois2 path: /src/errors.rs
use std::fmt::Display;
#[derive(Debug)]
pub enum Error {
BadWhoisForDomain,
ConvertToPunycode(idna::Errors),
WhoisServerLoop(String),
CantFindWhoisServer,
Network(std::io::Error),
}
use Error::*;
impl Display for Error {
fn fmt(&s... | code_fim | hard | {
"lang": "rust",
"repo": "rekby/rust-whois2",
"path": "/src/errors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
BadWhoisForDomain | CantFindWhoisServer => f.write_str(format!("{:?}", *self).as_str()),
ConvertToPunycode(errors) => {
f.write_str(format!("Error convert to punycode: {:?}", errors).as_str())
}
WhoisServerLoop(domain) =>... | code_fim | medium | {
"lang": "rust",
"repo": "rekby/rust-whois2",
"path": "/src/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let final_map = loop {
let (next_map, changed) = tick(&seatmap);
debug_print(&next_map);
thread::sleep_ms(10);
if !changed { break next_map };
seatmap = next_map;
};
let final_occupied_count: u32 =
final_map
.iter()
.map... | code_fim | hard | {
"lang": "rust",
"repo": "krithin/adventofcode2020",
"path": "/day11/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: krithin/adventofcode2020 path: /day11/src/main.rs
use std::{io, io::prelude::*};
use std::{thread};
fn first_along_direction(seatmap: &Vec<Vec<char>>, i: usize, j: usize, dir_update: &fn(i32, i32) -> (i32, i32)) -> char {
let mut i: i32 = i as i32;
let mut j: i32 = j as i32;
loop {
... | code_fim | hard | {
"lang": "rust",
"repo": "krithin/adventofcode2020",
"path": "/day11/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug_print(&next_map);
thread::sleep_ms(10);
if !changed { break next_map };
seatmap = next_map;
};
let final_occupied_count: u32 =
final_map
.iter()
.map(
|row|
row.iter().map(
|c... | code_fim | hard | {
"lang": "rust",
"repo": "krithin/adventofcode2020",
"path": "/day11/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Creates and returns a Rust VFS VmoFile-backed executable file using the contents of the
/// conformance test harness binary itself.
fn new_exec_file() -> Result<Arc<dyn DirectoryEntry>, Error> {
let init_vmo = || async {
let file = fdio::open_fd(
HARNESS_EXEC_PATH,
... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/storage/conformance/conformance_harness/rustvfs/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvanotti/fuchsia-mirror path: /src/storage/conformance/conformance_harness/rustvfs/src/main.rs
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! io.fidl and io2.fidl conformance... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/storage/conformance/conformance_harness/rustvfs/src/main.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn add_entry(
entry: &io_test::DirectoryEntry,
dest: &Arc<Simple<MutableConnection>>,
) -> Result<(), Error> {
match entry {
io_test::DirectoryEntry::Directory(dir) => {
let name = dir.name.as_ref().expect("Directory must have name");
let new_dir = simple();
... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/storage/conformance/conformance_harness/rustvfs/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = None;
let exp = "None".to_string();
let act = format!("{:?}", x);
assert_eq!(act, exp);
check_log(exp, x);
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
#![allow(non_camel_case_types)]
#![allow(dead_code)... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#[derive(Clone, Debug)]
enum foo {
a(usize),
b(String),
}
fn check_log<T: std::fmt::Debug>(exp: String, v: T) {
<|fim_suffix|>pub fn main()... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raptor-lang/Raptortime path: /src/runtime.rs
use interpreter::{Interpreter, StackFrame};
use raptor_object::RaptorObject;
#[derive(Debug, Default)]
pub struct Runtime {
interpreter: Interpreter,
call_stack: Vec<StackFrame>,
options: ::Options,
memory: Vec<RaptorObject>
}
<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "raptor-lang/Raptortime",
"path": "/src/runtime.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let debug = self.options.debug;
while self.call_stack.len() > 0 {
let dispatch_result = {
let ln = self.call_stack.len();
let mut last_frame = &mut self.call_stack[ln-1];
last_frame.dispatch(&mut self.interpreter, debug)
... | code_fim | hard | {
"lang": "rust",
"repo": "raptor-lang/Raptortime",
"path": "/src/runtime.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Liby99/photon-proto path: /native/src/renderer.rs
use ::math::{Color};
use ::util::{ImageData, Intersection};
use ::scene::Scene;
use ::camera::Camera;
<|fim_suffix|>impl RayTracer {
pub fn render(scene: &Scene, camera: &Camera, img_data: &mut ImageData) {
for (i, j, ray) in camera.rays(i... | code_fim | medium | {
"lang": "rust",
"repo": "Liby99/photon-proto",
"path": "/native/src/renderer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RayTracer {
pub fn render(scene: &Scene, camera: &Camera, img_data: &mut ImageData) {
for (i, j, ray) in camera.rays(img_data.width, img_data.height) {
let color = match scene.intersect(&ray) {
Some(itsct) => Color::from(itsct.normal), // TODO: Change the colors
None => Co... | code_fim | medium | {
"lang": "rust",
"repo": "Liby99/photon-proto",
"path": "/native/src/renderer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> "
} // close digraph\n".to_string()
}
fn run_to_dot(runnable: &Runnable) -> String {
let mut dot_string = String::new();
let name = if runnable.name() == runnable.alias() {
"".to_string()
} else {
format!("\\n({})", runnable.name()).to_string()
};
let mut initial... | code_fim | hard | {
"lang": "rust",
"repo": "l4l/flow",
"path": "/flowclib/src/dumper/dump_dot.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Add edges for each of the outputs of this runnable to other ones
for &(ref output_route, destination_index, destination_input_index) in runnable.get_output_routes() {
let input_port = INPUT_PORTS[destination_input_index % INPUT_PORTS.len()];
let destination_runnable = &runnables... | code_fim | hard | {
"lang": "rust",
"repo": "l4l/flow",
"path": "/flowclib/src/dumper/dump_dot.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: l4l/flow path: /flowclib/src/dumper/dump_dot.rs
use model::flow::Flow;
use generator::generate::CodeGenTables;
use std::io;
use std::io::prelude::*;
use std::path::PathBuf;
use model::runnable::Runnable;
use model::process_reference::ProcessReference;
use model::io::IOSet;
use model::route::Rout... | code_fim | hard | {
"lang": "rust",
"repo": "l4l/flow",
"path": "/flowclib/src/dumper/dump_dot.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for st in strs {
for byte in st.v.as_bytes() {
string_table.push(*byte);
}
string_table.push(0x00);
}
string_table
}
Contents64::Symbols(syms) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "Drumato/elf-utilities",
"path": "/src/section/elf64.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Contents64 {
pub fn size(&self) -> usize {
match self {
Contents64::Raw(bytes) => bytes.len(),
Contents64::StrTab(strs) => {
// ELFの文字列テーブルは null-byte + (name + null-byte) * n という形状に
let total_len: usize = strs.iter().map(|s| s.v.len... | code_fim | hard | {
"lang": "rust",
"repo": "Drumato/elf-utilities",
"path": "/src/section/elf64.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Drumato/elf-utilities path: /src/section/elf64.rs
//! Type definitions for 64-bit ELF binaries.
use std::collections::HashSet;
use crate::section;
use crate::*;
use serde::{Deserialize, Serialize};
use super::StrTabEntry;
#[derive(Debug, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enu... | code_fim | hard | {
"lang": "rust",
"repo": "Drumato/elf-utilities",
"path": "/src/section/elf64.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.mechanism.eq("crossbeam") || args.mechanism.eq("cb") || args.mechanism.eq("all") {
if args.measure {
match measure_workload_crossbeam(
args.bounds,
args.upper_left,
args.lower_right,
args.draw,
) {
... | code_fim | hard | {
"lang": "rust",
"repo": "RustProfi/Mandelbrot-in-Rust-and-C",
"path": "/rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustProfi/Mandelbrot-in-Rust-and-C path: /rust/src/main.rs
use mandelbrot::parseargs::parse_arguments;
use mandelbrot::wcrossbeam::{measure_workload_crossbeam, time_crossbeam};
use mandelbrot::wrayon::{measure_workload_rayon, time_rayon};
use mandelbrot::wscopedthreadpool::{measure_workload_scop... | code_fim | hard | {
"lang": "rust",
"repo": "RustProfi/Mandelbrot-in-Rust-and-C",
"path": "/rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rooms = vec![];
let max_trys = 50;
let min_room = 3;
let max_room = 5;
let first = new_room(rng, min_room, max_room, column_count, row_count);
carve_room(&first, &mut char_map, column_count);
rooms.push(first);
'rooms: for _ in 0..max_trys {
let new_roo... | code_fim | hard | {
"lang": "rust",
"repo": "chrisrhayden/sprite_fight",
"path": "/src/map_gen/basic_dungeon.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrisrhayden/sprite_fight path: /src/map_gen/basic_dungeon.rs
use std::cmp::{max, min};
use rand::prelude::*;
use crate::map_gen::generator::MapRect;
fn new_room(
rng: &mut ThreadRng,
min_room: usize,
max_room: usize,
column_count: usize,
row_count: usize,
) -> MapRect {
... | code_fim | hard | {
"lang": "rust",
"repo": "chrisrhayden/sprite_fight",
"path": "/src/map_gen/basic_dungeon.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stiiifff/aleph-node path: /bin/node/src/command.rs
// SPDX-License-Identifier: Apache-2.0
// 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://www.apache.or... | code_fim | hard | {
"lang": "rust",
"repo": "stiiifff/aleph-node",
"path": "/bin/node/src/command.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Parse and run command line arguments
pub fn run() -> sc_cli::Result<()> {
let cli = Cli::from_args();
match &cli.subcommand {
Some(Subcommand::BootstrapChain(cmd)) => cmd.run(),
Some(Subcommand::BootstrapNode(cmd)) => cmd.run(),
Some(Subcommand::Key(cmd)) => cmd.run(&cl... | code_fim | hard | {
"lang": "rust",
"repo": "stiiifff/aleph-node",
"path": "/bin/node/src/command.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: ResourcePath> Resource for Path<T> {
type Path = T;
fn resource_path(&mut self) -> &mut Path<Self::Path> {
self
}
}
impl<T, P> Resource for T
where
T: DerefMut<Target = Path<P>>,
P: ResourcePath,
{
type Path = P;
fn resource_path(&mut self) -> &mut Path<Self:... | code_fim | hard | {
"lang": "rust",
"repo": "actix/actix-web",
"path": "/actix-router/src/path.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T: ResourcePath> Iterator for PathIter<'a, T> {
type Item = (&'a str, &'a str);
#[inline]
fn next(&mut self) -> Option<(&'a str, &'a str)> {
if self.idx < self.params.segment_count() {
let idx = self.idx;
let res = match self.params.segments[idx].1 {
... | code_fim | hard | {
"lang": "rust",
"repo": "actix/actix-web",
"path": "/actix-router/src/path.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: actix/actix-web path: /actix-router/src/path.rs
use std::{
borrow::Cow,
ops::{DerefMut, Index},
};
use serde::de;
use crate::{de::PathDeserializer, Resource, ResourcePath};
#[derive(Debug, Clone)]
pub(crate) enum PathItem {
Static(Cow<'static, str>),
Segment(u16, u16),
}
impl... | code_fim | hard | {
"lang": "rust",
"repo": "actix/actix-web",
"path": "/actix-router/src/path.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tari-project/tari path: /applications/minotari_node/src/table.rs
// Copyright 2020, The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code mus... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/applications/minotari_node/src/table.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut table = Table::new();
table.set_titles(vec!["Name", "Age", "Telephone Number", "Favourite Headwear"]);
table.add_row(row!["Trevor", 132, "+123 12323223", "Pith Helmet"]);
table.add_row(row![]);
table.add_row(row!["Hatless", 2]);
let mut buf = io::Cur... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/applications/minotari_node/src/table.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res =
show_simple_message_box(MESSAGEBOX_ERROR,
"Goodbye!",
"After months of want and hunger, we suddenly found ourselves able to have meals fit for the gods, and... | code_fim | hard | {
"lang": "rust",
"repo": "mjhoy/overland",
"path": "/game/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mjhoy/overland path: /game/src/main.rs
extern crate sdl2;
use sdl2::pixels::Color;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::messagebox::*;
pub fn main() {
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let window ... | code_fim | hard | {
"lang": "rust",
"repo": "mjhoy/overland",
"path": "/game/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut price_source = MockPriceSource::new();
let price = Arc::new(atomic::AtomicU8::new(1));
price_source.expect_get_prices().returning({
let price = price.clone();
move |_| {
let price_ = price.clone();
Ok(hash_map! { TOKEN... | code_fim | hard | {
"lang": "rust",
"repo": "gnosis/dex-services",
"path": "/services-core/src/price_estimation/threaded_price_source.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnosis/dex-services path: /services-core/src/price_estimation/threaded_price_source.rs
use super::price_source::PriceSource;
use crate::models::TokenId;
use crate::token_info::TokenInfoFetching;
use anyhow::Result;
use async_std::{
sync::Mutex,
task::{self, JoinHandle},
};
use std::colle... | code_fim | hard | {
"lang": "rust",
"repo": "gnosis/dex-services",
"path": "/services-core/src/price_estimation/threaded_price_source.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ps = MockPriceSource::new();
ps.expect_get_prices().returning(|_| Ok(HashMap::new()));
let mut token_info_fetcher = MockTokenInfoFetching::new();
token_info_fetcher
.expect_all_ids()
.returning(|| Ok(TOKENS.to_vec()));
let (tps, han... | code_fim | hard | {
"lang": "rust",
"repo": "gnosis/dex-services",
"path": "/services-core/src/price_estimation/threaded_price_source.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apexys/Laserlogin path: /lib/sqlite-traits/src/db_object.rs
use rusqlite::{NO_PARAMS, ToSql, params};
use smallvec::SmallVec;
use std::error::Error;
use crate::{Persistence, Query, SqlObject};
pub trait DbObject: SqlObject{
fn initialize() ->Result<(), Box<dyn Error>>;
fn save(&mut self... | code_fim | hard | {
"lang": "rust",
"repo": "apexys/Laserlogin",
"path": "/lib/sqlite-traits/src/db_object.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn delete(&mut self) ->Result<(), Box<dyn Error>> {
if let Some(id) = self.get_id(){ //No id == not in database
let mut query = "DELETE FROM ".to_string();
query.push_str(T::get_table_name());
query.push_str(" WHERE id = ?");
let connection = Per... | code_fim | hard | {
"lang": "rust",
"repo": "apexys/Laserlogin",
"path": "/lib/sqlite-traits/src/db_object.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(id) = self.get_id(){
let mut query = "UPDATE ".to_string();
query.push_str(T::get_table_name());
query.push_str(" SET ");
let mut values: SmallVec<[&dyn ToSql; 10]> = SmallVec::new();
for (index, (column, value)) in self.field... | code_fim | hard | {
"lang": "rust",
"repo": "apexys/Laserlogin",
"path": "/lib/sqlite-traits/src/db_object.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Device: {:?}", adapter.get_info());
panic!("Deliberate panic");
}<|fim_prefix|>// repo: Aaron1011/wgpu-panic path: /src/main.rs
use futures::executor::block_on;
fn main() {
<|fim_middle|> let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY);
let adapter = block_on(instanc... | code_fim | hard | {
"lang": "rust",
"repo": "Aaron1011/wgpu-panic",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aaron1011/wgpu-panic path: /src/main.rs
use futures::executor::block_on;
fn main() {
<|fim_suffix|> println!("Device: {:?}", adapter.get_info());
panic!("Deliberate panic");
}<|fim_middle|> let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY);
let adapter = block_on(instanc... | code_fim | hard | {
"lang": "rust",
"repo": "Aaron1011/wgpu-panic",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>named!(#[doc = "Line endings are different for xref records to preserve alignment \
(\\r and \\n are preceeded by ` `)"],
pub xref_eol,
alt!(tag!(b" \r") | tag!(b" \n") | tag!(b"\r\n")));
/// Takes a byte array and returns an escaped string of ascii
#[cfg(test)]
pub fn u8_to... | code_fim | hard | {
"lang": "rust",
"repo": "derekdreery/pdf",
"path": "/pdf-par-ser/src/util.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: derekdreery/pdf path: /pdf-par-ser/src/util.rs
//! Utility functions used elsewhere
//!
//! This is a bit of a mess of jumbled up functionality
//use num;
use nom;
macro_rules! pdf_ws (
($i:expr, $($args:tt)*) => {{
use $crate::util::eat_pdf_ws;
sep!($i, eat_pdf_ws, $($args)... | code_fim | hard | {
"lang": "rust",
"repo": "derekdreery/pdf",
"path": "/pdf-par-ser/src/util.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_oct_arr3() {
let input = vec![
[b'3', b'7', b'7'],
[b'0', b'0', b'1'],
[b'0', b'0', b'0'],
];
for input in input {
assert_eq!(oct_to_arr3(arr3_to_oct(&input)), input);
}
// case with overflow
assert_eq!(oct_to_arr3(arr3_to_oct(&[b'7',... | code_fim | hard | {
"lang": "rust",
"repo": "derekdreery/pdf",
"path": "/pdf-par-ser/src/util.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/rust-optee-trustzone-sdk path: /optee-utee/src/object.rs
ent: raw::content {
memref: raw::Memref {
buffer: 0 as *mut _,
size: 0,
},
},
};
Self { raw }
}
pub fn new_value() -> Self... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/rust-optee-trustzone-sdk",
"path": "/optee-utee/src/object.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn write(&mut self, buf: &[u8]) -> Result<()> {
self.0.write(buf)
}
pub fn truncate(&self, size: u32) -> Result<()> {
self.0.truncate(size)
}
pub fn seek(&self, offset: i32, whence: Whence) -> Result<()> {
self.0.seek(offset, whence)
}
}
impl Drop for... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/rust-optee-trustzone-sdk",
"path": "/optee-utee/src/object.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/rust-optee-trustzone-sdk path: /optee-utee/src/object.rs
Self {
let raw = raw::TEE_Attribute {
attributeID: 0,
content: raw::content {
value: raw::Value { a: 0, b: 0 },
},
};
Self { raw }
}
pub fn from_... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/rust-optee-trustzone-sdk",
"path": "/optee-utee/src/object.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgouly/keyboard-app path: /src/matrix.rs
pub trait Matrix {
type T;
fn new() -> Self;
fn get(&self, row: usize, col: usize) -> Self::T;
fn put(&mut self, row: usize, col: usize, val: Self::T);
fn get_num_rows(&self) -> usize;
fn get_num_columns(&self) -> usize;
}
#[macro_export]
mac... | code_fim | medium | {
"lang": "rust",
"repo": "jgouly/keyboard-app",
"path": "/src/matrix.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
}
#[cfg(test)]
mod tests {
use matrix::Matrix;
#[test]
fn basic() {
gen_matrix!(Matrix2x3, 2, 3, u32);
let m = Matrix2x3::new_with_data([0, 1, 2, 3, 4, 5]);
assert_eq!(0, m.get(0, 0));
assert_eq!(1, m.get(0, 1));
assert_eq!(4, m.get(1, 1));
assert_eq!(5, m.get(1, 2... | code_fim | hard | {
"lang": "rust",
"repo": "jgouly/keyboard-app",
"path": "/src/matrix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c = self.get_num_columns();
self.data[col + (row * c)] = val;
}
fn get_num_rows(&self) -> usize { $rows }
fn get_num_columns(&self) -> usize { $cols }
}
}
}
#[cfg(test)]
mod tests {
use matrix::Matrix;
#[test]
fn basic() {
gen_matrix!(Matrix2x3, 2, 3,... | code_fim | hard | {
"lang": "rust",
"repo": "jgouly/keyboard-app",
"path": "/src/matrix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dakongyi2014/aiot-rust path: /examples/dynregmq-basic.rs
use aiot::DynamicRegister;
use anyhow::Result;
use log::*;
<|fim_suffix|> let reg = DynamicRegister::new_tls(&host, &product_key, &product_secret, &device_name)?;
let res = reg.register().await?;
info!("{:?}", res);
Ok(())... | code_fim | hard | {
"lang": "rust",
"repo": "dakongyi2014/aiot-rust",
"path": "/examples/dynregmq-basic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let reg = DynamicRegister::new_tls(&host, &product_key, &product_secret, &device_name)?;
let res = reg.register().await?;
info!("{:?}", res);
Ok(())
}<|fim_prefix|>// repo: dakongyi2014/aiot-rust path: /examples/dynregmq-basic.rs
use aiot::DynamicRegister;
use anyhow::Result;
use log::*;... | code_fim | hard | {
"lang": "rust",
"repo": "dakongyi2014/aiot-rust",
"path": "/examples/dynregmq-basic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pgarg-ripple/interledger-rs path: /crates/interledger-settlement-engines/tests/eth_engine_integration_tests/ganache_tests.rs
use mockito;
use serde_json::json;
use std::collections::HashMap;
use std::time::Duration;
use web3::contract::{Contract, Options};
use web3::{api::Web3, futures::future::... | code_fim | hard | {
"lang": "rust",
"repo": "pgarg-ripple/interledger-rs",
"path": "/crates/interledger-settlement-engines/tests/eth_engine_integration_tests/ganache_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let alice_store = test_store(ALICE.clone(), false, false, true);
alice_store
.save_account_addresses(HashMap::from_iter(vec![(
"0".to_string(),
Addresses {
own_address: bob.address,
token_address: None,
},
)]))
... | code_fim | hard | {
"lang": "rust",
"repo": "pgarg-ripple/interledger-rs",
"path": "/crates/interledger-settlement-engines/tests/eth_engine_integration_tests/ganache_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MissaDavid/rusty path: /src/variables.rs
/*
Variables are immutable by default
Use `let` keyword to define a variable (JS devs, this is a `const` equivalent)
*/
<|fim_suffix|> println!("Hello, I am {} the {}", mascot, animal);
// animal = "rustacean"
// println!("Hello, I am {} the... | code_fim | medium | {
"lang": "rust",
"repo": "MissaDavid/rusty",
"path": "/src/variables.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* const keyword exists but not used as much */
// const OFFICIAL: bool = false;
}<|fim_prefix|>// repo: MissaDavid/rusty path: /src/variables.rs
/*
Variables are immutable by default
Use `let` keyword to define a variable (JS devs, this is a `const` equivalent)
*/
// snake_case for function n... | code_fim | medium | {
"lang": "rust",
"repo": "MissaDavid/rusty",
"path": "/src/variables.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iLifetruth/ref-contracts path: /ref-exchange/tests/test_account_upgrade.rs
use near_sdk::json_types::U128;
use near_sdk_sim::{call, to_yocto, ContractAccount, UserAccount};
use ref_exchange::{ContractContract as Exchange, SwapAction};
use test_token::ContractContract as TestToken;
near_sdk_sim... | code_fim | hard | {
"lang": "rust",
"repo": "iLifetruth/ref-contracts",
"path": "/ref-exchange/tests/test_account_upgrade.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(get_deposits(&pool,
user.valid_account_id())
.get(&token3.account_id()).unwrap().0, to_yocto("4"));
}
#[test]
fn account_upgrade_not_enough_storage() {
let (_, owner, pool, token1, token2, _, user) = prepare_old_user();
// Upgrade to the new version.
owner.ca... | code_fim | hard | {
"lang": "rust",
"repo": "iLifetruth/ref-contracts",
"path": "/ref-exchange/tests/test_account_upgrade.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xcaptain/rust-algorithms path: /leetcode/src/p258.rs
// https://leetcode-cn.com/problems/add-digits/
pub fn add_digits(num: i32) -> i32 {
let mut res = num;
while res >= 10 {
let mut p = res;
let mut s = 0;
while p > 0 {
let q = p % 10;
s ... | code_fim | hard | {
"lang": "rust",
"repo": "xcaptain/rust-algorithms",
"path": "/leetcode/src/p258.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(1, add_digits_recursive(10));
assert_eq!(1, add_digits(10));
}
}<|fim_prefix|>// repo: xcaptain/rust-algorithms path: /leetcode/src/p258.rs
// https://leetcode-cn.com/problems/add-digits/
pub fn add_digits(num: i32) -> i32 {
let mut res = num;
while res >= 10 {
... | code_fim | medium | {
"lang": "rust",
"repo": "xcaptain/rust-algorithms",
"path": "/leetcode/src/p258.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LyricTian/qdrant path: /lib/collection/src/collection_manager/mod.rs
pub mod collection_managers;
pub mod holders;
pub mod optimizers;
pub mod simple_collection_searcher;
pub mod simple_collection_updater;
<|fim_suffix|>#[cfg(test)]
mod tests;<|fim_middle|>mod segments_updater;
#[allow(dead_co... | code_fim | easy | {
"lang": "rust",
"repo": "LyricTian/qdrant",
"path": "/lib/collection/src/collection_manager/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
mod fixtures;
#[cfg(test)]
mod tests;<|fim_prefix|>// repo: LyricTian/qdrant path: /lib/collection/src/collection_manager/mod.rs
pub mod collection_managers;
pub mod holders;
pub mod optimizers;
pub mod simple_collection_searcher;
pub mod simple_collection_updater;
<|fim_middle|>mod... | code_fim | easy | {
"lang": "rust",
"repo": "LyricTian/qdrant",
"path": "/lib/collection/src/collection_manager/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> result
}
pub fn width(&self, repeats: usize) -> usize {
self.risk_levels[0].len() * repeats
}
pub fn height(&self, repeats: usize) -> usize {
self.risk_levels.len() * repeats
}
}<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2021/day15/src/grid.rs
... | code_fim | medium | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2021/day15/src/grid.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Grid {
pub fn risk_level(&self, (x, y): (usize, usize)) -> usize {
let x_tile = x / self.risk_levels[0].len();
let y_tile = y / self.risk_levels.len();
let raw_pos = self.risk_levels[y % self.risk_levels.len()][x % self.risk_levels[0].len()];
(raw_pos + x_tile + ... | code_fim | medium | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2021/day15/src/grid.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2021/day15/src/grid.rs
use std::convert::Infallible;
use std::str::FromStr;
#[derive(Debug)]
pub struct Grid {
risk_levels: Vec<Vec<usize>>,
}
impl FromStr for Grid {
type Err = Infallible;
<|fim_suffix|> if x < (self.risk_levels[0].len() * re... | code_fim | hard | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2021/day15/src/grid.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gordon-F/miniquad path: /native/sapp-linux/src/xi_input.rs
use crate::_sapp_x11_display;
use crate::x::{Display, Window, _XPrivDisplay};
pub const XIAllDevices: libc::c_int = 0 as libc::c_int;
pub const XI_RawMotion: libc::c_int = 17 as libc::c_int;
pub const XI_RawMotionMask: libc::c_int = (1... | code_fim | hard | {
"lang": "rust",
"repo": "Gordon-F/miniquad",
"path": "/native/sapp-linux/src/xi_input.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // select events to listen
let mut mask = XI_RawMotionMask;
let mut masks = XIEventMask {
deviceid: XIAllDevices,
mask_len: ::std::mem::size_of::<libc::c_int>() as _,
mask: &mut mask as *mut _ as *mut _,
};
XISelectEvents(
_sapp_x11_display,
// t... | code_fim | hard | {
"lang": "rust",
"repo": "Gordon-F/miniquad",
"path": "/native/sapp-linux/src/xi_input.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oblique/aoc-2020 path: /src/bin/day02b.rs
use anyhow::Result;
use aoc_2020::file_lines;
use std::str::FromStr;
struct PassPolicy {
allowed_pos: Vec<usize>,
letter: char,
}
impl PassPolicy {
fn parse(s: &str) -> Option<Self> {
let mut x = s.splitn(2, ' ');
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "oblique/aoc-2020",
"path": "/src/bin/day02b.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (policy, pass) in lines.filter_map(to_policy_and_pass) {
if policy.valid_password(&pass) {
valid_pass += 1;
}
}
println!("{}", valid_pass);
Ok(())
}<|fim_prefix|>// repo: oblique/aoc-2020 path: /src/bin/day02b.rs
use anyhow::Result;
use aoc_2020::file_lin... | code_fim | hard | {
"lang": "rust",
"repo": "oblique/aoc-2020",
"path": "/src/bin/day02b.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sdroege/cookie-factory path: /tests/combinators-json.rs
extern crate cookie_factory;
#[macro_use]
extern crate maplit;
#[path="./json/mod.rs"] mod implementation;
use implementation::*;
<|fim_suffix|> let mut buffer = repeat(0).take(16384).collect::<Vec<u8>>();
let ptr = {
let mut sr = ... | code_fim | hard | {
"lang": "rust",
"repo": "sdroege/cookie-factory",
"path": "/tests/combinators-json.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let index = ptr - (&buffer[..]).as_ptr() as usize;
println!("result:\n{}", str::from_utf8(&buffer[..index]).unwrap());
assert_eq!(str::from_utf8(&buffer[..index]).unwrap(),
"{\"arr\":[1234.56,1234.56,1234.56],\"b\":true,\"o\":{\"empty\":[],\"x\":\"abcd\",\"y\":\"efgh\"}}");
}<|fim_prefix|>// re... | code_fim | hard | {
"lang": "rust",
"repo": "sdroege/cookie-factory",
"path": "/tests/combinators-json.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::str;
use std::iter::repeat;
let value = JsonValue::Object(btreemap!{
String::from("arr") => JsonValue::Array(vec![JsonValue::Num(1.0), JsonValue::Num(12.3), JsonValue::Num(42.0)]),
String::from("b") => JsonValue::Boolean(true),
String::from("o") => JsonValue::Object(btreemap!{
... | code_fim | medium | {
"lang": "rust",
"repo": "sdroege/cookie-factory",
"path": "/tests/combinators-json.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
#[doc = "Reader of field `EDSEL`"]
pub type EDSEL_R = crate::R<u8, EDSEL_A>;
impl EDSEL_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> EDSEL_A {
match self.bits {
0 => EDSEL_A::OFF,
1 => EDSEL_A::POSEDGE,
... | code_fim | hard | {
"lang": "rust",
"repo": "timokroeger/efm32pg12-pac",
"path": "/src/prs/ch7_ctrl.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn none(self) -> &'a mut W {
self.variant(SOURCESEL_A::NONE)
}
#[doc = "Peripheral Reflex System"]
#[inline(always)]
pub fn prsl(self) -> &'a mut W {
self.variant(SOURCESEL_A::PRSL)
}
#[doc = "Peripheral Reflex System"]
#[inline(always)]
pub fn prsh... | code_fim | hard | {
"lang": "rust",
"repo": "timokroeger/efm32pg12-pac",
"path": "/src/prs/ch7_ctrl.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: timokroeger/efm32pg12-pac path: /src/prs/ch7_ctrl.rs
,
63 => Val(SOURCESEL_A::WTIMER1),
67 => Val(SOURCESEL_A::CM4),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `NONE`"]
#[inline(always)]
pub fn is_none(&self) -> bool ... | code_fim | hard | {
"lang": "rust",
"repo": "timokroeger/efm32pg12-pac",
"path": "/src/prs/ch7_ctrl.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use canvas::{CanvasData, Paste};
pub use clipboard::{get_image_from_clipboard, put_image_to_clipboard, ClipboardError};
pub use edit::{Edit, EditDesc, UndoHistory};
pub use paintable::Paintable;
pub use selections::Selection;
pub mod lens;<|fim_prefix|>// repo: kindlychung/paintr path: /crates/paint... | code_fim | medium | {
"lang": "rust",
"repo": "kindlychung/paintr",
"path": "/crates/paintr/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kindlychung/paintr path: /crates/paintr/src/lib.rs
#[macro_export]
macro_rules! impl_from {
($trait:ident : [$($from:ty => $to:ident ),*] ) => {
$(
impl From<$from> for $trait {
fn from(f: $from) -> $trait {
$trait::$to(f)
... | code_fim | medium | {
"lang": "rust",
"repo": "kindlychung/paintr",
"path": "/crates/paintr/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize)]
pub(crate) struct OWResponse {
main: Stats,
weather: Vec<Weather>,
coord: Coord,
name: String,
base: String,
visibility: u64,
wind: Wind,
clouds: Clouds,
dt: u64,
sys: Sys,
timezone: i64,
id: u64,
cod: u64,
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "mattjperez/tenki",
"path": "/src/openweather.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattjperez/tenki path: /src/openweather.rs
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub(crate) struct Stats {
temp: f32,
feels_like: f32,
temp_max: f32,
temp_min: f32,
pressure: u32,
humidity: u32,
}
#[derive(Debug, Deserialize)]
pub(crate) struct Weather {... | code_fim | hard | {
"lang": "rust",
"repo": "mattjperez/tenki",
"path": "/src/openweather.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize)]
pub(crate) struct Clouds {
all: u16,
}
#[derive(Debug, Deserialize)]
pub(crate) struct OWResponse {
main: Stats,
weather: Vec<Weather>,
coord: Coord,
name: String,
base: String,
visibility: u64,
wind: Wind,
clouds: Clouds,
dt: u64,
... | code_fim | medium | {
"lang": "rust",
"repo": "mattjperez/tenki",
"path": "/src/openweather.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ermiya13277/libra path: /vm-validator/src/vm_validator.rs
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use anyhow::Result;
use libra_config::config::NodeConfig;
use libra_types::{
account_address::AccountAddress, account_config::AccountResource,
tr... | code_fim | hard | {
"lang": "rust",
"repo": "Ermiya13277/libra",
"path": "/vm-validator/src/vm_validator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
} else if let Some(_a_path) = opts.recover {
// just create recovery file
return Ok(())
} else if opts.daemon {
// start the live fork daemon
return Ok(())
} else if opts.swarm {
// Write swarm genesis from snapshot, for CI and simulation
... | code_fim | hard | {
"lang": "rust",
"repo": "VenkatTeja/libra",
"path": "/ol/genesis-tools/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> } else if let Some(_a_path) = opts.recover {
// just create recovery file
return Ok(())
} else if opts.daemon {
// start the live fork daemon
return Ok(())
} else if opts.swarm {
// Write swarm genesis from snapshot, for CI and simulation
... | code_fim | hard | {
"lang": "rust",
"repo": "VenkatTeja/libra",
"path": "/ol/genesis-tools/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VenkatTeja/libra path: /ol/genesis-tools/src/main.rs
use std::{path::PathBuf, process::exit};
use anyhow::Result;
use gumdrop::Options;
use ol_genesis_tools::{fork_genesis::make_recovery_genesis, swarm_genesis::make_swarm_genesis};
#[tokio::main]
async fn main() -> Result<()> {
#[derive(D... | code_fim | hard | {
"lang": "rust",
"repo": "VenkatTeja/libra",
"path": "/ol/genesis-tools/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
pub struct RectangleGrid<'a> {
rectangles: &'a [Tile],
small_files_coordinates: Option<(u16, u16)>,
selected_rect_index: Option<usize>,
}
impl<'a> RectangleGrid<'a> {
pub fn new(
rectangles: &'a [Tile],
small_files_coordinates: Option<(u16, u16)>,
... | code_fim | hard | {
"lang": "rust",
"repo": "imsnif/diskonaut",
"path": "/src/ui/grid/rectangle_grid.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imsnif/diskonaut path: /src/ui/grid/rectangle_grid.rs
use ::tui::buffer::Buffer;
use ::tui::layout::Rect;
use ::tui::style::{Color, Style};
use ::tui::widgets::Widget;
use crate::state::tiles::Tile;
use crate::ui::grid::{draw_rect_on_grid, draw_tile_text_on_grid};
fn draw_small_files_rect_on_g... | code_fim | hard | {
"lang": "rust",
"repo": "imsnif/diskonaut",
"path": "/src/ui/grid/rectangle_grid.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Widget for RectangleGrid<'a> {
fn render(self, area: Rect, buf: &mut Buffer) {
if self.rectangles.is_empty() {
draw_empty_folder(buf, area);
} else {
for (index, tile) in self.rectangles.iter().enumerate() {
let selected = if let Some(se... | code_fim | hard | {
"lang": "rust",
"repo": "imsnif/diskonaut",
"path": "/src/ui/grid/rectangle_grid.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> HttpResponse::Ok().content_type("text/plain").body(
data.providers()
.map(|p| format!("{}\n", p.domain()))
.collect::<Vec<_>>()
.join(""),
),
)
}<|fim_prefix|>// repo: fnichol/artifetch path: /src/app/handlers/providers.rs
use ... | code_fim | medium | {
"lang": "rust",
"repo": "fnichol/artifetch",
"path": "/src/app/handlers/providers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fnichol/artifetch path: /src/app/handlers/providers.rs
use crate::app;
use actix_web::{web, Error, HttpResponse};
use futures::{future, Future};
pub fn get_providers<|fim_suffix|> format!("{}\n", p.domain()))
.collect::<Vec<_>>()
.join(""),
),
)
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "fnichol/artifetch",
"path": "/src/app/handlers/providers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LLFourn/lindy path: /src/p2p/event.rs
use crate::PeerId;
use futures::channel::mpsc;
use futures::channel::mpsc::UnboundedSender;
use futures::channel::oneshot;
use futures::Future;
use futures::Sink;
use futures::SinkExt;
use futures::Stream;
use futures::StreamExt;
use std::collections::HashMa... | code_fim | hard | {
"lang": "rust",
"repo": "LLFourn/lindy",
"path": "/src/p2p/event.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type Notifier = oneshot::Sender<Result<(), conn::Error>>;
enum ConnectState<M> {
Connected(mpsc::UnboundedSender<(M, Option<Notifier>)>),
Connecting {
notify_on_connect: Vec<Notifier>,
pending_messages: Vec<(M, Option<Notifier>)>,
},
}
impl<M> Default for ConnectState<M> ... | code_fim | hard | {
"lang": "rust",
"repo": "LLFourn/lindy",
"path": "/src/p2p/event.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>onst TT_API: &str = "http://tt.chadsoft.co.uk/index.json";<|fim_prefix|>// repo: y21/wrnotifier path: /src/constants.rs
pub const DATABASE_PATH_RAW: &str = "database.sqlite";
pub<|fim_middle|> const DATABASE_PATH: &str = "file:database.sqlite";
pub const TT_API_BASE: &str = "http://tt.chadsoft.co.uk";
pu... | code_fim | medium | {
"lang": "rust",
"repo": "y21/wrnotifier",
"path": "/src/constants.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: y21/wrnotifier path: /src/constants.rs
pub const DATABASE_PATH_RAW: &str = "database.sqlite";
pub<|fim_suffix|>onst TT_API: &str = "http://tt.chadsoft.co.uk/index.json";<|fim_middle|> const DATABASE_PATH: &str = "file:database.sqlite";
pub const TT_API_BASE: &str = "http://tt.chadsoft.co.uk";
pu... | code_fim | medium | {
"lang": "rust",
"repo": "y21/wrnotifier",
"path": "/src/constants.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
Assets,
Liabilities,
Equity,
Income,
Expenses,
}<|fim_prefix|>// repo: fanninpm/beancount path: /beancount-core/src/account_types.rs
/// Allowed account types.
///
/// <https://docs.google.com/document/d<|fim_middle|>/1wAMVrKIA2qtRGmoVDSUBJGmYZSygUaR0uOMW1GV3YE0/edit#heading=h.17ry... | code_fim | medium | {
"lang": "rust",
"repo": "fanninpm/beancount",
"path": "/beancount-core/src/account_types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fanninpm/beancount path: /beancount-core/src/account_types.rs
/// Allowed account types.
///
/// <https://docs.google.com/document/d<|fim_suffix|>uiu>
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum AccountType {
Assets,
Liabilities,
Equity,
Income,
Expenses,
}<|fim_mid... | code_fim | medium | {
"lang": "rust",
"repo": "fanninpm/beancount",
"path": "/beancount-core/src/account_types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lcdr/endio path: /src/write.rs
use std::io::Write;
use std::io::Result as Res;
use crate::{BigEndian, Endianness, LittleEndian, Serialize};
/**
Only necessary for custom (de-)serializations.
Interface for writing data with a specified endianness. Use this interface to make serializations au... | code_fim | hard | {
"lang": "rust",
"repo": "lcdr/endio",
"path": "/src/write.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut writer = vec![];
writer.write(42u8);
writer.write(true);
writer.write(754187983u32);
assert_eq!(writer, b"\x2a\x01\xcf\xfe\xf3\x2c");
```
*/
pub trait EWrite<E: Endianness>: Sized { // todo[supertrait item shadowing]: make Write a supertrait of this
/**
Writes a `Serialize` to the writer... | code_fim | hard | {
"lang": "rust",
"repo": "lcdr/endio",
"path": "/src/write.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.