text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>impl From<Option<BlockHeader>> for base_node_proto::BlockHeaderResponse {
fn from(v: Option<BlockHeader>) -> Self {
Self {
header: v.map(Into::into),
}
}
}
impl TryInto<Option<BlockHeader>> for base_node_proto::BlockHeaderResponse {
type Error = String;
fn try... | code_fim | hard | {
"lang": "rust",
"repo": "StriderDM/tari",
"path": "/base_layer/core/src/base_node/proto/response.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (id, document) in documents {
for (field_id, name) in &attributes_for_facetting {
if let Some(value) = document.get(*name) {
match value {
Value::Array(values) => {
for v in values {
add_to_... | code_fim | hard | {
"lang": "rust",
"repo": "tpayet/MeiliSearch",
"path": "/meilisearch-core/src/facets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tpayet/MeiliSearch path: /meilisearch-core/src/facets.rs
use std::borrow::Cow;
use std::collections::HashMap;
use std::hash::Hash;
use std::ops::Deref;
use cow_utils::CowUtils;
use either::Either;
use heed::types::{Str, OwnedType};
use indexmap::IndexMap;
use serde_json::Value;
use meilisearch... | code_fim | hard | {
"lang": "rust",
"repo": "tpayet/MeiliSearch",
"path": "/meilisearch-core/src/facets.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> heed::BytesEncode<'a> for FacetKey {
type EItem = FacetKey;
fn bytes_encode(item: &'a Self::EItem) -> Option<Cow<'a, [u8]>> {
let mut buffer = Vec::with_capacity(2 + item.1.len());
let id = BEU16::new(item.key().into());
let id_bytes = OwnedType::bytes_encode(&id)... | code_fim | hard | {
"lang": "rust",
"repo": "tpayet/MeiliSearch",
"path": "/meilisearch-core/src/facets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hashworks/AoC path: /2019/day12/src/main.rs
use std::collections::HashSet;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::time::Instant;
fn simulate_universe_step(constellations: Vec<[i16; 6]>) -> Vec<[i16; 6]> {
let constellations: Vec<[i16; 6]> = constellations
.cl... | code_fim | hard | {
"lang": "rust",
"repo": "hashworks/AoC",
"path": "/2019/day12/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut constellations: Vec<[i16; 6]> = BufReader::new(File::open("./input").unwrap())
.lines()
.map(|l| {
let xyz = l
.unwrap()
.chars()
.filter(|c| c == &'-' || c == &',' || (c >= &'0' && c <= &'9'))
.collect... | code_fim | hard | {
"lang": "rust",
"repo": "hashworks/AoC",
"path": "/2019/day12/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tyan-boot/ssh-rs path: /src/buffer.rs
#![allow(non_snake_case, non_camel_case_types)]
use libc::{c_int, c_void};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ssh_buffer_struct {
_unused: [u8; 0],
}
<|fim_suffix|> pub fn ssh_buffer_get_len(buffer: ssh_buffer) -> u32;
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "tyan-boot/ssh-rs",
"path": "/src/buffer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn ssh_buffer_add_data(buffer: ssh_buffer, data: *const c_void, len: u32) -> c_int;
pub fn ssh_buffer_get(buffer: ssh_buffer) -> *mut c_void;
pub fn ssh_buffer_get_len(buffer: ssh_buffer) -> u32;
pub fn ssh_buffer_get_data(buffer: ssh_buffer, data: *mut c_void, requestedlen: u32) ->... | code_fim | hard | {
"lang": "rust",
"repo": "tyan-boot/ssh-rs",
"path": "/src/buffer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/testing/sl4f/src/common_utils/macros.rs
// Copyright 2019 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.
//use anyhow::Error;
<|fim_suffix|>#[macro_export]
macro_rules... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/testing/sl4f/src/common_utils/macros.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>use crate::common_utils::error::Sl4fError;
pub mod macros {
pub use crate::parse_arg;
}
#[macro_export]
macro_rules! parse_arg {
($args:ident, $func:ident, $name:expr) => {
match $args.get($name) {
Some(v) => match v.$func() {
Some(val) => Ok(val),
... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/testing/sl4f/src/common_utils/macros.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aabb15768/StellarSQL path: /src/storage/index.rs
use std::fmt;
use std::fs::File;
use std::io::prelude::*;
use std::io::Seek;
use std::io::SeekFrom;
use std::mem;
#[derive(Debug)]
pub enum IndexError {
OpenFileError,
CreateFileError,
BuildIntIndexTableError,
ReadIntIndexTableErr... | code_fim | hard | {
"lang": "rust",
"repo": "aabb15768/StellarSQL",
"path": "/src/storage/index.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // insert into index table in which key type is int
// if work, use b-insert
pub fn insert_int_index_table(
insert_value: IndexDataStructureInt,
index_arr: &mut Vec<IndexDataStructureInt>,
) -> Result<(), IndexError> {
if index_arr.is_empty() {
index_arr... | code_fim | hard | {
"lang": "rust",
"repo": "aabb15768/StellarSQL",
"path": "/src/storage/index.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> table_meta: &TableMeta,
index_arr: &mut Vec<IndexDataStructureString>,
) -> Result<(), IndexError> {
let table_index_name = format!("{}.index", table_meta.table_name);
let mut file = File::open(table_index_name).map_err(|_| IndexError::OpenFileError)?;
let mut b... | code_fim | hard | {
"lang": "rust",
"repo": "aabb15768/StellarSQL",
"path": "/src/storage/index.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Interrupt Descriptor Table
pub struct IDT;
impl IDT {
/// Initialize the IDT
pub fn init() {
// Load the IDT
STATIC_IDT.load();
}
}
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut ExceptionStackFrame) {
log!(fault: "*** BREAKPOINT EXCEPTION\r\n{:#?}", st... | code_fim | hard | {
"lang": "rust",
"repo": "TheKernelCorp/Hydroxide",
"path": "/src/idt.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheKernelCorp/Hydroxide path: /src/idt.rs
use lazy_static::lazy_static;
use x86_64::structures::idt::{ExceptionStackFrame, InterruptDescriptorTable, PageFaultErrorCode};
//
// Constants
//
/// PIT825x interrupt code
pub const INT_PIT: u8 = crate::pic::PIC_1_OFFSET;
<|fim_suffix|>lazy_static! ... | code_fim | medium | {
"lang": "rust",
"repo": "TheKernelCorp/Hydroxide",
"path": "/src/idt.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Standard infor for window
impl RootWindow {
pub fn new() -> RootWindow { RootWindow { height: 50, width: 80 } }
}<|fim_prefix|>// repo: psyomn/wasteland path: /src/ui/root_window.rs
extern crate ncurses;
use self::ncurses::*;
<|fim_middle|>pub struct RootWindow {
height: i16,
width: i16,... | code_fim | medium | {
"lang": "rust",
"repo": "psyomn/wasteland",
"path": "/src/ui/root_window.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: psyomn/wasteland path: /src/ui/root_window.rs
extern crate ncurses;
use self::ncurses::*;
<|fim_suffix|>/// Standard infor for window
impl RootWindow {
pub fn new() -> RootWindow { RootWindow { height: 50, width: 80 } }
}<|fim_middle|>pub struct RootWindow {
height: i16,
width: i16,... | code_fim | medium | {
"lang": "rust",
"repo": "psyomn/wasteland",
"path": "/src/ui/root_window.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> keys.cmp(&other_keys)
}
}
impl<T: Hash + Eq + Ord> PartialOrd for CustomSet<T> {
fn partial_cmp(&self, other: &CustomSet<T>) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<T: Hash + Eq> PartialEq for CustomSet<T> {
fn eq(&self, other: &CustomSet<T>) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "saks/exercism-exercises",
"path": "/rust/custom-set/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saks/exercism-exercises path: /rust/custom-set/src/lib.rs
use std::collections::HashMap;
use std::cmp::Ordering;
use std::hash::Hash;
#[derive(Debug, Eq)]
pub struct CustomSet<T: Hash + Eq> {
data: HashMap<T, bool>,
}
impl<T: Hash + Eq + Clone> CustomSet<T> {
pub fn new(input: Vec<T>) ... | code_fim | hard | {
"lang": "rust",
"repo": "saks/exercism-exercises",
"path": "/rust/custom-set/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::new(data)
}
pub fn difference(&self, other: &CustomSet<T>) -> CustomSet<T> {
let data: Vec<_> = self.data
.keys()
.cloned()
.filter(|k| !other.data.contains_key(k))
.collect();
CustomSet::new(data)
}
}
impl<T: Has... | code_fim | hard | {
"lang": "rust",
"repo": "saks/exercism-exercises",
"path": "/rust/custom-set/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mebus/nalgebra path: /src/geometry/rotation.rs
on-serialize")]
use abomonation::Abomonation;
use simba::scalar::RealField;
use simba::simd::SimdRealField;
use crate::base::allocator::Allocator;
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
use crate::base::{DefaultAllocato... | code_fim | hard | {
"lang": "rust",
"repo": "Mebus/nalgebra",
"path": "/src/geometry/rotation.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Transposes `self`.
///
/// Same as `.inverse()` because the inverse of a rotation matrix is its transform.
///
/// # Example
/// ```
/// # #[macro_use] extern crate approx;
/// # use nalgebra::{Rotation2, Rotation3, Vector3};
/// let rot = Rotation3::new(Vector3::ne... | code_fim | hard | {
"lang": "rust",
"repo": "Mebus/nalgebra",
"path": "/src/geometry/rotation.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mebus/nalgebra path: /src/geometry/rotation.rs
uffer: Copy,
{
}
impl<N: Scalar, D: DimName> Clone for Rotation<N, D>
where
DefaultAllocator: Allocator<N, D, D>,
<DefaultAllocator as Allocator<N, D, D>>::Buffer: Clone,
{
#[inline]
fn clone(&self) -> Self {
Self::from_matr... | code_fim | hard | {
"lang": "rust",
"repo": "Mebus/nalgebra",
"path": "/src/geometry/rotation.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut session = match stomp::session("127.0.0.1", 61613).start() {
Ok(session) => session,
Err(error) => panic!("Could not connect to the server: {}", error)
};
let sub_id = session.subscription(destination, |frame: &Frame| {
message_count += 1;
println!("Received message #{}:... | code_fim | medium | {
"lang": "rust",
"repo": "austinzmchen/stomp-rs",
"path": "/examples/transactions/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: austinzmchen/stomp-rs path: /examples/transactions/src/main.rs
extern crate env_logger;
extern crate stomp;
use stomp::frame::Frame;
use stomp::header::{Header, SuppressedHeader, ContentType};
use stomp::subscription::AckOrNack::Ack;
use stomp::subscription::AckMode;
use stomp::connection::{Hear... | code_fim | hard | {
"lang": "rust",
"repo": "austinzmchen/stomp-rs",
"path": "/examples/transactions/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sub_id = session.subscription(destination, |frame: &Frame| {
message_count += 1;
println!("Received message #{}:\n{}", message_count, frame);
Ack
})
.start();
match session.begin_transaction() {
Ok(mut transaction) => {
transaction.message(destination, "Animal").send... | code_fim | medium | {
"lang": "rust",
"repo": "austinzmchen/stomp-rs",
"path": "/examples/transactions/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn owner(&self) -> &str {
&self.owner
}
pub fn server_type(&self) -> ServerType {
self.tp
}
}<|fim_prefix|>// repo: mendess/rust-fearless-concurrency path: /src/auction_house/droplet.rs
use super::client::Client;
use super::server_type::ServerType;
use std::sync::at... | code_fim | hard | {
"lang": "rust",
"repo": "mendess/rust-fearless-concurrency",
"path": "/src/auction_house/droplet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mendess/rust-fearless-concurrency path: /src/auction_house/droplet.rs
use super::client::Client;
use super::server_type::ServerType;
use std::sync::atomic::{AtomicUsize, Ordering};
<|fim_suffix|>impl Droplet {
pub fn new_reserved(tp :ServerType, owner :&str) -> Self {
Droplet {
... | code_fim | medium | {
"lang": "rust",
"repo": "mendess/rust-fearless-concurrency",
"path": "/src/auction_house/droplet.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new_auctioned(tp :ServerType, owner :&str, value :i32) -> Self {
Droplet {
tp,
id: ID.fetch_add(1, Ordering::SeqCst) as u32,
owner: owner.to_string(),
value: value,
}
}
pub fn id(&self) -> u32 {
self.id
}
... | code_fim | hard | {
"lang": "rust",
"repo": "mendess/rust-fearless-concurrency",
"path": "/src/auction_house/droplet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_native_types_without_attributes(
native_type,
"Decimal",
&error_msg(native_type, "Precision", "1 to 65"),
MYSQL_SOURCE,
);
let native_type = "Decimal(44,33)";
test_native_types_without_attributes(
native_type,
"Decimal",
&error... | code_fim | hard | {
"lang": "rust",
"repo": "2color/prisma-engines",
"path": "/libs/datamodel/core/tests/types/mysql_native_types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 2color/prisma-engines path: /libs/datamodel/core/tests/types/mysql_native_types.rs
use crate::common::*;
use crate::types::helper::{
test_native_types_compatibility, test_native_types_with_field_attribute_support,
test_native_types_without_attributes,
};
use datamodel::{ast, diagnostics:... | code_fim | hard | {
"lang": "rust",
"repo": "2color/prisma-engines",
"path": "/libs/datamodel/core/tests/types/mysql_native_types.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[snafu(display("Malformed expression in value {}: {}", value, source))]
MalformedExpression {
value: String,
source: evalexpr::EvalexprError,
},
#[snafu(display("Verification failed: {}", reason))]
VerificationFailure { reason: String },
}<|fim_prefix|>// repo: bittrance... | code_fim | hard | {
"lang": "rust",
"repo": "bittrance/mqtt-verify",
"path": "/src/errors.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bittrance/mqtt-verify path: /src/errors.rs
use snafu::Snafu;
#[derive(Debug, Snafu)]
pub enum MqttVerifyError {
#[snafu(display("Expected {} to be on format X=Y", input))]
MalformedParameter { input: String },
#[snafu(display("Timer borked: {}", source))]
SourceTimerError { sour... | code_fim | hard | {
"lang": "rust",
"repo": "bittrance/mqtt-verify",
"path": "/src/errors.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn pause(&self);
fn resume(&self);
}<|fim_prefix|>// repo: zyhong/tickrs path: /src/service.rs
pub mod default_timestamps;
pub mod options;
pub mod stock;
<|fim_middle|>/// Container of one or more tasks, that manages capturing all queued task responses
/// into one update response
pub trait Se... | code_fim | medium | {
"lang": "rust",
"repo": "zyhong/tickrs",
"path": "/src/service.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zyhong/tickrs path: /src/service.rs
pub mod default_timestamps;
pub mod options;
pub mod stock;
<|fim_suffix|> fn pause(&self);
fn resume(&self);
}<|fim_middle|>/// Container of one or more tasks, that manages capturing all queued task responses
/// into one update response
pub trait Se... | code_fim | medium | {
"lang": "rust",
"repo": "zyhong/tickrs",
"path": "/src/service.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>he condition to be a boolean.\n\
Note that Passerine does not have a notion of truthiness."
.to_string()
)
}
}<|fim_prefix|>// repo: hhhapz/passerine path: /src/core/control.rs
use crate::common::data::Data;
use crate::core::extract::triop;
/// An implementation of an... | code_fim | medium | {
"lang": "rust",
"repo": "hhhapz/passerine",
"path": "/src/core/control.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>op(data) {
let choice = if condition { option_a } else { option_b };
Ok(choice)
} else {
Err("\
Expected the condition to be a boolean.\n\
Note that Passerine does not have a notion of truthiness."
.to_string()
)
}
}<|fim_prefix|>... | code_fim | medium | {
"lang": "rust",
"repo": "hhhapz/passerine",
"path": "/src/core/control.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hhhapz/passerine path: /src/core/control.rs
use crate::common::data::Data;
use crate::core::extract::triop;
/// An implementation of an if statement, as an FFI.
/// Interesting idea, not sure if I'm going to keep it.
pub fn if_choice(data: Data) -> Result<Data, String> {
if let (Data::Boole... | code_fim | medium | {
"lang": "rust",
"repo": "hhhapz/passerine",
"path": "/src/core/control.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhiqiangxu/rust-tests path: /src/bin/self.rs
struct Test {
consume: u32,
}
impl Test {
fn consume(self) {
<|fim_suffix|>fn main() {
let t = Test { consume: 1 };
t.consume();
// t.consume();
}<|fim_middle|> println!("consume self:{} n:{} {}", self.consume, !3, 0x10000)... | code_fim | medium | {
"lang": "rust",
"repo": "zhiqiangxu/rust-tests",
"path": "/src/bin/self.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let t = Test { consume: 1 };
t.consume();
// t.consume();
}<|fim_prefix|>// repo: zhiqiangxu/rust-tests path: /src/bin/self.rs
struct Test {
consume: u32,
}
<|fim_middle|>impl Test {
fn consume(self) {
println!("consume self:{} n:{} {}", self.consume, !3, 0x10000)... | code_fim | medium | {
"lang": "rust",
"repo": "zhiqiangxu/rust-tests",
"path": "/src/bin/self.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unnsa/rust path: /src/test/run-pass/arbitrary_self_types_pointers_and_wrappers.rs
// Copyright 2017 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.... | code_fim | hard | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/run-pass/arbitrary_self_types_pointers_and_wrappers.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let pw = Ptr(Box::new(Wrapper(5))) as Ptr<Wrapper<dyn Trait>>;
assert_eq!(pw.ptr_wrapper(), 5);
let wp = Wrapper(Ptr(Box::new(6))) as Wrapper<Ptr<dyn Trait>>;
assert_eq!(wp.wrapper_ptr(), 6);
let wpw = Wrapper(Ptr(Box::new(Wrapper(7)))) as Wrapper<Ptr<Wrapper<dyn Trait>>>... | code_fim | hard | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/run-pass/arbitrary_self_types_pointers_and_wrappers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: ?Sized> Deref for Wrapper<T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
impl<T: CoerceUnsized<U>, U> CoerceUnsized<Wrapper<U>> for Wrapper<T> {}
impl<T: DispatchFromDyn<U>, U> DispatchFromDyn<Wrapper<U>> for Wrapper<T> {}
trait Trait {
// This method isn't o... | code_fim | hard | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/run-pass/arbitrary_self_types_pointers_and_wrappers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> - 1) as usize;
for j in 0..n {
if a[i][j] == 1 && (set & (1 << j)) != 0 {
dp[set] += dp[set ^ (1 << j)];
dp[set] %= modp;
}
}
}
let ans = dp[(1 << n) - 1];
println!("{}", ans);
}<|fim_prefix|>// repo: bouzuya/rust-atcoder... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-compete/pastbook2/src/bin/102.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-compete/pastbook2/src/bin/102.rs
use proconio::input;
fn main() {
input! {
n: usize,
a: [[usize; n]; n],
}
let modp = 1_000_000_007_usi<|fim_suffix|>(1 << j)];
dp[set] %= modp;
}
}
}
let an... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-compete/pastbook2/src/bin/102.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>(1 << j)];
dp[set] %= modp;
}
}
}
let ans = dp[(1 << n) - 1];
println!("{}", ans);
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-compete/pastbook2/src/bin/102.rs
use proconio::input;
fn main() {
input! {
n: usize,
a: [[usize... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-compete/pastbook2/src/bin/102.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Content {
anecdote,
container,
index_label,
next,
}
}
}
impl AnecdoteComponent {
fn new(index: usize) -> AnecdoteComponent {
AnecdoteComponent(AtomicUsize::new(index))
}
fn get_index(&self) -> usize {
self.0.l... | code_fim | hard | {
"lang": "rust",
"repo": "jim4067/developer-anecdotes",
"path": "/src/main2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jim4067/developer-anecdotes path: /src/main2.rs
extern crate gtk;
extern crate rand;
use gtk::*;
use rand::{thread_rng, Rng};
use std::process;
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
};
const ANECDOTES_LIST : [&str; 6] = [
"If it hurts, do it more often",
"Addin... | code_fim | hard | {
"lang": "rust",
"repo": "jim4067/developer-anecdotes",
"path": "/src/main2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct App {
pub header: Header,
pub window: Window,
pub content: Content,
}
struct Header {
pub header_container: HeaderBar,
}
struct Content {
pub anecdote: Label,
pub container: Box,
index_label: Label,
pub next: Button,
}
struct AnecdoteComponent(AtomicUsize);
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "jim4067/developer-anecdotes",
"path": "/src/main2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut bakerbird_results: Vec<(usize, usize)> = Vec::new();
stringmatch2d::bakerbird::run(&text_vec, &query_vec, &mut bakerbird_results);
print_and_check_result(
"baker-bird",
&query_vec,
&bakerbird_results,
Some(&naive_results),
);
}<|fim_prefix|>// repo: ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/rust-practice",
"path": "/run/src/run_stringmatch2d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/rust-practice path: /run/src/run_stringmatch2d.rs
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
extern crate stringmatch2d;
use util;
fn print_and_check_result(
name: &str,
query: &Vec<Vec<char>>,
res: &Vec<(usize, usize)>,
answer: Option<&Vec<(usize, ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/rust-practice",
"path": "/run/src/run_stringmatch2d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tspooner/spaces path: /src/option.rs
use crate::{
FiniteSpace, OrderedSpace, Space, IterableSpace,
intervals::bounds::OpenOrClosed,
ops::UnionPair,
prelude::*,
};
pub struct OptionIter<S: IterableSpace>(Option<S::ElemIter>);
impl<S: IterableSpace> Iterator for OptionIter<S> {
... | code_fim | hard | {
"lang": "rust",
"repo": "tspooner/spaces",
"path": "/src/option.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(!a.contains(&-1.0));
assert!(!b.contains(&-1.0));
assert!(a.contains(&0.0));
assert!(b.contains(&0.0));
assert!(!a.contains(&1.0));
assert!(b.contains(&1.0));
}
#[test]
fn test_intersect() {
let e: Option<crate::real::PositiveR... | code_fim | hard | {
"lang": "rust",
"repo": "tspooner/spaces",
"path": "/src/option.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize, Debug)]
pub struct Scene {
pub objects: Vec<Object>,
/// 环境光
env: Vector3f,
/// 环境折射率
n: FloatT,
}
impl Scene {
pub fn hit(&self, ray: &Ray, t_min: FloatT) -> Option<Hit> {
if let Some((object, t, normal, uv)) = self
.objects
.... | code_fim | medium | {
"lang": "rust",
"repo": "function2-llx/ray-tracing",
"path": "/src/scene/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: function2-llx/ray-tracing path: /src/scene/mod.rs
use std::fs;
use serde::Deserialize;
use serde_json::Value;
use crate::graphics::material::{Material, Surface};
use crate::graphics::{Color, HitTemp, Hittable};
use crate::graphics::{Hit, Object};
use crate::math::vector::Vector3f;
use crate::m... | code_fim | medium | {
"lang": "rust",
"repo": "function2-llx/ray-tracing",
"path": "/src/scene/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> writeln!(log_buffer, "This is a string.").unwrap();
writeln!(log_buffer, "This is another string.").unwrap();
writeln!(log_buffer, "This is yet another string.").unwrap();
assert!(!log_buffer.is_empty());
assert_eq!(
log_buffer.extract(),
"This is a string.\nThis is an... | code_fim | medium | {
"lang": "rust",
"repo": "lambdaxymox/log-buffer",
"path": "/examples/vec_storage.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lambdaxymox/log-buffer path: /examples/vec_storage.rs
extern crate log_buffer;
use log_buffer::LogBuffer;
use std::fmt::Write;
<|fim_suffix|> assert!(log_buffer.is_empty());
writeln!(log_buffer, "This is a string.").unwrap();
writeln!(log_buffer, "This is another string.").unwrap()... | code_fim | medium | {
"lang": "rust",
"repo": "lambdaxymox/log-buffer",
"path": "/examples/vec_storage.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", str);
}
fn take_ownership(some_string: &mut String) {
println!("{}", some_string);
some_string.push_str(" - mutated");
}<|fim_prefix|>// repo: RinatValiullov/rust_land path: /ownership_function.rs
fn main() {
let mut str = String::from("Simple string");
<|fim_middle|> ... | code_fim | easy | {
"lang": "rust",
"repo": "RinatValiullov/rust_land",
"path": "/ownership_function.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RinatValiullov/rust_land path: /ownership_function.rs
fn main() {
let mut str = String::from("Simple string");
<|fim_suffix|> println!("{}", some_string);
some_string.push_str(" - mutated");
}<|fim_middle|> take_ownership(&mut str);
println!("{}", str);
}
fn take_ownership(s... | code_fim | medium | {
"lang": "rust",
"repo": "RinatValiullov/rust_land",
"path": "/ownership_function.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaanaslanyuksek/priv-ic path: /backend/libraries/types/src/app_user_id.rs
use candid::{CandidType, Principal};
use serde::{Deserialize, Serialize};
<|fim_suffix|>impl From<Principal> for AppUserId {
fn from(principal: Principal) -> Self {
AppUserId(principal)
}
}
impl From<AppU... | code_fim | medium | {
"lang": "rust",
"repo": "kaanaslanyuksek/priv-ic",
"path": "/backend/libraries/types/src/app_user_id.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> AppUserId(principal)
}
}
impl From<AppUserId> for Principal {
fn from(app_user_id: AppUserId) -> Self {
app_user_id.0
}
}<|fim_prefix|>// repo: kaanaslanyuksek/priv-ic path: /backend/libraries/types/src/app_user_id.rs
use candid::{CandidType, Principal};
use serde::{Deseriali... | code_fim | hard | {
"lang": "rust",
"repo": "kaanaslanyuksek/priv-ic",
"path": "/backend/libraries/types/src/app_user_id.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LazyShpee/bf-rust path: /src/interpreter.rs
use std::fs;
use std::cmp;
use std::io::{stdin, Read, stdout, Write};
use colored::*;
pub struct Options {
pub verbose: bool,
pub tape_dump: bool,
pub color: bool,
pub tape_length: usize,
pub filename: Option<String>,
pub code... | code_fim | hard | {
"lang": "rust",
"repo": "LazyShpee/bf-rust",
"path": "/src/interpreter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if options.verbose { println!("Created VM type {} with code {}", vm.extend, String::from_utf8(vm.tape[vm.code_start..vm.data_start - 1].to_vec()).unwrap_or("INVALID CODE".to_string())) }
vm
}
fn tape_change(&mut self, mode: ChangeMode<u8>) {
match mode {
Chang... | code_fim | hard | {
"lang": "rust",
"repo": "LazyShpee/bf-rust",
"path": "/src/interpreter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>is_none")]
pub resource: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub operation: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
}
#[derive(Clone, Debug, PartialEq,... | code_fim | hard | {
"lang": "rust",
"repo": "MindFlavor/azure-sdk-for-rust",
"path": "/services/mgmt/hybridconnectivity/src/package_2021_10_06_preview/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MindFlavor/azure-sdk-for-rust path: /services/mgmt/hybridconnectivity/src/package_2021_10_06_preview/models.rs
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deser... | code_fim | hard | {
"lang": "rust",
"repo": "MindFlavor/azure-sdk-for-rust",
"path": "/services/mgmt/hybridconnectivity/src/package_2021_10_06_preview/models.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy, Clone)]
pub enum TSpin {
None,
Regular,
Mini,
}
impl From<&TSpinInternal> for TSpin {
fn from(t_spin_internal: &TSpinInternal) -> TSpin {
match t_spin_internal {
TSpinInternal::None => TSpin::None,
TSpinInternal::Regular | TSpinInternal::Poin... | code_fim | hard | {
"lang": "rust",
"repo": "ttaomae/tet-rs",
"path": "/src/engine/base.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ttaomae/tet-rs path: /src/engine/base.rs
}
/// Attempts to hold the current piece if it is one of the specified actions.
/// Returns whether or not the the hold was successful.
fn apply_hold(&mut self, actions: &HashSet<Action>) -> bool {
if actions.contains(&Action::Hold)... | code_fim | hard | {
"lang": "rust",
"repo": "ttaomae/tet-rs",
"path": "/src/engine/base.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ttaomae/tet-rs path: /src/engine/base.rs
layfield::TOTAL_HEIGHT);
if rows > 0 {
self.current_t_spin = TSpinInternal::None;
}
self.notify_observers(|obs| obs.on_hard_drop(rows));
return Option::Some(Action::HardDrop);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ttaomae/tet-rs",
"path": "/src/engine/base.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let node_data = node.node.data();
let node_parent_computed_data = node
.get_parent()
.map(|p| computed[p.node.handle().index()].as_ref().unwrap());
computed[index] = Some(T::compute_hierarchy(node_data, node_parent_computed_data));
});
}... | code_fim | hard | {
"lang": "rust",
"repo": "mikialex/rendiation",
"path": "/utils/tree/src/update_full.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mikialex/rendiation path: /utils/tree/src/update_full.rs
use std::ops::Deref;
use crate::*;
pub trait HierarchyDerived {
type Source;
fn compute_hierarchy(self_source: &Self::Source, parent_derived: Option<&Self>) -> Self;
}
<|fim_suffix|>impl<T: HierarchyDerived> ComputedDerivedTree<T> ... | code_fim | hard | {
"lang": "rust",
"repo": "mikialex/rendiation",
"path": "/utils/tree/src/update_full.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
let h = wind.raw_handle();
let mut w = Window::find_by_handle(h).unwrap();
w.set_color(Color::White);
// wind.set_raw_handle(h);
}
app.run().unwrap();
}<|fim_prefix|>// repo: Zalasus/fltk-rs path: /examples/win_handle.rs
use fltk::{app::*, window::*};... | code_fim | easy | {
"lang": "rust",
"repo": "Zalasus/fltk-rs",
"path": "/examples/win_handle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> wind.end();
wind.show();
unsafe {
let h = wind.raw_handle();
let mut w = Window::find_by_handle(h).unwrap();
w.set_color(Color::White);
// wind.set_raw_handle(h);
}
app.run().unwrap();
}<|fim_prefix|>// repo: Zalasus/fltk-rs path: /examples/win_handle... | code_fim | medium | {
"lang": "rust",
"repo": "Zalasus/fltk-rs",
"path": "/examples/win_handle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Zalasus/fltk-rs path: /examples/win_handle.rs
use fltk::{app::*, window::*};
fn main() {
<|fim_suffix|> wind.end();
wind.show();
unsafe {
let h = wind.raw_handle();
let mut w = Window::find_by_handle(h).unwrap();
w.set_color(Color::White);
// wind.set... | code_fim | medium | {
"lang": "rust",
"repo": "Zalasus/fltk-rs",
"path": "/examples/win_handle.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // This one should never happen.
TableType::AnimFragment(_) => PackedFileType::AnimFragment,
TableType::AnimTable(_) => PackedFileType::AnimTable,
TableType::DependencyManager(_) => PackedFileType::DependencyPackFilesList,
TableType::DB(_) => Pac... | code_fim | hard | {
"lang": "rust",
"repo": "swipswaps/rpfm",
"path": "/rpfm_ui/src/packedfile_views/table/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swipswaps/rpfm path: /rpfm_ui/src/packedfile_views/table/mod.rs
//---------------------------------------------------------------------------//
// Copyright (c) 2017-2020 Ismael Gutiérrez González. All rights reserved.
//
// This file is part of the Rusted PackFile Manager (RPFM) project,
// whi... | code_fim | hard | {
"lang": "rust",
"repo": "swipswaps/rpfm",
"path": "/rpfm_ui/src/packedfile_views/table/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ula-lang/ula path: /src/ast/stmts/if_else.rs
use std::fmt;
use crate::ast::{Expr, Stmt};
use crate::compilation::{Compilable, Scope};
#[derive(Clone)]
pub struct IfElse {
cond: Expr,
body: Vec<Stmt>,
else_body: Option<Vec<Stmt>>,
}
impl IfElse {
pub fn new<T: Into<Expr>>(cond:... | code_fim | hard | {
"lang": "rust",
"repo": "ula-lang/ula",
"path": "/src/ast/stmts/if_else.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref else_body) = self.else_body {
compiled.push_str(&format!("else\r\n{}\r\n", else_body.compile_indented(scope, 1)));
}
compiled.push_str("end");
compiled
}
}
impl Into<Stmt> for IfElse {
fn into(self) -> Stmt {
Stmt::IfElse(self)... | code_fim | medium | {
"lang": "rust",
"repo": "ula-lang/ula",
"path": "/src/ast/stmts/if_else.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn process_transactions(
bank: &Arc<Bank>,
transactions: &[Transaction],
poh_service: &PohService,
) -> Result<Vec<Entry>> {
let mut entries = Vec::new();
debug!("processing: {}", transactions.len());
let mut chunk_start = 0;
while chunk_st... | code_fim | hard | {
"lang": "rust",
"repo": "temptgithub/solana",
"path": "/src/banking_stage.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Process a batch that includes a transaction that receives two tokens.
let alice = Keypair::new();
let tx = Transaction::new(&mint.keypair(), alice.pubkey(), 2, mint.last_id());
let packets = to_packets(&recycler, &[tx]);
verified_sender
.send(vec![(p... | code_fim | hard | {
"lang": "rust",
"repo": "temptgithub/solana",
"path": "/src/banking_stage.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: temptgithub/solana path: /src/banking_stage.rs
//! The `banking_stage` processes Transaction messages. It is intended to be used
//! to contruct a software pipeline. The stage uses all available CPU cores and
//! can do its processing in parallel with signature verification on the GPU.
use bank... | code_fim | hard | {
"lang": "rust",
"repo": "temptgithub/solana",
"path": "/src/banking_stage.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: namachan10777/canorus path: /src/preprocess.rs
use pest::Parser;
use pest::iterators::{Pair, Pairs};
use std::vec::Vec;
#[derive(Parser)]
#[grammar = "step.pest"]
struct StepParser;
#[derive(PartialEq, Debug, Clone)]
pub enum Value {
Float(f64),
Int(i64),
String(String),
Id(u64... | code_fim | hard | {
"lang": "rust",
"repo": "namachan10777/canorus",
"path": "/src/preprocess.rs",
"mode": "psm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match d.as_rule() {
Rule::data => Ok(d
.into_inner()
.map(|d| {
let mut inner = d.into_inner();
let id : Result<u64, PreprocessError> = inner
.next()
.ok_or(PreprocessError::InternalError)?
... | code_fim | hard | {
"lang": "rust",
"repo": "namachan10777/canorus",
"path": "/src/preprocess.rs",
"mode": "spm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{:?}", self)
}
}<|fim_prefix|>// repo: rjmacarthy/bfxrs path: /src/time_frame.rs
use std::fmt;
#[derive(Debug)]
pub enum TimeFrame {
T1m,
T5m,
T15m,
T30m,
T1h,
T3h,
T6h,
T12h,
T1D,
T7D,
T14D,
T1M
}
<|fim_middle|>impl fmt::Display for TimeFrame {
fn fmt(&self, ... | code_fim | medium | {
"lang": "rust",
"repo": "rjmacarthy/bfxrs",
"path": "/src/time_frame.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rjmacarthy/bfxrs path: /src/time_frame.rs
use std::fmt;
#[derive(Debug)]
pub enum TimeFrame {
T1m,
T5m,
T15m,
T30m,
T1h,
T3h,
T6h,
T12h,
T1D,
T7D,
T14D,
T1M
}
<|fim_suffix|> write!(f, "{:?}", self)
}
}<|fim_middle|>impl fmt::Display for TimeFrame {
fn fmt(&self, ... | code_fim | medium | {
"lang": "rust",
"repo": "rjmacarthy/bfxrs",
"path": "/src/time_frame.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.x.distance() as i128 * self.y.distance() as i128 * self.z.distance() as i128
}
fn lower_bound(&self) -> Coordinate {
Coordinate(self.x.0, self.y.0, self.z.0)
}
}
impl Ord for RegionScore {
fn cmp(&self, other: &RegionScore) -> Ordering {
self.potential_bots.cmp(&other.... | code_fim | hard | {
"lang": "rust",
"repo": "dylanowen/advent-of-code-2018",
"path": "/23/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> lowest
}
fn _area(&self) -> i128 {
self.x.distance() as i128 * self.y.distance() as i128 * self.z.distance() as i128
}
fn lower_bound(&self) -> Coordinate {
Coordinate(self.x.0, self.y.0, self.z.0)
}
}
impl Ord for RegionScore {
fn cmp(&self, other: &RegionScore) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "dylanowen/advent-of-code-2018",
"path": "/23/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dylanowen/advent-of-code-2018 path: /23/src/main.rs
use regex::Regex;
use std::option::Option::{Some, None};
use std::cmp::Ordering;
use priority_queue::PriorityQueue;
use common::*;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
struct NanoBot {
location: Coordinate,
radius: i64,
}
#[de... | code_fim | hard | {
"lang": "rust",
"repo": "dylanowen/advent-of-code-2018",
"path": "/23/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dalalsunil1986/Methylenix path: /src/kernel/drivers/efi/mod.rs
//!
//! EFI Functions Manager
//!
//! This manager handles EFI services.
//! Currently, this is not used.
pub mod boot_service {
pub mod memory_map;
}
pub mod table;
pub mod text;
use self::table::EfiTableManager;
use self::tex... | code_fim | medium | {
"lang": "rust",
"repo": "dalalsunil1986/Methylenix",
"path": "/src/kernel/drivers/efi/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct EfiManager {
pub is_valid: bool,
pub table_manager: EfiTableManager,
pub output_manager: EfiTextOutputManager,
}
impl EfiManager {
pub const fn new() -> Self {
EfiManager {
is_valid: false,
table_manager: EfiTableManager::new(),
outpu... | code_fim | medium | {
"lang": "rust",
"repo": "dalalsunil1986/Methylenix",
"path": "/src/kernel/drivers/efi/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LogBlock {
#[serde(with = "b64data")]
pub last_block_hash: Vec<u8>,
pub operation: LogOperation,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "snake_case")]
pub enum LogOperation {
AddWrappedKeys(Vec<Wrap... | code_fim | hard | {
"lang": "rust",
"repo": "ArtDark/sigchain",
"path": "/sigchain_core/src/protocol/logging.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ArtDark/sigchain path: /sigchain_core/src/protocol/logging.rs
use errors::Result;
use b64data;
#[cfg(feature = "db")]
use db;
use team::{TeamPointer, SignedReadToken};
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "snake_case")]
pub enum LogChain {
Create(GenesisLogBl... | code_fim | hard | {
"lang": "rust",
"repo": "ArtDark/sigchain",
"path": "/sigchain_core/src/protocol/logging.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.exclude_response_status_codes && !self.on_response_status_codes.contains(&response_status_code) {
return (Some(self.log_override), self.rule_id.clone(), true);
}
if !self.exclude_response_status_codes && self.on_response_status_codes.iter().any(|v| *v == respon... | code_fim | hard | {
"lang": "rust",
"repo": "redirectionio/libredirectionio",
"path": "/src/action/log_override.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redirectionio/libredirectionio path: /src/action/log_override.rs
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LogOverride {
pub log_override: bool,
pub rule_id: Option<String>,
pub on_response_status_codes: Vec<u16>,
pub exclude... | code_fim | hard | {
"lang": "rust",
"repo": "redirectionio/libredirectionio",
"path": "/src/action/log_override.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Optional: Node hosting this endpoint. This can be used to determine endpoints local to a node.
#[serde(rename = "nodeName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub node_name: Option<String>,
/// Reference to object providing the endpoint.
#[serde(rename = "targe... | code_fim | hard | {
"lang": "rust",
"repo": "kichristensen/k8s-openapi-codegen",
"path": "/k8s-openapi/src/api/core/v1/endpoint_address.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kichristensen/k8s-openapi-codegen path: /k8s-openapi/src/api/core/v1/endpoint_address.rs
// Generated from definition io.k8s.api.core.v1.EndpointAddress
/// EndpointAddress is a tuple that describes single IP address.
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct EndpointAddress ... | code_fim | hard | {
"lang": "rust",
"repo": "kichristensen/k8s-openapi-codegen",
"path": "/k8s-openapi/src/api/core/v1/endpoint_address.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn render_buffer(&mut self) -> Result<(), ()> {
write!(self.stdout, "{}", termion::clear::All);
for r in 0..self.buffer.len() {
write!(self.stdout, "{}", termion::cursor::Goto(1, r as u16 + 1),);
for c in 0..self.buffer[0].len() {
... | code_fim | hard | {
"lang": "rust",
"repo": "gabivlj/tetris-terminal",
"path": "/src/tetris.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gabivlj/tetris-terminal path: /src/tetris.rs
pub mod game {
use crate::pieces;
use crate::pieces::Move;
use crate::utils::{clamp_over, out_of_bounds};
use std::io::{self, Read};
use std::io::{stdin, stdout, Stdin, Stdout, Write};
use std::sync::{Arc, Mutex};
use termi... | code_fim | hard | {
"lang": "rust",
"repo": "gabivlj/tetris-terminal",
"path": "/src/tetris.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ((x, y), rot, piece_buffers) = &self.current_piece;
let piece_buffer = &piece_buffers[*rot as usize];
for row in 0..piece_buffer.len() {
for col in 0..piece_buffer[0].len() {
if piece_buffer[row][col] == pieces::EMPTY_CELL {
... | code_fim | hard | {
"lang": "rust",
"repo": "gabivlj/tetris-terminal",
"path": "/src/tetris.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let b: i64 = get();
let s: Vec<_> = get_word().bytes().map(|b| b as i64 - 0x30).collect();
let n = s.len();
if b <= 9 {
// simply read b-base rep.
let mut cur = 0;
for v in s {
cur *= b;
cur += v;
}
println!("{}", cur);
... | code_fim | hard | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/codeforces/392/2d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sogapalag/contest path: /codeforces/392/2d.rs
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok();
return ret;
}... | code_fim | hard | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/codeforces/392/2d.rs",
"mode": "psm",
"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.