text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> match output {
Ok(x) => {
println!("{}", x);
exit(0)
}
Err(x) => {
eprintln!("{}", x);
exit(127)
}
}
}
fn main() {
let args = cli().get_matches_safe();
match args {
Ok(matches) => {
if let ... | code_fim | hard | {
"lang": "rust",
"repo": "fvhockney/warp-drive",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jypkkjj/rustrade path: /src/utils/log_utils.rs
use chrono::Local;
use colored::*;
use lazy_static::lazy_static;
use log::LevelFilter;
use std::io::Write;
use std::mem;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::{io, sync::Mutex};
use termcolor::{ColorChoice, StandardStream};
lazy_... | code_fim | hard | {
"lang": "rust",
"repo": "jypkkjj/rustrade",
"path": "/src/utils/log_utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A simple logger
pub struct Logger;
impl Logger {
fn get_actual_level(&self, metadata: &log::Metadata<'_>) -> log::Level {
let mut level = metadata.level();
if level == log::Level::Debug && (metadata.target() == "tokio_reactor" || metadata.target().starts_with("hyper::proto::")) {
... | code_fim | hard | {
"lang": "rust",
"repo": "jypkkjj/rustrade",
"path": "/src/utils/log_utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::test]
async fn test_async_lookup_data() {
let service = TestServiceImpl;
use test_schema::TestService;
let service_impl = service.serve();
let async_handler = AsyncTestServiceServer {
inner: service_impl,
};
let mut client = test_schema::TestServiceAsyncClient::new... | code_fim | hard | {
"lang": "rust",
"repo": "rbehjati/oak",
"path": "/oak_idl_tests/tests/test_schema.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rbehjati/oak path: /oak_idl_tests/tests/test_schema.rs
// Copyright 2022 The Project Oak Authors
//
// 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://w... | code_fim | hard | {
"lang": "rust",
"repo": "rbehjati/oak",
"path": "/oak_idl_tests/tests/test_schema.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
request: &test_schema::LogRequest,
) -> Result<oak_idl::utils::OwnedFlatbuffer<test_schema::LogResponse>, oak_idl::Status> {
eprintln!("log: {}", request.entry().unwrap());
let mut b = oak_idl::utils::OwnedFlatbufferBuilder::default();
let flatbuffer ... | code_fim | hard | {
"lang": "rust",
"repo": "rbehjati/oak",
"path": "/oak_idl_tests/tests/test_schema.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/**
* Adds an entry to the <TABLE_BLACKBOX_UNREGISTERED>.
* If a row already exists with the same client_id, a new one isn't added.
* Returns true if successful.
*/
pub fn add_to_unregistered_table(
client_id: &str,
elements_summary: &str,
db_pool: Pool<PostgresConnectionManager<NoTls>>,
)... | code_fim | hard | {
"lang": "rust",
"repo": "SyStem-5/LSOC-BlackBox",
"path": "/src/db_manager/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = conn.execute(query.as_str(), &[&client_id, &elements_summary]);
match res {
Ok(res) => {
if res > 0 {
debug!(
"Unregistered node listed. Client_id: {} Elements_Summary: {}",
&client_id, &elements_summary
... | code_fim | hard | {
"lang": "rust",
"repo": "SyStem-5/LSOC-BlackBox",
"path": "/src/db_manager/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SyStem-5/LSOC-BlackBox path: /src/db_manager/mod.rs
ute(comm.as_str(), &[]);
match query {
Ok(_) => true,
Err(e) => {
error!("Failed to create table {}. {}", TABLE_MQTT_USERS, e);
false
}
}
}
/**
* Generates <MYSQL_MQTT_ACL_TABLE>.
*/
f... | code_fim | hard | {
"lang": "rust",
"repo": "SyStem-5/LSOC-BlackBox",
"path": "/src/db_manager/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seikichi/icfpc2018 path: /nanobot/src/main.rs
mod ai;
mod common;
mod model;
mod state;
mod union_find;
use std::env;
use std::fs::File;
use std::io::BufReader;
use std::path::Path;
use std::process;
use ai::builder::*;
use ai::config::Config;
use common::write_trace_file;
use model::Model;
f... | code_fim | hard | {
"lang": "rust",
"repo": "seikichi/icfpc2018",
"path": "/nanobot/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> eprintln!(
"not enough arguments
Example:
$ {0} assemble target.mdl output_trace.nbt
$ {0} disassemble source.mdl output_trace.nbt
$ {0} reassemble source.mdl target.mdl output_trace.nbt
NOTE: Use following environment variables to configure AIs
## Required
GOLD_AI=default
## Op... | code_fim | hard | {
"lang": "rust",
"repo": "seikichi/icfpc2018",
"path": "/nanobot/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let trace_output_path = Path::new(&args[3]);
let config = Config::new();
let name = env::var("GOLD_AI").expect("failed to get AI from ENV");
let mut ai = build_disassembler(&name, &config, &source);
let commands = ai.disassemble(&source);
write_trace_file(trace_output_path, &comman... | code_fim | hard | {
"lang": "rust",
"repo": "seikichi/icfpc2018",
"path": "/nanobot/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Davier/bevy_prototype_widgets path: /src/widgets/label.rs
use super::Base;
use crate::{Widget, WidgetBuilder};
use bevy::prelude::*;
pub struct Label {
base: Base,
}
impl Label {
pub fn new(wb: &WidgetBuilder, label: &str) -> Self {
Self {
base: Base::spawn(wb).inse... | code_fim | hard | {
"lang": "rust",
"repo": "Davier/bevy_prototype_widgets",
"path": "/src/widgets/label.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_font_color(self, color: Color) -> Self {
self.get_mut(|text: &mut Text| {
text.sections[0].style.color = color;
})
}
}
impl Widget for Label {
fn builder(&self) -> &WidgetBuilder {
self.base.builder()
}
fn root_id(&self) -> Entity {
... | code_fim | hard | {
"lang": "rust",
"repo": "Davier/bevy_prototype_widgets",
"path": "/src/widgets/label.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nikolads/fmi-projects path: /parallel_dfs_v1/src/dfs/threaded.rs
extern crate bit_vec;
use self::bit_vec::BitVec;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use std::sync::mpsc::{self, Sender};
use std::usize;
use graph::Graph;
use thread_p... | code_fim | hard | {
"lang": "rust",
"repo": "nikolads/fmi-projects",
"path": "/parallel_dfs_v1/src/dfs/threaded.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pool.lock().unwrap().spawn(move || spawner(state, next_root, pool_clone, answ_tx));
break;
}
}
task_main(state, root, answ_tx);
}
struct Owned<G: Graph + Send + Sync + 'static> {
root: usize,
data: BitVec,
state: Arc<Inner<G>>,
}
impl<G: Graph + Send ... | code_fim | hard | {
"lang": "rust",
"repo": "nikolads/fmi-projects",
"path": "/parallel_dfs_v1/src/dfs/threaded.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ianProductIter;
pub use join_iter::Join;
pub use set_partition::SetPartitions;
pub use step::{Bounded, Range, Step};
pub use storage_int::StorageInt;
pub use vec_set::VecSet;<|fim_prefix|>// repo: declanvk/regular path: /src/util.rs
mod bit_set;
mod cartesian_product;
mod join_iter;
mod set_partition;
mo... | code_fim | medium | {
"lang": "rust",
"repo": "declanvk/regular",
"path": "/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: declanvk/regular path: /src/util.rs
mod bit_set;
mod cartesian_product;
mod join_iter;
mod set_partition;
mod step;
mod storage_int;
mod vec_set;
pub use bit_set::FixedBitSet;
pub use cartesian_product::Cartes<|fim_suffix|>step::{Bounded, Range, Step};
pub use storage_int::StorageInt;
pub use v... | code_fim | medium | {
"lang": "rust",
"repo": "declanvk/regular",
"path": "/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: delewit/rust path: /src/libcoretest/ops.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apac... | code_fim | medium | {
"lang": "rust",
"repo": "delewit/rust",
"path": "/src/libcoretest/ops.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = Range { start: 2, end: 10 };
let mut count = 0;
for (i, ri) in r.enumerate() {
assert!(ri == i + 2);
assert!(ri >= 2 && ri < 10);
count += 1;
}
assert!(count == 8);
}
#[test]
fn test_range_from() {
let r = RangeFrom { start: 2 };
let mut count =... | code_fim | medium | {
"lang": "rust",
"repo": "delewit/rust",
"path": "/src/libcoretest/ops.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: layog/advent-of-code path: /2020/9_1.rs
use std::collections::HashSet;
use std::io::Read;
fn check(nums: &[i128], val: i128) -> bool {
<|fim_suffix|> let nums: Vec<i128> = buffer
.trim()
.split('\n')
.map(|x| x.parse().unwrap())
.collect();
let preamble =... | code_fim | hard | {
"lang": "rust",
"repo": "layog/advent-of-code",
"path": "/2020/9_1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
/// A graph construction (id) adapter, to construct a graph with additional id mapping.
///
/// For alogrithmic performance reasons, [`Graph`] requires that node ids are [`Copy`].
/// However that is not always the case.
/// [`GraphAdapter`] hence allows you to construct a graph, by providing a st... | code_fim | hard | {
"lang": "rust",
"repo": "WFBFA/SNOMOR",
"path": "/Real_case/Paths/src/graph.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WFBFA/SNOMOR path: /Real_case/Paths/src/graph.rs
fn is_orphan(&self, n: NId) -> bool {
self.get_edges(n).is_empty()
}
/// Get all edges between 2 nodes
pub fn get_edges_between(&self, n1: NId, n2: NId) -> Vec<&E> {
self.edges.get(&n1).iter().flat_map(|es| es.iter()).filter(|e| e.other(n1)... | code_fim | hard | {
"lang": "rust",
"repo": "WFBFA/SNOMOR",
"path": "/Real_case/Paths/src/graph.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WFBFA/SNOMOR path: /Real_case/Paths/src/graph.rs
pe Parameters:
/// - `DIRESPECT`: whether the directionality of the edge is respected
fn is_outgoing<const DIRESPECT: bool>(&self, id: NId) -> bool {
id == self.p1() || (id == self.p2() && (!DIRESPECT || !self.directed()))
}
}
/// A graph
//... | code_fim | hard | {
"lang": "rust",
"repo": "WFBFA/SNOMOR",
"path": "/Real_case/Paths/src/graph.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "metrics")]
let labels: [&str; 2] = [&data.method, &data.path];
#[cfg(feature = "metrics")]
RATELIMIT_LATENCY
.get_metric_with_label_values(&labels)?
.observe(latency.as_secs_f64());
message.ack().await?;
let (req, bucket) = claim?;
#[cfg(feature = "metrics")]
REQU... | code_fim | hard | {
"lang": "rust",
"repo": "sussyballsuwu/proxy",
"path": "/src/runtime/client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sussyballsuwu/proxy path: /src/runtime/client.rs
#[cfg(feature = "metrics")]
use crate::metrics::{RATELIMIT_LATENCY, REQUESTS_TOTAL, REQUEST_LATENCY, RESPONSES_TOTAL};
use crate::{
models::{RequestResponse, SerializableHttpRequest, SerializableHttpResponse},
ratelimiter::Ratelimiter,
route::m... | code_fim | hard | {
"lang": "rust",
"repo": "sussyballsuwu/proxy",
"path": "/src/runtime/client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-osdev/apic path: /src/io_apic/mod.rs
use core::convert::TryInto;
use bit_field::BitField;
use volatile::Volatile;
pub mod values;
pub struct IoApicBase<'a> {
pub select: Volatile<&'a mut Select>,
pub window: Volatile<&'a mut u32>,
}
impl IoApicBase<'_> {
/// base address mus... | code_fim | hard | {
"lang": "rust",
"repo": "rust-osdev/apic",
"path": "/src/io_apic/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe fn offset<'a, T>(base_addr: *mut u8, offset: Offset) -> Volatile<&'a mut T> {
let ptr = Self::offset_ptr(base_addr, offset).cast();
Volatile::new(unsafe { &mut *ptr })
}
fn offset_ptr(base_addr: *mut u8, offset: Offset) -> *mut u8 {
base_addr.wrapping_add(offset... | code_fim | hard | {
"lang": "rust",
"repo": "rust-osdev/apic",
"path": "/src/io_apic/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NobodyNada/advent2020 path: /day3/src/part1.rs
use std::io::{self, BufRead};
pub fn run() {
// The horizontal position on the map.
let mut x_pos = 0;
let mut trees = 0;
let mut line_length: Option<usize> = None;
for line in io::stdin().lock().lines() {
let line = lin... | code_fim | medium | {
"lang": "rust",
"repo": "NobodyNada/advent2020",
"path": "/day3/src/part1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if line.as_bytes()[x_pos] == '#' as u8 { trees += 1; }
x_pos = (x_pos + 3) % line.len();
}
println!("{}", trees);
}<|fim_prefix|>// repo: NobodyNada/advent2020 path: /day3/src/part1.rs
use std::io::{self, BufRead};
pub fn run() {
// The horizontal position on the map.
let... | code_fim | medium | {
"lang": "rust",
"repo": "NobodyNada/advent2020",
"path": "/day3/src/part1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mut W,
}
impl<'a> FORCELDO_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r... | code_fim | hard | {
"lang": "rust",
"repo": "wgwoods/atsamd",
"path": "/pac/atsamd21j18a/src/sysctrl/vreg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wgwoods/atsamd path: /pac/atsamd21j18a/src/sysctrl/vreg.rs
#[doc = "Reader of register VREG"]
pub type R = crate::R<u16, super::VREG>;
#[doc = "Writer for register VREG"]
pub type W = crate::W<u16, super::VREG>;
#[doc = "Register VREG `reset()`'s with value 0"]
impl crate::ResetValue for super::... | code_fim | hard | {
"lang": "rust",
"repo": "wgwoods/atsamd",
"path": "/pac/atsamd21j18a/src/sysctrl/vreg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: noonebtw/coral-screenshot path: /src/screenshot.rs
use std::io::{Error, ErrorKind};
use image::{DynamicImage, ImageError, ImageResult};
use crate::{fb::FrameBufferBackend, traits::ScreenshotBackend, xlib::XLibState};
#[derive(Debug, Clone, Copy)]
pub enum Backend {
XLib,
FrameBuffer,
... | code_fim | medium | {
"lang": "rust",
"repo": "noonebtw/coral-screenshot",
"path": "/src/screenshot.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match name {
Some("fb") => Self::FrameBuffer,
Some("xlib") => Self::XLib,
_ => Self::Default,
}
}
}<|fim_prefix|>// repo: noonebtw/coral-screenshot path: /src/screenshot.rs
use std::io::{Error, ErrorKind};
use image::{DynamicImage, ImageError, Imag... | code_fim | hard | {
"lang": "rust",
"repo": "noonebtw/coral-screenshot",
"path": "/src/screenshot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> backend.screenshot(window)
}
impl From<Option<&str>> for Backend {
fn from(name: Option<&str>) -> Self {
match name {
Some("fb") => Self::FrameBuffer,
Some("xlib") => Self::XLib,
_ => Self::Default,
}
}
}<|fim_prefix|>// repo: noonebtw/coral... | code_fim | hard | {
"lang": "rust",
"repo": "noonebtw/coral-screenshot",
"path": "/src/screenshot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn remove(&mut self, key: String) -> Option<String> {
self.storage.remove(&key)
}
}<|fim_prefix|>// repo: manhtai/rust-plan path: /project-1/src/lib.rs
use std::collections::HashMap;
pub struct KvStore {
storage: HashMap<String, String>,
}
<|fim_middle|>impl KvStore {
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "manhtai/rust-plan",
"path": "/project-1/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: manhtai/rust-plan path: /project-1/src/lib.rs
use std::collections::HashMap;
pub struct KvStore {
storage: HashMap<String, String>,
}
impl KvStore {
pub fn new() -> Self {
let storage = HashMap::new();
KvStore { storage }
}
<|fim_suffix|> pub fn get(&self, key: ... | code_fim | medium | {
"lang": "rust",
"repo": "manhtai/rust-plan",
"path": "/project-1/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ethanpailes/iced path: /wgpu/src/widget/canvas/layer/cache.rs
use crate::{
canvas::{Drawable, Frame, Layer},
Primitive,
};
use iced_native::Size;
use std::{cell::RefCell, marker::PhantomData, sync::Arc};
enum State {
Empty,
Filled {
bounds: Size,
primitive: Arc<... | code_fim | hard | {
"lang": "rust",
"repo": "ethanpailes/iced",
"path": "/wgpu/src/widget/canvas/layer/cache.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T> Layer for Bind<'a, T>
where
T: Drawable + std::fmt::Debug,
{
fn draw(&self, current_bounds: Size) -> Arc<Primitive> {
use std::ops::Deref;
if let State::Filled { bounds, primitive } =
self.cache.state.borrow().deref()
{
if *bounds == cur... | code_fim | hard | {
"lang": "rust",
"repo": "ethanpailes/iced",
"path": "/wgpu/src/widget/canvas/layer/cache.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Emtrixx/raytracer_wasm path: /src/scene/helpers.rs
use glam::{Vec3};
use crate::scene::*;
//Ray
pub struct Ray {
pub origin: Vec3,
pub direction: Vec3,
}
<|fim_suffix|> Ray {
origin: Vec3::ZERO,
direction: Vec3::new(viewport_x, viewport_y, -1.0).normaliz... | code_fim | hard | {
"lang": "rust",
"repo": "Emtrixx/raytracer_wasm",
"path": "/src/scene/helpers.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Intersection
pub struct Intersection<'a> {
pub distance: f32,
pub element: &'a Element,
}
pub fn to_radians(x: f32) -> f32 {
x / 57.296
}<|fim_prefix|>// repo: Emtrixx/raytracer_wasm path: /src/scene/helpers.rs
use glam::{Vec3};
use crate::scene::*;
//Ray
pub struct Ray {
pub origin:... | code_fim | hard | {
"lang": "rust",
"repo": "Emtrixx/raytracer_wasm",
"path": "/src/scene/helpers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>m = num / 3;
vec![num, num + 1, num + 2]
}
}<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/medium/find_three_consecutive_integers_that_sum_to_a_given_number.rs
impl Solution {
pub fn sum_of_three(num: i64) -> Vec<i64> {
let num = num - 3;
if num % 3 !=<|fim_mi... | code_fim | easy | {
"lang": "rust",
"repo": "stackcats/leetcode",
"path": "/algorithms/medium/find_three_consecutive_integers_that_sum_to_a_given_number.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/medium/find_three_consecutive_integers_that_sum_to_a_given_number.rs
impl Solution {
pub fn sum_of_three(num: i64) -> Vec<|fim_suffix|> 0 {
return vec![];
}
let num = num / 3;
vec![num, num + 1, num + 2]
}
}<|fim_mi... | code_fim | easy | {
"lang": "rust",
"repo": "stackcats/leetcode",
"path": "/algorithms/medium/find_three_consecutive_integers_that_sum_to_a_given_number.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const MAX_SYMBOL_LEN: usize = 1024;
const_assert!(MAX_SYMBOL_LEN > MAX_FMT_INSTR_LEN);
#[rustfmt::skip]
let test_cases: [(u32, &'static [u8]); IcedConstants::MAX_OP_COUNT] = [
// op0: push 0FFFFFFFFA412A55Ah
(0, b"\x68\x5A\xA5\x12\xA4"),
// op1: mov rax,3412A55A37261504h
(1, b"\x48\xB8\x04\x1... | code_fim | medium | {
"lang": "rust",
"repo": "jogibear9988/iced",
"path": "/src/rust/iced-x86/src/formatter/fast/tests/symres.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jogibear9988/iced path: /src/rust/iced-x86/src/formatter/fast/tests/symres.rs
// SPDX-License-Identifier: MIT
// Copyright (C) 2018-present iced project and contributors
use static_assertions::const_assert;
use crate::formatter::fast::tests::fmt_factory::create_resolver;
use crate::formatter::... | code_fim | medium | {
"lang": "rust",
"repo": "jogibear9988/iced",
"path": "/src/rust/iced-x86/src/formatter/fast/tests/symres.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[rustfmt::skip]
let test_cases: [(u32, &'static [u8]); IcedConstants::MAX_OP_COUNT] = [
// op0: push 0FFFFFFFFA412A55Ah
(0, b"\x68\x5A\xA5\x12\xA4"),
// op1: mov rax,3412A55A37261504h
(1, b"\x48\xB8\x04\x15\x26\x37\x5A\xA5\x12\x34"),
// op2: imul ecx,esi,3412A55Ah
(2, b"\x69\xCE\x5A\xA5\x12... | code_fim | hard | {
"lang": "rust",
"repo": "jogibear9988/iced",
"path": "/src/rust/iced-x86/src/formatter/fast/tests/symres.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> DuplicationChecker::verify_module(&module).expect("DuplicationChecker failure");
SignatureChecker::verify_module(&module).expect("SignatureChecker failure");
InstructionConsistency::verify_module(&module).expect("InstructionConsistency failure");
constants::verify_module(&m... | code_fim | medium | {
"lang": "rust",
"repo": "rustielin/libra",
"path": "/language/bytecode-verifier/bytecode-verifier-tests/src/unit_tests/multi_pass_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustielin/libra path: /language/bytecode-verifier/bytecode-verifier-tests/src/unit_tests/multi_pass_tests.rs
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use bytecode_verifier::{
constants, instantiation_loops::InstantiationLoopChecker, DuplicationCheck... | code_fim | medium | {
"lang": "rust",
"repo": "rustielin/libra",
"path": "/language/bytecode-verifier/bytecode-verifier-tests/src/unit_tests/multi_pass_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn write_dictionaries<W>(registry: &Registry, dest: &mut W) -> io::Result<()>
where
W: io::Write,
{
for (name, dictionary) in registry.iter_types(NamedType::as_dictionary) {
write_dictionary(name, dictionary, registry, dest)?;
}
Ok(())
}
fn write_dictionary<W>(
name: &str,
... | code_fim | hard | {
"lang": "rust",
"repo": "SafariMonkey/gl-rs",
"path": "/webgl_generator/webgl_generators/stdweb_gen.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn process_result_type_kind(type_kind: &TypeKind, registry: &Registry) -> ProcessedResult {
match type_kind {
&TypeKind::Primitive(ref p) => ProcessedResult::simple(p.name()),
&TypeKind::String => ProcessedResult::simple("String"),
&TypeKind::ArrayBuffer | &TypeKind::ArrayBuffe... | code_fim | hard | {
"lang": "rust",
"repo": "SafariMonkey/gl-rs",
"path": "/webgl_generator/webgl_generators/stdweb_gen.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SafariMonkey/gl-rs path: /webgl_generator/webgl_generators/stdweb_gen.rs
&NamedType::Enum(_) => ProcessedArg::simple(name.unwrap()),
&NamedType::Typedef(ref t) => {
// We have to "look through" the typedef, as the correct parameter
... | code_fim | hard | {
"lang": "rust",
"repo": "SafariMonkey/gl-rs",
"path": "/webgl_generator/webgl_generators/stdweb_gen.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beautifularea/jlib-rs path: /src/base/wallet/config.rs
/*
base config
*/
use crate::WalletType;
//钱包属性:地址长度,加密算法等
#[derive(Debug, Copy, Clone)]
pub struct WalletConfig {
pub key_type: WalletType,
}
impl WalletConfig {
pub fn new(key_type: WalletType) -> Self {
<|fim_suffix|> ... | code_fim | medium | {
"lang": "rust",
"repo": "beautifularea/jlib-rs",
"path": "/src/base/wallet/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn default() -> Self {
WalletConfig {
key_type: WalletType::SECP256K1,
}
}
}<|fim_prefix|>// repo: beautifularea/jlib-rs path: /src/base/wallet/config.rs
/*
base config
*/
use crate::WalletType;
//钱包属性:地址长度,加密算法等
#[derive(Debug, Copy, Clone)]
pub struct WalletConf<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "beautifularea/jlib-rs",
"path": "/src/base/wallet/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yesterday17/SNLCompiler path: /snl-semantic/src/symbol.rs
use std::collections::HashMap;
use std::cmp::min;
#[derive(Debug)]
pub enum Symbol {
Variable(String),
Procedure(Vec<String>),
Type(String),
}
pub struct SymbolTable<T> {
inner: Vec<HashMap<String, T>>
}
impl<T> Default... | code_fim | hard | {
"lang": "rust",
"repo": "Yesterday17/SNLCompiler",
"path": "/snl-semantic/src/symbol.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn insert(&mut self, key: String, value: T) {
self.inner.last_mut().unwrap().insert(key, value);
}
pub fn has_own_property(&self, key: &str) -> bool {
self.inner.last().unwrap().contains_key(key)
}
}
impl SymbolTable<Symbol> {
pub fn query_type(&self, ty: &str) ->... | code_fim | hard | {
"lang": "rust",
"repo": "Yesterday17/SNLCompiler",
"path": "/snl-semantic/src/symbol.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmun/leetcode path: /src/217.contains-duplicate.rs
/*
* @lc app=leetcode id=217 lang=rust
*
* [217] Contains Duplicate
*/
// @lc code=start
use std::collections::HashSet;
impl Solution {
pub fn contains_duplicate(nums: Vec<i32>) -> bool {
let mut set = HashSet::new();
<|fim_su... | code_fim | medium | {
"lang": "rust",
"repo": "mmun/leetcode",
"path": "/src/217.contains-duplicate.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn contains_duplicate(nums: Vec<i32>) -> bool {
let mut set = HashSet::new();
for i in 0..nums.len() {
if !set.insert(nums[i]) {
return true;
}
}
return false;
}
}
// @lc code=end<|fim_prefix|>// repo: mm... | code_fim | easy | {
"lang": "rust",
"repo": "mmun/leetcode",
"path": "/src/217.contains-duplicate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn error_parse_index_already_exists() {
let f = load_file("tests/samples/error_index_already_exists.json");
let deserialized = parse::<IndexResponse>()
.from_reader(StatusCode::BAD_REQUEST, f)
.unwrap_err();
let valid = match deserialized {
ResponseError::Api(A... | code_fim | hard | {
"lang": "rust",
"repo": "Obarros/elastic",
"path": "/src/responses/tests/index/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Obarros/elastic path: /src/responses/tests/index/mod.rs
extern crate elastic_responses;
extern crate serde_json;
use elastic_responses::{
error::*,
*,
};
use load_file;
#[test]
fn success_parse_response() {
let f = load_file("tests/samples/index_success.json");
let deserialized... | code_fim | medium | {
"lang": "rust",
"repo": "Obarros/elastic",
"path": "/src/responses/tests/index/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
impl<T: Num + Copy> Complex<T> {
pub fn abs_sq(self) -> T {
(self.0 * self.0) + (self.1 * self.1)
}
pub fn pow(self, i: u16) -> Complex<T> {
(0..i).fold(Complex(T::one(), T::zero()), |c, _| c*self)
}
}<|fim_prefix|>// repo: AntonLydike/rusting path: /src/complex.rs
use n... | code_fim | hard | {
"lang": "rust",
"repo": "AntonLydike/rusting",
"path": "/src/complex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AntonLydike/rusting path: /src/complex.rs
use num_traits::*;
use std::ops::{Add, Mul};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Complex<T: Num + Copy> (pub T, pub T);
<|fim_suffix|>impl<T: Num + Copy> Complex<T> {
pub fn abs_sq(self) -> T {
(self.0 * self.0) + (self.... | code_fim | hard | {
"lang": "rust",
"repo": "AntonLydike/rusting",
"path": "/src/complex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
impl<T: Num + Copy> Zero for Complex<T> {
fn zero() -> Self {
Complex(
T::zero(),
T::zero()
)
}
fn is_zero(&self) -> bool {
self == &Self::zero()
}
}
impl<T: Num + Copy> One for Complex<T> {
fn one() -> Self {
Complex(
... | code_fim | medium | {
"lang": "rust",
"repo": "AntonLydike/rusting",
"path": "/src/complex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng2 = rng.clone();
let mut rng3 = rng.clone();
$(
let mut cases = String::new();
for (i1, i2) in iproduct!(
EDGE_CASES64.iter().cloned(),
EDGE_CASES64.iter().cloned()
).chai... | code_fim | hard | {
"lang": "rust",
"repo": "BenSandeen/libm",
"path": "/test-generator/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BenSandeen/libm path: /test-generator/src/main.rs
let out = unsafe { $intr(i1, i2) };
let i1 = i1.to_bits();
let i2 = i2.to_bits();
let out = out.to_bits();
write!(cases, "(({}, {}), {})", i1, i2, out).... | code_fim | hard | {
"lang": "rust",
"repo": "BenSandeen/libm",
"path": "/test-generator/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BenSandeen/libm path: /test-generator/src/main.rs
,
EDGE_CASES32.iter().cloned()
).chain(EDGE_CASES32.iter().map(|i1| (*i1, f32(rng))))
.chain(EDGE_CASES32.iter().map(|i2| (f32(&mut rng2), *i2)))
.chain((0..NTESTS).map(|... | code_fim | hard | {
"lang": "rust",
"repo": "BenSandeen/libm",
"path": "/test-generator/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut slice = Slice::from(vec![0, 1, 2, 3]);
assert_eq!(&slice[..], &[0, 1, 2, 3]);
assert_matches!(slice.try_resize(8, 0), Err(Error::Exhausted));
assert_eq!(&slice[..], &[0, 1, 2, 3]);
}
#[test]
fn test_resize_with_capacity() {
let mut slice = Slice... | code_fim | hard | {
"lang": "rust",
"repo": "briteming/usrnet",
"path": "/src/core/storage/slice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self.buffer[0 .. self.len]
}
}
impl<T: Clone> Slice<T> {
/// Attempts to resize the slice, assigning fresh values to the tail end
/// of the buffer in an upsizing operation.
pub fn try_resize(&mut self, buffer_len: usize, value: T) -> Result<()> {
if buffer_len > self... | code_fim | hard | {
"lang": "rust",
"repo": "briteming/usrnet",
"path": "/src/core/storage/slice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: briteming/usrnet path: /src/core/storage/slice.rs
use std::ops::{
Deref,
DerefMut,
};
use {
Error,
Result,
};
/// Owned slice which acts a resizable view over a non-resizable buffer.
#[derive(Clone, Debug)]
pub struct Slice<T> {
buffer: Vec<T>,
len: usize,
}
<|fim_suff... | code_fim | hard | {
"lang": "rust",
"repo": "briteming/usrnet",
"path": "/src/core/storage/slice.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn is_valid_eyr(input: String) -> bool {
let input = input.parse::<u32>().unwrap();
input >= 2020 && input <= 2030
}
fn is_valid_hgt(input: String) -> bool {
let re = Regex::new(r"(\d+)(in|cm)").unwrap();
if let Some(caps) = re.captures(&input) {
let value = caps
.get(... | code_fim | hard | {
"lang": "rust",
"repo": "haochuan/aoc-2020",
"path": "/src/day4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: haochuan/aoc-2020 path: /src/day4.rs
use std::collections::HashMap;
extern crate regex;
use regex::Regex;
type Passport = HashMap<String, String>;
type PassportList = Vec<Passport>;
fn is_valid_passport(passport: &Passport, validation: bool) -> bool {
if !passport.contains_key("byr")
... | code_fim | hard | {
"lang": "rust",
"repo": "haochuan/aoc-2020",
"path": "/src/day4.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let text = concat!(
"eyr:1972 cid:100\n",
"hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926\n",
"\n",
"iyr:2019\n",
"hcl:#602927 eyr:1967 hgt:170cm\n",
"ecl:grn pid:012533040 byr:1946\n",
"\n",
"... | code_fim | hard | {
"lang": "rust",
"repo": "haochuan/aoc-2020",
"path": "/src/day4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xorlev/AdventOfCode path: /aoc2021/src/bin/main_04.rs
use crate::Spot::{Marked, Unmarked};
use util::aoc::*;
fn main() -> AocResult<()> {
let input: String = input::read_all(4)?;
let (drawn_numbers, boards) = parse(&input);
result("Part 1", || part1(&drawn_numbers, boards.clone()))... | code_fim | hard | {
"lang": "rust",
"repo": "Xorlev/AdventOfCode",
"path": "/aoc2021/src/bin/main_04.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.numbers
.iter()
.filter_map(|spot| match spot {
Unmarked(v) => Some(*v),
Marked(_) => None,
})
.sum()
}
fn has_bingo(&self) -> bool {
// Check rows
if self
.numbers
... | code_fim | hard | {
"lang": "rust",
"repo": "Xorlev/AdventOfCode",
"path": "/aoc2021/src/bin/main_04.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> false
}
}
#[cfg(test)]
mod tests {
use super::*;
const SAMPLE_INPUT: &str = r#"7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1
22 13 17 11 0
8 2 23 4 24
21 9 14 16 7
6 10 3 18 5
1 12 20 15 19
3 15 0 2 22
9 18 13 17 5
19 8 7 25 23
20 11 10 24 ... | code_fim | hard | {
"lang": "rust",
"repo": "Xorlev/AdventOfCode",
"path": "/aoc2021/src/bin/main_04.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erni100/bot path: /opensea-rs-master/opensea/src/api.rs
use ethers::types::Address;
use reqwest::{
header::{self, HeaderMap},
Client, ClientBuilder,
};
use serde::{Deserialize, Serialize};
use crate::types::{Network, Order};
use thiserror::Error;
#[derive(Clone, Debug)]
pub struct Open... | code_fim | hard | {
"lang": "rust",
"repo": "erni100/bot",
"path": "/opensea-rs-master/opensea/src/api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use crate::types::MinimalOrder;
use super::*;
#[tokio::test]
async fn can_get_order() {
let api = OpenSeaApi::new(OpenSeaApiConfig::default());
let req = OrderRequest {
side: 1,
token_id: 2292.to_string(),
cont... | code_fim | hard | {
"lang": "rust",
"repo": "erni100/bot",
"path": "/opensea-rs-master/opensea/src/api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: broughjt/inc path: /tests/inc.rs
use inc::compile::compile;
use std::{fs::write, process::Command};
mod temporary_directory;
use temporary_directory::TemporaryDirectory;
fn test(input: &str, expected: &str) {
let directory = TemporaryDirectory::create().unwrap();
let object = director... | code_fim | hard | {
"lang": "rust",
"repo": "broughjt/inc",
"path": "/tests/inc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn is_null() {
cases(&[
(r"(null? ())", "#t"),
(r"(null? #f)", "#f"),
(r"(null? #t)", "#f"),
(r"(null? (null? ()))", "#f"),
(r"(null? #\a)", "#f"),
(r"(null? 0)", "#f"),
(r"(null? -10)", "#f"),
... | code_fim | hard | {
"lang": "rust",
"repo": "broughjt/inc",
"path": "/tests/inc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn read32(&self, offset: usize) -> u32 {
let lo = self.read16(offset) as u32;
let hi = self.read16(offset + 2) as u32;
return lo | (hi << 16);
}
pub fn read16(&self, offset: usize) -> u16 {
if offset < 0x200 {
return self.bg[offset / 2];
... | code_fim | hard | {
"lang": "rust",
"repo": "ExPixel/Pyrite-old-",
"path": "/pyrite-gba/src/lcd/palette.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ExPixel/Pyrite-old- path: /pyrite-gba/src/lcd/palette.rs
pub struct GbaPalette {
bg: [u16; 256],
obj: [u16; 256],
}
impl GbaPalette {
pub const fn new() -> GbaPalette {
GbaPalette {
bg: [0u16; 256],
obj: [0u16; 256],
}
}
pub fn backdr... | code_fim | hard | {
"lang": "rust",
"repo": "ExPixel/Pyrite-old-",
"path": "/pyrite-gba/src/lcd/palette.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hatoo/vst_plugin_parameters_derive path: /src/lib.rs
pub use vst_plugin_parameters_derive_<|fim_suffix|>meters};
pub trait NumPluginParameters {
fn num_parameters() -> i32;
}<|fim_middle|>impl::{NumPluginParameters, PluginPara | code_fim | easy | {
"lang": "rust",
"repo": "hatoo/vst_plugin_parameters_derive",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rs {
fn num_parameters() -> i32;
}<|fim_prefix|>// repo: hatoo/vst_plugin_parameters_derive path: /src/lib.rs
pub use vst_plugin_parameters_derive_<|fim_middle|>impl::{NumPluginParameters, PluginParameters};
pub trait NumPluginParamete | code_fim | medium | {
"lang": "rust",
"repo": "hatoo/vst_plugin_parameters_derive",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/tauri path: /core/tauri/src/app/tray.rs
#[cfg(target_os = "macos")]
icon_as_template_set: bool,
#[cfg(target_os = "macos")]
title: Option<String>,
tooltip: Option<String>,
}
impl fmt::Debug for SystemTray {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tauri",
"path": "/core/tauri/src/app/tray.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/tauri path: /core/tauri/src/app/tray.rs
tray menu.
pub menu: Option<SystemTrayMenu>,
/// Whether the icon is a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc) icon or not.
#[cfg(target_os = "macos")]
pub icon_as_template: bo... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tauri",
"path": "/core/tauri/src/app/tray.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A handle to a system tray menu item.
#[default_runtime(crate::Wry, wry)]
#[derive(Debug)]
pub struct SystemTrayMenuItemHandle<R: Runtime> {
id: MenuHash,
tray_handler: R::TrayHandler,
}
impl<R: Runtime> Clone for SystemTrayMenuItemHandle<R> {
fn clone(&self) -> Self {
Self {
id: self.... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tauri",
"path": "/core/tauri/src/app/tray.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Expression for ParseIntFn {
fn resolve(&self, ctx: &mut Context) -> Resolved {
let value = self.value.resolve(ctx)?;
let string = value.try_bytes_utf8_lossy()?;
let (base, index) = match &self.base {
Some(base) => base
.resolve(ctx)
... | code_fim | hard | {
"lang": "rust",
"repo": "imorph/vector",
"path": "/lib/vrl/stdlib/src/parse_int.rs",
"mode": "spm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(converted.into())
}
fn type_def(&self, _state: &state::Compiler) -> TypeDef {
TypeDef::new().fallible().integer()
}
}
#[cfg(test)]
mod tests {
use super::*;
test_function![
parse_int => ParseInt;
decimal {
args: func_args![value: "-42... | code_fim | hard | {
"lang": "rust",
"repo": "imorph/vector",
"path": "/lib/vrl/stdlib/src/parse_int.rs",
"mode": "spm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imorph/vector path: /lib/vrl/stdlib/src/parse_int.rs
use vrl::prelude::*;
#[derive(Clone, Copy, Debug)]
pub struct ParseInt;
impl Function for ParseInt {
fn identifier(&self) -> &'static str {
"parse_int"
}
fn parameters(&self) -> &'static [Parameter] {
&[
... | code_fim | hard | {
"lang": "rust",
"repo": "imorph/vector",
"path": "/lib/vrl/stdlib/src/parse_int.rs",
"mode": "psm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_new() {
let h = Header::new("name".to_string(), "value".to_string());
assert_eq!(h.name, "name");
assert_eq!(h.value, "value");
}
#[test]
fn test_eq() {
let h1 = Header::new("name".to_string(), "value".to_string());
let h2 = Head... | code_fim | medium | {
"lang": "rust",
"repo": "cyplp/naptime",
"path": "/src/napstruct/napheader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyplp/naptime path: /src/napstruct/napheader.rs
#[derive(Debug)]
pub struct Header {
pub name: String,
pub value: String,
}
impl Header {
pub fn new(name: String, value: String) -> Header {
Header { name, value }
}
}
impl PartialEq for Header {
fn eq(&self, other: &... | code_fim | hard | {
"lang": "rust",
"repo": "cyplp/naptime",
"path": "/src/napstruct/napheader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
// Wait for ping, reply with pong that has a matching nonce.
let ping = ping_sub.receive().await?;
debug!(target: "net", "ProtocolPing::reply_to_ping() received Ping message");
// Send pong message.
let pong = messages::PongMessag... | code_fim | hard | {
"lang": "rust",
"repo": "narodnik/sapvi",
"path": "/src/net/protocols/protocol_ping.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: narodnik/sapvi path: /src/net/protocols/protocol_ping.rs
use log::*;
use rand::Rng;
use smol::Executor;
use std::sync::Arc;
use std::time::Instant;
use crate::net::error::{NetError, NetResult};
use crate::net::messages;
use crate::net::protocols::{ProtocolJobsManager, ProtocolJobsManagerPtr};
u... | code_fim | hard | {
"lang": "rust",
"repo": "narodnik/sapvi",
"path": "/src/net/protocols/protocol_ping.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>AAnswer,
}
pub type Result<R> = std::result::Result<R, Error>;<|fim_prefix|>// repo: russells-crockpot/treacle path: /src/error.rs
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("The decision is not a branch.")]
DecisionIsNotABranch,
<|fim_middle|> #[error("The decision is not an... | code_fim | medium | {
"lang": "rust",
"repo": "russells-crockpot/treacle",
"path": "/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: russells-crockpot/treacle path: /src/error.rs
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[erro<|fim_suffix|> #[error("The decision is not an answer.")]
DecisionIsNotAAnswer,
}
pub type Result<R> = std::result::Result<R, Error>;<|fim_middle|>r("The decision is not a branch.")... | code_fim | medium | {
"lang": "rust",
"repo": "russells-crockpot/treacle",
"path": "/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astro/rust-lpc43xx path: /src/scu/mod.rs
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Pin configuration register for pins P0"]
pub sfsp0: [SFSP0; 2],
_reserved0: [u8; 120usize],
#[doc = "0x80 - Pin configuration register for pins P1"]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rust-lpc43xx",
"path": "/src/scu/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub mod sfspa_4;
#[doc = "Pin configuration register for pins PB"]
pub struct SFSPB {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "Pin configuration register for pins PB"]
pub mod sfspb;
#[doc = "Pin configuration register for pins PC"]
pub struct SFSPC {
register: ::vcell::VolatileCell<u32>,... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rust-lpc43xx",
"path": "/src/scu/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elicharlese/advent-of-code path: /2019/src/bin/day03.rs
use anyhow::{bail, Result};
use itertools::Itertools;
use std::collections::HashSet;
const INPUT: &str = include_str!("../../input/day03.txt");
#[derive(Hash, Eq, PartialEq, Debug, Clone, Copy)]
struct Point {
x: isize,
y: isize,
... | code_fim | hard | {
"lang": "rust",
"repo": "elicharlese/advent-of-code",
"path": "/2019/src/bin/day03.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test = "R8,U5,L5,D3\nU7,R6,D4,L4";
run(test).unwrap();
let test = "R75,D30,R83,U83,L12,D49,R71,U7,L72\nU62,R66,U55,R34,D71,R55,D58,R83";
run(test).unwrap();
let test = "R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51\nU98,R91,D20,R16,D67,R40,U7,R15,U6,R7";
run(test).unwrap();
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "elicharlese/advent-of-code",
"path": "/2019/src/bin/day03.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let min_steps = set1
.intersection(&set2)
.map(|p| {
let steps0 = wires[0]
.iter()
.enumerate()
.find(|(_, q)| *q == p)
.unwrap()
.0;
let steps1 = wires[1]
.iter()
... | code_fim | hard | {
"lang": "rust",
"repo": "elicharlese/advent-of-code",
"path": "/2019/src/bin/day03.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut target = display.draw();
target.clear_color(1.0, 1.0, 1.0, 1.0);
// Render the font at (10, 10), with a font size of 24 and a black colour
cached_font.render(&text, [10.0, 10.0], 24.0, [0.0, 0.0, 0.0, 1.0], &mut target, &display, &program).unwrap();
target.f... | code_fim | hard | {
"lang": "rust",
"repo": "expenses/runic",
"path": "/examples/simple.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.