text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> }
}
for bomb in &mut self.bombs {
if bomb.over_players.len() != 0 {
for player_id in 0..self.players.len() {
if Collision::is_over_bomb(self.players[player_id].position, bomb.position... | code_fim | hard | {
"lang": "rust",
"repo": "sakamoto-a/bomberhuman",
"path": "/src/models/world.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sakamoto-a/bomberhuman path: /src/models/world.rs
if self.players[event.player_id].items.fire_up < 8 {
self.players[event.player_id].firepower += 1;
}
self.players[event.player_id].items.fire_up += 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "sakamoto-a/bomberhuman",
"path": "/src/models/world.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A wrapper for [`jsonrpc_v2::Server`], implemented [`roa::Endpoint`].
///
/// [`jsonrpc_v2::Server`]: https://docs.rs/jsonrpc-v2/0.10.1/jsonrpc_v2/struct.Server.html
/// [`roa::Endpoint`]: https://docs.rs/roa/0.6.0/roa/trait.Endpoint.html
pub struct RpcEndpoint<R>(pub Server<R>);
#[async_trait(? Send)... | code_fim | medium | {
"lang": "rust",
"repo": "Hexilee/roa",
"path": "/roa/src/jsonrpc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hexilee/roa path: /roa/src/jsonrpc.rs
//!
//! ## roa::jsonrpc
//!
//! This module provides a json rpc endpoint.
//!
//! ### Example
//!
//! ```rust,no_run
//! use roa::App;
//! use roa::jsonrpc::{RpcEndpoint, Data, Error, Params, Server};
//! use roa::tcp::Listener;
//! use tracing::info;
//!
//... | code_fim | hard | {
"lang": "rust",
"repo": "Hexilee/roa",
"path": "/roa/src/jsonrpc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>named!(
pub parse_page<OggPage>,
do_parse!(
header: parse_header >>
data: take!(header.get_data_size()) >>
(OggPage {
header: header,
data: data,
})
)
);
named!(parse_all_pages<Vec<OggPage> >, many0!(parse_page));
#[cfg(test)]
mod tests... | code_fim | hard | {
"lang": "rust",
"repo": "fsasm/rogg",
"path": "/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = include_bytes!("../test/test02.ogg");
let (_, page) = parse_page(data).unwrap();
let digest = page.calc_crc();
assert_eq!(digest, page.header.crc32);
}
#[test]
fn test_crc_wikipedia() {
let data = include_bytes!("../test/Example.ogg");
... | code_fim | hard | {
"lang": "rust",
"repo": "fsasm/rogg",
"path": "/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fsasm/rogg path: /src/parser.rs
use types::*;
use nom::*;
named!(magic, tag!(&[0x4F, 0x67, 0x67, 0x53]));
named!(version, tag!([0x00]));
named!(
header_flags<Flags>,
map!(take!(1), |flags| Flags::from(flags[0]))
);
named!(
granule_position<GranulePosition>,
map!(le_u64, |pos| G... | code_fim | hard | {
"lang": "rust",
"repo": "fsasm/rogg",
"path": "/src/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LazyOxen/orbtk path: /examples/canvas.rs
extern crate orbtk;
use orbtk::{Window, Canvas, Rect, Point};
use orbtk::traits::{Click, Place};
use std::rc::Rc;
use std::cell::RefCell;
<|fim_suffix|> if let Some(prev_position) = *prev_opt {
canvas.line(prev_positi... | code_fim | hard | {
"lang": "rust",
"repo": "LazyOxen/orbtk",
"path": "/examples/canvas.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let canvas = Canvas::new();
canvas.position(10, 10)
.size(400, 400)
.on_click(move |canvas: &Canvas, point: Point| {
let click = click_pos.clone();
{
let mut prev_opt = click.borrow_mut();
if let Some(prev_position) = *prev_o... | code_fim | medium | {
"lang": "rust",
"repo": "LazyOxen/orbtk",
"path": "/examples/canvas.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let click_pos: Rc<RefCell<Option<Point>>>= Rc::new(RefCell::new(None));
let canvas = Canvas::new();
canvas.position(10, 10)
.size(400, 400)
.on_click(move |canvas: &Canvas, point: Point| {
let click = click_pos.clone();
{
let mut prev_op... | code_fim | medium | {
"lang": "rust",
"repo": "LazyOxen/orbtk",
"path": "/examples/canvas.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tvpsh2021/HoloStatsTW path: /server/src/requests/pubsub.rs
use reqwest::header::CONTENT_TYPE;
use tracing::instrument;
use super::RequestHub;
use crate::config::CONFIG;
<|fim_suffix|> let _ = self
.client
.post("https://pubsubhubbub.appspot.com/subscribe")
... | code_fim | hard | {
"lang": "rust",
"repo": "tvpsh2021/HoloStatsTW",
"path": "/server/src/requests/pubsub.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = self
.client
.post("https://pubsubhubbub.appspot.com/subscribe")
.header(CONTENT_TYPE, "application/x-www-form-urlencoded")
.body(format!(
"hub.callback={}/api/pubsub/{}&hub.topic={}{}&hub.mode=subscribe",
CONF... | code_fim | hard | {
"lang": "rust",
"repo": "tvpsh2021/HoloStatsTW",
"path": "/server/src/requests/pubsub.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut new_line = true;
let mut on_crn = false;
let mut on_subject = false;
let mut on_number = false;
let mut crn = 0;
let mut subject = String::new();
let mut number = String::new();
for letter in contents.chars() {
if letter =... | code_fim | hard | {
"lang": "rust",
"repo": "rweichler/ecs30_in_rust",
"path": "/prog7/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rweichler/ecs30_in_rust path: /prog7/src/parser.rs
pub struct Parser {
courses: Vec<Course>
}
pub struct Course {
crn: i32,
subject: String,
number: String
}
use std::fmt;
impl Course {
fn new(crn: i32, subject: String, number: String) -> Course {
Course {
... | code_fim | hard | {
"lang": "rust",
"repo": "rweichler/ecs30_in_rust",
"path": "/prog7/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rmit-programming-club/tpcdata path: /src/main.rs
use rusoto_core::Region;
use rusoto_dynamodb::{DynamoDb, DynamoDbClient, PutItemInput, ScanInput, DeleteItemInput};
use lambda_http::{handler, lambda, Context, Request, Response, Body};
use serde_json::json;
use serde::{Deserialize, Serialize};
us... | code_fim | hard | {
"lang": "rust",
"repo": "rmit-programming-club/tpcdata",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn get_members(datastore: &impl TpcDatastore, _ : Request) -> Result<Response<Body>, Error> {
let members = datastore.list_members().await?;
// Make sure only members that want to be seen are seen
let filtered_members : Vec<&User> = members.iter().filter(|user| user.show_user).collect()... | code_fim | hard | {
"lang": "rust",
"repo": "rmit-programming-club/tpcdata",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn test_user() -> User {
User { id: String::from("")
, student_number: String::from("s3723315")
, first_name: String::from("Sam")
, last_name: String::from("Nolan")
, preferred_name: String::from("")
, preferred_email: String::from("")... | code_fim | hard | {
"lang": "rust",
"repo": "rmit-programming-club/tpcdata",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: suryatmodulus/bevy path: /crates/bevy_app/src/app.rs
the App, which by default executes the App schedule once. Apps are constructed using the
/// builder pattern.
///
/// ## Example
/// Here is a simple "Hello World" Bevy app:
/// ```
/// # use bevy_app::prelude::*;
/// # use bevy_ecs::prelude::... | code_fim | hard | {
"lang": "rust",
"repo": "suryatmodulus/bevy",
"path": "/crates/bevy_app/src/app.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn add_startup_system_set(&mut self, system_set: SystemSet) -> &mut Self {
self.add_startup_system_set_to_stage(StartupStage::Startup, system_set)
}
pub fn add_startup_system_to_stage<Params>(
&mut self,
stage_label: impl StageLabel,
system: impl IntoSystem... | code_fim | hard | {
"lang": "rust",
"repo": "suryatmodulus/bevy",
"path": "/crates/bevy_app/src/app.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Adds a single plugin
///
/// One of Bevy's core principles is modularity. All Bevy engine features are implemented
/// as plugins. This includes internal features like the renderer.
///
/// Bevy also provides a few sets of default plugins. See [`App::add_plugins`].
///
... | code_fim | hard | {
"lang": "rust",
"repo": "suryatmodulus/bevy",
"path": "/crates/bevy_app/src/app.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "alloc")]
extern crate alloc;
#[macro_use]
extern crate log;
mod connection;
mod gdbstub_impl;
mod protocol;
mod util;
#[doc(hidden)]
pub mod internal;
pub mod arch;
pub mod common;
pub mod target;
pub use connection::Connection;
pub use gdbstub_impl::*;
/// (Internal) The fake Tid t... | code_fim | hard | {
"lang": "rust",
"repo": "kevinmiles/gdbstub",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kevinmiles/gdbstub path: /src/lib.rs
//! An ergonomic and easy-to-integrate implementation of the
//! [GDB Remote Serial Protocol](https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html#Remote-Protocol)
//! in Rust, with full `#![no_std]` support.
//!
//! ## Feature flags
//!
//! By defa... | code_fim | hard | {
"lang": "rust",
"repo": "kevinmiles/gdbstub",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DannyLee12/projecteuler path: /projecteuler/src/e_66.rs
/*
Consider quadratic Diophantine equations of the form:
x2 – Dy2 = 1
For example, when D=13, the minimal solution in x is 6492 – 13×1802 = 1.
It can be assumed that there are no solutions in positive integers when D is square.
<|fim_su... | code_fim | medium | {
"lang": "rust",
"repo": "DannyLee12/projecteuler",
"path": "/projecteuler/src/e_66.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::time::Instant;
use std::cmp::max;
pub fn main() {
let now = Instant::now();
let mut max_x: u64 = 9;
let mut b = false;
let mut ds: Vec<i128> = vec![];
for D in 2..1001 {
let sq2 = (D as f64).sqrt();
if sq2 - (sq2 as i64 as f64) == 0.0 { continue };
pri... | code_fim | medium | {
"lang": "rust",
"repo": "DannyLee12/projecteuler",
"path": "/projecteuler/src/e_66.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexcrichton/wasmtime path: /fuzz/fuzz_targets/compile.rs
//! Compile arbitrary bytes from the fuzzer as if they were Wasm. Also use
//! `wasm-mutate` to mutate the fuzz inputs.
#![no_main]
use libfuzzer_sys::{fuzz_mutator, fuzz_target};
use wasmtime::{Config, Engine, Module};
fn create_engin... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/wasmtime",
"path": "/fuzz/fuzz_targets/compile.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut config = Config::default();
// Safety: the Cranelift option `regalloc_checker` does not alter
// the generated code at all; it only does extra checking after
// compilation.
unsafe {
config.cranelift_flag_enable("regalloc_checker");
}
Engine::new(&config).expect... | code_fim | medium | {
"lang": "rust",
"repo": "alexcrichton/wasmtime",
"path": "/fuzz/fuzz_targets/compile.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
circuit_id: &str,
service_id: &str,
) -> Result<Option<String>, CommitHashStoreError> {
let current_commit_hash = scabbard_commit_hash::table
.find((circuit_id, service_id))
.select(scabbard_commit_hash::commit_hash)
.get_resul... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/services/scabbard/libscabbard/src/store/commit_hash/diesel/operations/get_current_commit_hash.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cargill/splinter path: /services/scabbard/libscabbard/src/store/commit_hash/diesel/operations/get_current_commit_hash.rs
// Copyright 2021 Cargill Incorporated
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License... | code_fim | medium | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/services/scabbard/libscabbard/src/store/commit_hash/diesel/operations/get_current_commit_hash.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, C> CommitHashStoreGetCurrentCommitHashOperation for CommitHashStoreOperations<'a, C>
where
C: diesel::Connection,
String: diesel::deserialize::FromSql<Text, C::Backend>,
{
fn get_current_commit_hash(
&self,
circuit_id: &str,
service_id: &str,
) -> Result<Op... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/services/scabbard/libscabbard/src/store/commit_hash/diesel/operations/get_current_commit_hash.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Zeroes the `.bss` section
///
/// # Arguments
///
/// - `sbss`. Pointer to the start of the `.bss` section.
/// - `ebss`. Pointer to the end of the `.bss` section.
pub unsafe fn zero_bss<T>(mut sbss: *mut T, ebss: *mut T)
where
T: Copy,
{
while sbss < ebss {
ptr::write_volatile(sbss, m... | code_fim | medium | {
"lang": "rust",
"repo": "wave-mirror/particle",
"path": "/libs/rrt0/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wave-mirror/particle path: /libs/rrt0/src/lib.rs
// Copyright 2019 The Particle Authors
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
<|fim_suffix|>/// Initialize the `.data` section
///
///... | code_fim | hard | {
"lang": "rust",
"repo": "wave-mirror/particle",
"path": "/libs/rrt0/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytebeamio/rumqtt path: /rumqttc/src/lib.rs
ilder()
.with_safe_defaults()
.with_root_certificates(root_cert_store)
.with_no_client_auth();
Self::Rustls(Arc::new(tls_config))
}
}
#[cfg(feature = "use-rustls")]
impl From<ClientConfig> for TlsConfig... | code_fim | hard | {
"lang": "rust",
"repo": "bytebeamio/rumqtt",
"path": "/rumqttc/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> MqttOptions {
broker_addr: host.into(),
port,
transport: Transport::tcp(),
keep_alive: Duration::from_secs(60),
clean_session: true,
client_id: id,
credentials: None,
max_incoming_packet_size: 10 * 1024... | code_fim | hard | {
"lang": "rust",
"repo": "bytebeamio/rumqtt",
"path": "/rumqttc/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set number of concurrent in flight messages
pub fn set_inflight(&mut self, inflight: u16) -> &mut Self {
assert!(inflight != 0, "zero in flight is not allowed");
self.inflight = inflight;
self
}
/// Number of concurrent in flight messages
pub fn inflight(&... | code_fim | hard | {
"lang": "rust",
"repo": "bytebeamio/rumqtt",
"path": "/rumqttc/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: littleroys/leetcode-rs path: /src/array/mod.rs
pub mod flip_and_invert_image;
pub mod last_len_word;
pub mod merge_s<|fim_suffix|>e_arrays;
pub mod spiral_matrix;
pub mod two_sum;
pub mod word_search;<|fim_middle|>ort_array;
pub mod move_zeroes;
pub mod number_good_pairs;
pub mod remove_dup_arra... | code_fim | medium | {
"lang": "rust",
"repo": "littleroys/leetcode-rs",
"path": "/src/array/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e_arrays;
pub mod spiral_matrix;
pub mod two_sum;
pub mod word_search;<|fim_prefix|>// repo: littleroys/leetcode-rs path: /src/array/mod.rs
pub mod flip_and_invert_image;
pub mod last_len_word;
pub mod merge_sort_array;
pub mod move_zeroes;
pub mod number_good_pairs;
pub mod rem<|fim_middle|>ove_dup_arra... | code_fim | medium | {
"lang": "rust",
"repo": "littleroys/leetcode-rs",
"path": "/src/array/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: satyamakgec/fe path: /analyzer/src/traversal/utils.rs
use crate::namespace::types::FixedSize;
use crate::{
ExpressionAttributes,
Type,
};
use fe_parser::ast as fe;
use fe_parser::node::Node;
<|fim_suffix|>pub fn fixed_sizes_to_types(sizes: Vec<FixedSize>) -> Vec<Type> {
sizes.iter()... | code_fim | hard | {
"lang": "rust",
"repo": "satyamakgec/fe",
"path": "/analyzer/src/traversal/utils.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn expression_attributes_to_types(attributes: Vec<ExpressionAttributes>) -> Vec<Type> {
attributes
.iter()
.map(|attributes| attributes.typ.clone())
.collect()
}
pub fn fixed_sizes_to_types(sizes: Vec<FixedSize>) -> Vec<Type> {
sizes.iter().map(|param| param.clone().in... | code_fim | medium | {
"lang": "rust",
"repo": "satyamakgec/fe",
"path": "/analyzer/src/traversal/utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn fixed_sizes_to_types(sizes: Vec<FixedSize>) -> Vec<Type> {
sizes.iter().map(|param| param.clone().into()).collect()
}<|fim_prefix|>// repo: satyamakgec/fe path: /analyzer/src/traversal/utils.rs
use crate::namespace::types::FixedSize;
use crate::{
ExpressionAttributes,
Type,
};
use fe_p... | code_fim | hard | {
"lang": "rust",
"repo": "satyamakgec/fe",
"path": "/analyzer/src/traversal/utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::init_log();
::info("hello world");
::info("test xlog");
unsafe {
::xlog::appender_close();
}
}
}<|fim_prefix|>// repo: xinghun92/test_xlog path: /src/lib.rs
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)... | code_fim | medium | {
"lang": "rust",
"repo": "xinghun92/test_xlog",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xinghun92/test_xlog path: /src/lib.rs
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
pub mod xlog;
use std::ffi::CString;
fn init_log() {
<|fim_suffix|> ::init_log();
::info("hello world");
::info("test xlog");
unsafe... | code_fim | hard | {
"lang": "rust",
"repo": "xinghun92/test_xlog",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: titaneric/exercism-rust path: /rust/pascals-triangle/src/lib.rs
pub struct PascalsTriangle {
rows: Vec<Vec<u32>>,
}
impl PascalsTriangle {
pub fn new(row_count: u32) -> Self {
let mut rows = vec![];
for r in 0..row_count {
let mut row = vec![];
fo... | code_fim | medium | {
"lang": "rust",
"repo": "titaneric/exercism-rust",
"path": "/rust/pascals-triangle/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n <= 1 {
1
} else {
n * factorial(n - 1)
}
}<|fim_prefix|>// repo: titaneric/exercism-rust path: /rust/pascals-triangle/src/lib.rs
pub struct PascalsTriangle {
rows: Vec<Vec<u32>>,
}
impl PascalsTriangle {
pub fn new(row_count: u32) -> Self {
let mut rows =... | code_fim | medium | {
"lang": "rust",
"repo": "titaneric/exercism-rust",
"path": "/rust/pascals-triangle/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut iter = result
.into_iter()
.map(|[y, x]| (y - r_center).abs() + (x - c_center).abs());
let mut prev = iter.next().unwrap();
for distance in iter {
assert!(prev <= distance);
prev = distance;
... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_1030_matrix_cells_in_distance_order/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (rows, cols, r_center, c_center) in test_cases {
let result = S::all_cells_dist_order(rows, cols, r_center, c_center)
.into_iter()
.map(|cell| cell.try_into().unwrap())
.collect::<Vec<_>>();
let expected_set = (0..rows)
... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_1030_matrix_cells_in_distance_order/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_1030_matrix_cells_in_distance_order/mod.rs
pub mod bfs;
pub trait Solution {
fn all_cells_dist_order(rows: i32, cols: i32, r_center: i32, c_center: i32) -> Vec<Vec<i32>>;
<|fim_suffix|> let mut prev = iter.next().unwrap();
for dista... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_1030_matrix_cells_in_distance_order/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: galactic-src/advent-rust-19 path: /problem10/src/main.rs
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::collections::{HashSet, BTreeMap};
use num::integer::gcd;
use std::cmp::Ordering;
use std::f64::consts::PI;
#[derive(Debug, Copy, Clone, PartialEq)]
struct Point {
x: usiz... | code_fim | hard | {
"lang": "rust",
"repo": "galactic-src/advent-rust-19",
"path": "/problem10/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_example1() {
let input = vec!(
".#....#####...#..",
"##...##.#####..##",
"##...#...#.#####.",
"..#.....#...###..",
"..#.#.....#....##"
);
let mut all_points = vec!();
for (line_no, line) in... | code_fim | hard | {
"lang": "rust",
"repo": "galactic-src/advent-rust-19",
"path": "/problem10/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thejpster/ke06z4-pac path: /src/osc/cr.rs
#[doc = "Reader of register CR"]
pub type R = crate::R<u8, super::CR>;
#[doc = "Writer for register CR"]
pub type W = crate::W<u8, super::CR>;
#[doc = "Register CR `reset()`'s with value 0"]
impl crate::ResetValue for super::CR {
type Type = u8;
... | code_fim | hard | {
"lang": "rust",
"repo": "thejpster/ke06z4-pac",
"path": "/src/osc/cr.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `OSCSTEN`"]
pub type OSCSTEN_R = crate::R<bool, OSCSTEN_A>;
impl OSCSTEN_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> OSCSTEN_A {
match self.bits {
false => OSCSTEN_A::_0... | code_fim | hard | {
"lang": "rust",
"repo": "thejpster/ke06z4-pac",
"path": "/src/osc/cr.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: j1elo/advent-of-code-2019-rust path: /day-03/src/main.rs
use std::collections::HashMap;
use std::io;
use euclid;
use recap::Recap; // #[recap()]
use serde::Deserialize; // #[derive(Deserialize)]
use std::cell::RefCell;
use turtle::Turtle;
// thread_local!(static TURTLE: Turtle = Turtle::new())... | code_fim | hard | {
"lang": "rust",
"repo": "j1elo/advent-of-code-2019-rust",
"path": "/day-03/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> turtle.go_to(tp);
});
}
walked
}
// ----------------------------------------------------------------------------
fn part1(path1: &[Path], path2: &[Path]) -> i32 {
let walk1 = walk_path(path1);
let walk2 = walk_path(path2);
walk1
.keys()
.filter_m... | code_fim | hard | {
"lang": "rust",
"repo": "j1elo/advent-of-code-2019-rust",
"path": "/day-03/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let walk1 = walk_path(path1);
let walk2 = walk_path(path2);
walk1
.keys()
.filter_map(|point| {
if walk2.contains_key(point) {
// Manhattan distance to the center (0, 0)
Some((point.x - 0).abs() + (point.y - 0).abs())
} e... | code_fim | hard | {
"lang": "rust",
"repo": "j1elo/advent-of-code-2019-rust",
"path": "/day-03/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("Done reading config");
return AppConfig {
kafka_config,
alpaca_config,
polygon_config,
};
}
}<|fim_prefix|>// repo: mchapala/alpacarust path: /src/appconfig/mod.rs
use super::alpaca::*;
use super::kafkautil::*;
use config::{Config, ... | code_fim | hard | {
"lang": "rust",
"repo": "mchapala/alpacarust",
"path": "/src/appconfig/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mchapala/alpacarust path: /src/appconfig/mod.rs
use super::alpaca::*;
use super::kafkautil::*;
use config::{Config, File, FileFormat};
use std::env;
use std::rc::Rc;
use std::slice::RChunks;
#[derive(Debug, Clone)]
pub struct AppConfig {
pub kafka_config: KafkaConfig,
pub alpaca_config:... | code_fim | medium | {
"lang": "rust",
"repo": "mchapala/alpacarust",
"path": "/src/appconfig/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let kafka_config = KafkaConfig {
broker_with_ip: conf.get_str("kafka.hosts").unwrap(),
};
let alpaca_config = Rc::new(AlpacaConfig {
url: conf.get_str("alpaca.url").unwrap(),
key: conf.get_str("alpaca.key").unwrap(),
secret: conf.get... | code_fim | hard | {
"lang": "rust",
"repo": "mchapala/alpacarust",
"path": "/src/appconfig/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 10~20 ResearchGroups are subOrgnization of the Department
let research_group_count = rand_between(&mut seed, 10, 20);
for rg_ix in 0..research_group_count {
let group = format!("{}|research_group{}", department, rg_ix);
eav(program, &m... | code_fim | hard | {
"lang": "rust",
"repo": "mwatts/eve-native",
"path": "/benches/lubm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mwatts/eve-native path: /benches/lubm.rs
// 15~25 Departments are subOrgnization of the University
let department_count = rand_between(&mut seed, 10, 25);
for department_ix in 0..department_count {
let department = format!("{}|department{}", university, departme... | code_fim | hard | {
"lang": "rust",
"repo": "mwatts/eve-native",
"path": "/benches/lubm.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn do_bench(b: &mut Bencher, name: &str, func: fn(&mut Program)) {
let mut program = Program::new(name);
setup(&mut program, 1);
func(&mut program);
let mut all_results = vec![];
b.iter(|| {
let results = program.exec_query(name);
all_results.push(results);
})... | code_fim | hard | {
"lang": "rust",
"repo": "mwatts/eve-native",
"path": "/benches/lubm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xuxue1/yolo-dl path: /tch-goodies/src/detection/dense_detection_tensor_list.rs
use super::DenseDetectionTensor;
use crate::common::*;
#[derive(Debug, PartialEq, TensorLike)]
pub struct DenseDetectionTensorList {
pub(super) inner: DenseDetectionTensorListUnchecked,
}
impl DenseDetectionTens... | code_fim | hard | {
"lang": "rust",
"repo": "Xuxue1/yolo-dl",
"path": "/tch-goodies/src/detection/dense_detection_tensor_list.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.inner
}
}
impl From<DenseDetectionTensorList> for DenseDetectionTensorListUnchecked {
fn from(from: DenseDetectionTensorList) -> Self {
from.inner
}
}
impl TryFrom<DenseDetectionTensorListUnchecked> for DenseDetectionTensorList {
type Error = Error;
fn try_from... | code_fim | hard | {
"lang": "rust",
"repo": "Xuxue1/yolo-dl",
"path": "/tch-goodies/src/detection/dense_detection_tensor_list.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: i5possible/datum path: /dc_compiler/src/neat/namespace.rs
use crate::ControlFlowGraph;
use dc_hir::{Function, StructDecl};
use dc_parser::ExpressionType;
#[derive(Debug)]
pub struct Namespace {
// todo: add diagnostics
pub files: Vec<String>,
pub structs: Vec<StructDecl>,
pub fu... | code_fim | medium | {
"lang": "rust",
"repo": "i5possible/datum",
"path": "/dc_compiler/src/neat/namespace.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn expr_to_type<'a>(&mut self, expr: &'a dc_parser::Expression) {
let expr = expr;
match expr.node {
ExpressionType::Call { .. } => {}
_ => {
println!("{:?}", expr.node);
}
}
}
}<|fim_prefix|>// repo: i5possible/datum ... | code_fim | medium | {
"lang": "rust",
"repo": "i5possible/datum",
"path": "/dc_compiler/src/neat/namespace.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Start the operator
let task = operator.run(num_operations.unwrap_or(u64::MAX));
tasks.push(task);
senders.push(sender);
}
// Send the initial block path to all operators
for sender in senders.iter_mut() {
let _ = sender.send(instance.block_path()).a... | code_fim | hard | {
"lang": "rust",
"repo": "Eissen/fuchsia",
"path": "/src/storage/stress-tests/fvm/lib/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eissen/fuchsia path: /src/storage/stress-tests/fvm/lib/mod.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.
pub mod fvm;
pub mod operator;
use {
fidl_fuchsia_hardware_block... | code_fim | hard | {
"lang": "rust",
"repo": "Eissen/fuchsia",
"path": "/src/storage/stress-tests/fvm/lib/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Give the new block path to the operators.
// Ignore the result because some operators may have completed.
let path = instance.block_path();
for sender in senders.iter_mut() {
let _ = sender.send(path.clone()).await;
... | code_fim | hard | {
"lang": "rust",
"repo": "Eissen/fuchsia",
"path": "/src/storage/stress-tests/fvm/lib/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Digus12/rays.rs path: /tests/color.rs
extern crate rays;
#[cfg(test)]
mod color_test {
use rays::color::*;
#[test]
fn creation() {
let c = Color::new(0.0, 1.0, 0.0);
assert_eq!(c.red, 0.0);
assert_eq!(c.green, 1.0);
assert_eq!(c.blue, 0.0);
}
#[test]
fn add() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Digus12/rays.rs",
"path": "/tests/color.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn to_pixel() {
let a = Color::new(-1.0, 1.5, 0.5);
let pix = a.to_pixel();
assert_eq!(pix[0], 0);
assert_eq!(pix[1], 255);
assert_eq!(pix[2], 128);
}
}<|fim_prefix|>// repo: Digus12/rays.rs path: /tests/color.rs
extern crate rays;
#[cfg(test)]
mod color_test {
use ... | code_fim | hard | {
"lang": "rust",
"repo": "Digus12/rays.rs",
"path": "/tests/color.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(b.red, 0.0);
assert_eq!(b.green, 1.0);
assert_eq!(b.blue, 0.5);
}
#[test]
fn to_pixel() {
let a = Color::new(-1.0, 1.5, 0.5);
let pix = a.to_pixel();
assert_eq!(pix[0], 0);
assert_eq!(pix[1], 255);
assert_eq!(pix[2], 128);
}
}<|fim_prefix|>// repo: Dig... | code_fim | medium | {
"lang": "rust",
"repo": "Digus12/rays.rs",
"path": "/tests/color.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_failure_kill_dependents() {
test_failure_strategy("kill-dependents");
}
fn restart_backoff(should_contain: bool, attempts: u32) {
let (mut cmd, temp_dir) = get_cli();
let failing_once_script = format!(
r#"#!/bin/bash
echo starting
if [ ! -f {0} ]; then
echo... | code_fim | hard | {
"lang": "rust",
"repo": "vascofazza/Horust",
"path": "/tests/horust.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vascofazza/Horust path: /tests/horust.rs
use assert_cmd::prelude::*;
use libc::pid_t;
use nix::sys::signal::kill;
use nix::sys::signal::Signal;
use nix::unistd::Pid;
use predicates::prelude::*;
use predicates::str::contains;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use... | code_fim | hard | {
"lang": "rust",
"repo": "vascofazza/Horust",
"path": "/tests/horust.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_termination_die_if_failed() {
let (cmd, temp_dir) = get_cli();
let script = r#"#!/bin/bash
while true ; do
sleep 1
done
"#;
let service = r#"[termination]
wait = "0s"
die-if-failed = ["a.toml"]"#;
store_service(temp_dir.path(), script, Some(service), None);
let scr... | code_fim | hard | {
"lang": "rust",
"repo": "vascofazza/Horust",
"path": "/tests/horust.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const HFUNC_APPROVE: ScHname = ScHname(0xa0661268);
pub const HFUNC_INIT: ScHname = ScHname(0x1f44d644);
pub const HFUNC_TRANSFER: ScHname = ScHname(0xa15da184);
pub const HFUNC_TRANSFER_FROM: ScHname = ScHname(0xd5e0a602);
pub const HVIEW_ALLOWANCE: ScHname = ScHname(0x5e16006... | code_fim | hard | {
"lang": "rust",
"repo": "MR1991/wasp",
"path": "/contracts/wasm/erc20/src/consts.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const SC_NAME: &str = "erc20";
pub const SC_DESCRIPTION: &str = "ERC-20 PoC for IOTA Smart Contracts";
pub const HSC_NAME: ScHname = ScHname(0x200e3733);
pub const PARAM_ACCOUNT: &str = "ac";
pub const PARAM_AMOUNT: &str = "am";
pub const PARAM_CREATOR: &str = "c";
pub const PA... | code_fim | medium | {
"lang": "rust",
"repo": "MR1991/wasp",
"path": "/contracts/wasm/erc20/src/consts.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MR1991/wasp path: /contracts/wasm/erc20/src/consts.rs
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
// (Re-)generated by schema tool
// >>>> DO NOT CHANGE THIS FILE! <<<<
// Change the json schema instead
// @formatter:off
#![allow(dead_code)]
use wasmlib::*;
pub co... | code_fim | hard | {
"lang": "rust",
"repo": "MR1991/wasp",
"path": "/contracts/wasm/erc20/src/consts.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> () // not used
}
}
impl MBC0 {
pub fn new(rom: Vec<u8>) -> Self {
Self { rom }
}
}<|fim_prefix|>// repo: ElijahWoelbing/rust-dmg path: /src/mbc/mbc0.rs
use crate::mbc::MBC;
pub struct MBC0 {
rom: Vec<u8>,
}
impl MBC for MBC0 {
fn read_rom(&self, address: u16) -> u8 ... | code_fim | medium | {
"lang": "rust",
"repo": "ElijahWoelbing/rust-dmg",
"path": "/src/mbc/mbc0.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ElijahWoelbing/rust-dmg path: /src/mbc/mbc0.rs
use crate::mbc::MBC;
pub struct MBC0 {
rom: Vec<u8>,
}
impl MBC for MBC0 {
fn read_rom(&self, address: u16) -> u8 {
self.rom[address as usize]
}
fn write_rom(&mut self, address: u16, value: u8) {
() // not used
... | code_fim | medium | {
"lang": "rust",
"repo": "ElijahWoelbing/rust-dmg",
"path": "/src/mbc/mbc0.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> () // not used
}
fn read_ram(&self, address: u16) -> u8 {
0 // not used
}
fn write_ram(&mut self, address: u16, value: u8) {
() // not used
}
}
impl MBC0 {
pub fn new(rom: Vec<u8>) -> Self {
Self { rom }
}
}<|fim_prefix|>// repo: ElijahWoe... | code_fim | medium | {
"lang": "rust",
"repo": "ElijahWoelbing/rust-dmg",
"path": "/src/mbc/mbc0.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: diesel-rs/diesel path: /diesel/src/type_impls/decimal.rs
#![allow(dead_code)]
#[cfg(feature = "bigdecimal")]
mod bigdecimal {
extern crate bigdecimal;
<|fim_suffix|>ion::AsExpression;
use crate::sql_types::Numeric;
#[derive(AsExpression, FromSqlRow)]
#[diesel(foreign_derive)]
... | code_fim | medium | {
"lang": "rust",
"repo": "diesel-rs/diesel",
"path": "/diesel/src/type_impls/decimal.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ion::AsExpression;
use crate::sql_types::Numeric;
#[derive(AsExpression, FromSqlRow)]
#[diesel(foreign_derive)]
#[diesel(sql_type = Numeric)]
struct BigDecimalProxy(BigDecimal);
}<|fim_prefix|>// repo: diesel-rs/diesel path: /diesel/src/type_impls/decimal.rs
#![allow(dead_code)]
#[c... | code_fim | medium | {
"lang": "rust",
"repo": "diesel-rs/diesel",
"path": "/diesel/src/type_impls/decimal.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vminkov/ink-substrate-issue path: /sub/lib.rs
#![cfg_attr(not(feature = "std"), no_std)]
pub use self::sub::Subcontract;
use ink_lang as ink;
<|fim_suffix|> impl Subcontract {
#[ink(constructor)]
pub fn new(init_value: u32) -> Self {
Self { value: init_value }
... | code_fim | medium | {
"lang": "rust",
"repo": "vminkov/ink-substrate-issue",
"path": "/sub/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[ink(message)]
pub fn get(&self) -> u32 {
self.value
}
}
}<|fim_prefix|>// repo: vminkov/ink-substrate-issue path: /sub/lib.rs
#![cfg_attr(not(feature = "std"), no_std)]
pub use self::sub::Subcontract;
use ink_lang as ink;
<|fim_middle|>#[ink::contract]
mod sub ... | code_fim | hard | {
"lang": "rust",
"repo": "vminkov/ink-substrate-issue",
"path": "/sub/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl Subcontract {
#[ink(constructor)]
pub fn new(init_value: u32) -> Self {
Self { value: init_value }
}
#[ink(message)]
pub fn get(&self) -> u32 {
self.value
}
}
}<|fim_prefix|>// repo: vminkov/ink-substrate-issue path: /s... | code_fim | medium | {
"lang": "rust",
"repo": "vminkov/ink-substrate-issue",
"path": "/sub/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: data-niklas/cash2 path: /backend/src/values/function.rs
use crate::ast::Node;
use crate::context::Context;
use crate::value::{Value, ValueResult};
use crate::values::ReturnValue;
use crate::error::CashError;
use crate::context::LockableContext;
use std::sync::Arc;
#[derive(Debug)]
pub struct ... | code_fim | hard | {
"lang": "rust",
"repo": "data-niklas/cash2",
"path": "/backend/src/values/function.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ctx = Context::from_parent(self.ctx.clone());
let param_count = params.len();
if param_count > self.params.len() {
return CashError::InvalidParameterCount(param_count, self.params.len()).boxed();
}
let mut user_values = params.into_iter();
{
... | code_fim | hard | {
"lang": "rust",
"repo": "data-niklas/cash2",
"path": "/backend/src/values/function.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn call(&self, params: Vec<Box<dyn Value>>, _ctx: LockableContext) -> ValueResult {
let ctx = Context::from_parent(self.ctx.clone());
let param_count = params.len();
if param_count > self.params.len() {
return CashError::InvalidParameterCount(param_count, self.param... | code_fim | hard | {
"lang": "rust",
"repo": "data-niklas/cash2",
"path": "/backend/src/values/function.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clay-rs/clay-core path: /src/process/render.rs
use std::{
path::Path,
collections::HashSet,
marker::PhantomData,
time::{Instant, Duration},
};
use ocl::{self, prm, builders::KernelBuilder};
use ocl_include::{Hook, MemHook, ListHook};
use crate::{
prelude::*,
scene::Scene,... | code_fim | hard | {
"lang": "rust",
"repo": "clay-rs/clay-core",
"path": "/src/process/render.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.scene_data.args_set(j, k)?;
j += S::Data::args_count();
self.view_data.args_set(j, k)?;
//j += V::Data::args_count();
Ok(())
}
}
/// Worker of the renderer.
///
/// It actually runs ray tracing process on the specific device and handles render data.
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "clay-rs/clay-core",
"path": "/src/process/render.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Container {
name: "ubuntu".into(),
tag: "xenial".into(),
}
}
}
impl Container {
/// Initialize a container struct
///
/// This will split the container on `:` to actually fetch the tag, and if no tag
/// was present, it will assume tag is latest... | code_fim | hard | {
"lang": "rust",
"repo": "lalbuild/lal",
"path": "/src/core/container.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lalbuild/lal path: /src/core/container.rs
use std::fmt;
/// Representation of a docker container image
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Container {
/// The fully qualified image name
pub name: String,
/// The tag to use
pub tag: String,
}
<|fim_suffix|... | code_fim | hard | {
"lang": "rust",
"repo": "lalbuild/lal",
"path": "/src/core/container.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FuGangqiang/mdblog.rs path: /src/post.rs
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
use chrono::{DateTime, Local};
use log::debug;
use serde::{Deserialize, Serialize};
use crate::error::{Error, Result};
use crate::utils::markdown_to_html;
/// blog post headers
///
/... | code_fim | hard | {
"lang": "rust",
"repo": "FuGangqiang/mdblog.rs",
"path": "/src/post.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v: Vec<&str> = content.splitn(2, "\n\n").collect();
if v.len() != 2 {
return Err(Error::PostOnlyOnePart(path.into()));
}
let head = v[0].trim();
let body = v[1].trim();
if head.is_empty() {
return Err(Error::PostNoHead(path.into()... | code_fim | hard | {
"lang": "rust",
"repo": "FuGangqiang/mdblog.rs",
"path": "/src/post.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvertescher/psoc6-pac path: /src/usbfs0/usblpm/intr_lvl_sel.rs
#[doc = "Reader of register INTR_LVL_SEL"]
pub type R = crate::R<u32, super::INTR_LVL_SEL>;
#[doc = "Writer for register INTR_LVL_SEL"]
pub type W = crate::W<u32, super::INTR_LVL_SEL>;
#[doc = "Register INTR_LVL_SEL `reset()`'s with ... | code_fim | hard | {
"lang": "rust",
"repo": "mvertescher/psoc6-pac",
"path": "/src/usbfs0/usblpm/intr_lvl_sel.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline(always)]
pub fn ep3_lvl_sel(&self) -> EP3_LVL_SEL_R {
EP3_LVL_SEL_R::new(((self.bits >> 20) & 0x03) as u8)
}
#[doc = "Bits 22:23 - EP4 Interrupt level select"]
#[inline(always)]
pub fn ep4_lvl_sel(&self) -> EP4_LVL_SEL_R {
EP4_LVL_SEL_R::new(((self.bits >> 22) ... | code_fim | hard | {
"lang": "rust",
"repo": "mvertescher/psoc6-pac",
"path": "/src/usbfs0/usblpm/intr_lvl_sel.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ptal/pcp path: /src/libpcp/propagators/cumulative.rs
// Copyright 2016 Pierre Talbot (IRCAM)
// 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.apach... | code_fim | hard | {
"lang": "rust",
"repo": "ptal/pcp",
"path": "/src/libpcp/propagators/cumulative.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.resources[i].bclone()
}
fn capacity_var(&self) -> Var<VStore> {
self.capacity.bclone()
}
}
#[cfg(test)]
mod test {
use super::*;
use kernel::*;
use trilean::SKleene;
use trilean::SKleene::*;
use variable::VStoreCopy;
use propagation::CStoreFD;
use interval::interval::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "ptal/pcp",
"path": "/src/libpcp/propagators/cumulative.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrey-ve/pmdk-rs path: /pmdk-sys/src/obj.rs
//
// Copyright (c) 2019 RepliXio Ltd. All rights reserved.
// Use is subject to license terms.
//
use libc::{c_char, c_int, c_void};
use libc::{mode_t, size_t};
use crate::PMEMoid;
pub enum PMEMobjpool {}
#[allow(non_camel_case_types)]
pub type p... | code_fim | hard | {
"lang": "rust",
"repo": "andrey-ve/pmdk-rs",
"path": "/pmdk-sys/src/obj.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn pmemobj_first(pop: *const PMEMobjpool) -> PMEMoid;
pub fn pmemobj_next(oid: PMEMoid) -> PMEMoid;
pub fn pmemobj_ctl_exec(pop: *mut PMEMobjpool, name: *const c_char, arg: *mut c_void) -> c_int;
pub fn pmemobj_ctl_get(pop: *mut PMEMobjpool, name: *const c_char, arg: *mut c_void) -> c... | code_fim | medium | {
"lang": "rust",
"repo": "andrey-ve/pmdk-rs",
"path": "/pmdk-sys/src/obj.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nihn/eurostartrainfinder path: /src/main.rs
extern crate structopt;
use chrono::{Duration, NaiveDate, NaiveTime, Weekday};
use clap::arg_enum;
use log::{debug, error, info};
use prettytable::{cell, format, row, Table};
use std::collections::HashMap;
use stderrlog;
use structopt::{clap, StructOp... | code_fim | hard | {
"lang": "rust",
"repo": "nihn/eurostartrainfinder",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// How many adults
#[structopt(long, default_value = "1")]
adults: i16,
/// Start station
#[structopt(default_value = "London")]
from: String,
/// Finish station
#[structopt(default_value = "Paris")]
to: String,
}
#[tokio::main]
async fn main() {
let opt = Opt::... | code_fim | hard | {
"lang": "rust",
"repo": "nihn/eurostartrainfinder",
"path": "/src/main.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.