text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: choubacha/kv-raft path: /src/public/proto/public.rs
::default_instance(),
}
}
// .public.request.Scan scan = 4;
pub fn clear_scan(&mut self) {
self.kind = ::std::option::Option::None;
}
pub fn has_scan(&self) -> bool {
match self.kind {
... | code_fim | hard | {
"lang": "rust",
"repo": "choubacha/kv-raft",
"path": "/src/public/proto/public.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Parse model name from file name
pub fn parse_name_from_path(path: &str) -> Result<String, ProbabilityModelError> {
// only build regex once
lazy_static! {
static ref GET_NAME: Regex =
Regex::new(r"\./data(?:/models(/ascii|/alphanum)?)?/([a-zA-Z0-9_]+... | code_fim | hard | {
"lang": "rust",
"repo": "PhilippGawlik/naive_langguesser",
"path": "/src/models/probability_model.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PhilippGawlik/naive_langguesser path: /src/models/probability_model.rs
use models::count_model::CountModel;
use models::errors::ProbabilityModelError;
use models::ngram_model::NGramModel;
use regex::Regex;
use std::collections::HashMap;
use std::fs;
use std::io;
// necessary import for .lines() ... | code_fim | hard | {
"lang": "rust",
"repo": "PhilippGawlik/naive_langguesser",
"path": "/src/models/probability_model.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let raw_text = String::from("aabcbaa\t");
let ngram_length: usize = 2;
let set_marker: Option<u8> = Some(35);
let sigma: Sigma = Sigma::new(set_marker, SigmaType::AlphaNum);
let smoothing_type: SmoothingType = SmoothingType::NoSmoothing;
let mut text_model =... | code_fim | hard | {
"lang": "rust",
"repo": "PhilippGawlik/naive_langguesser",
"path": "/src/models/probability_model.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Winwardo/matasano-crypto-challenges path: /src/cbc.rs
use aes::*;
use block_cipher_operation::*;
use byte_conversion::*;
use byte_manipulation::*;
use ciphertext::*;
use key::*;
pub struct CBC {
pub initialisation_vector: Vec<u8>,
pub input: PaddedBytes,
pub key: RepeatingKey,
}
im... | code_fim | hard | {
"lang": "rust",
"repo": "Winwardo/matasano-crypto-challenges",
"path": "/src/cbc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ciphertext = cipher_block.encrypt();
let mut decrypt_cipher = CBC {
input: PaddedBytes::from_bytes(&ciphertext[..], 16).unwrap(),
initialisation_vector: IV(),
key: key(),
};
assert_eq!(plaintext().vec(), &decrypt_cipher.decrypt());
... | code_fim | hard | {
"lang": "rust",
"repo": "Winwardo/matasano-crypto-challenges",
"path": "/src/cbc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let xored = xor_byte_streams(&self.initialisation_vector, self.input.vec());
let key = self.key.of_length(16);
encrypt_aes_128_ecb_no_padding(&xored[..], &key).unwrap()
}
fn decrypt(&mut self) -> Vec<u8> {
let key = self.key.of_length(16);
let decipher = d... | code_fim | hard | {
"lang": "rust",
"repo": "Winwardo/matasano-crypto-challenges",
"path": "/src/cbc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/spi_mem/spi_mem_user.rs
::Type {
0
}
}
#[doc = "Reader of field `SPI_MEM_USR_COMMAND`"]
pub type SPI_MEM_USR_COMMAND_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `SPI_MEM_USR_COMMAND`"]
pub struct SPI_MEM_USR_COMMAND_W<'a> {
w: &... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/spi_mem/spi_mem_user.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>l<'a> SPI_MEM_FWRITE_QUAD_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"W... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/spi_mem/spi_mem_user.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/spi_mem/spi_mem_user.rs
= "Reader of field `SPI_MEM_USR_COMMAND`"]
pub type SPI_MEM_USR_COMMAND_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `SPI_MEM_USR_COMMAND`"]
pub struct SPI_MEM_USR_COMMAND_W<'a> {
w: &'a mut W,
}
impl<'a> SPI_MEM_USR_... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/spi_mem/spi_mem_user.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fangying/paxos-rs path: /examples/http-paxos/commands.rs
use crate::kvstore::KeyValueStore;
use bincode::{deserialize, serialize};
use bytes::Bytes;
use hyper::{client::HttpConnector, Body, Client, Request};
use paxos::{Ballot, Commander, Configuration, NodeId, Sender, Slot, SlottedValue};
use s... | code_fim | hard | {
"lang": "rust",
"repo": "fangying/paxos-rs",
"path": "/examples/http-paxos/commands.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Commander for PaxosCommander {
fn proposal(&mut self, val: Bytes) {
self.send(Command::Proposal(val));
}
fn prepare(&mut self, bal: Ballot) {
self.send(Command::Prepare(bal));
}
fn promise(&mut self, node: NodeId, bal: Ballot, accepted: Vec<SlottedValue>) {
... | code_fim | hard | {
"lang": "rust",
"repo": "fangying/paxos-rs",
"path": "/examples/http-paxos/commands.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut tmp_square = 0;
for i in 0..rectangles.len() {
tmp_square = min(rectangles[i][0], rectangles[i][1]);
if tmp_square > max_square_size {
max_square_size = tmp_square;
max_square_count = 1;
}... | code_fim | medium | {
"lang": "rust",
"repo": "HamzaMouhcine/Leetcode-Rust",
"path": "/1725.-Number-Of-Rectangles-That-Can-Form-The-Largest-Square.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HamzaMouhcine/Leetcode-Rust path: /1725.-Number-Of-Rectangles-That-Can-Form-The-Largest-Square.rs
//https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/
use std::cmp::min;
<|fim_suffix|> let mut tmp_square = 0;
for i in 0..rectangles.len() {
... | code_fim | medium | {
"lang": "rust",
"repo": "HamzaMouhcine/Leetcode-Rust",
"path": "/1725.-Number-Of-Rectangles-That-Can-Form-The-Largest-Square.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if tmp_square > max_square_size {
max_square_size = tmp_square;
max_square_count = 1;
} else if tmp_square == max_square_size {
max_square_count += 1;
}
}
max_square_count
}
}<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "HamzaMouhcine/Leetcode-Rust",
"path": "/1725.-Number-Of-Rectangles-That-Can-Form-The-Largest-Square.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kriomant/mockers path: /examples/air_proc_macro/src/tests.rs
use super::{set_temperature_20, AirConditioner};
use mockers::Scenario;
<|fim_suffix|> let scenario = Scenario::new();
let (mut cond, handle) = scenario.create_mock_for::<dyn AirConditioner>();
scenario.expect(handle.get_t... | code_fim | easy | {
"lang": "rust",
"repo": "kriomant/mockers",
"path": "/examples/air_proc_macro/src/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> scenario.expect(handle.get_temperature().and_return(16));
scenario.expect(handle.make_hotter(4).and_return(()));
set_temperature_20(&mut cond);
}<|fim_prefix|>// repo: kriomant/mockers path: /examples/air_proc_macro/src/tests.rs
use super::{set_temperature_20, AirConditioner};
use mockers::S... | code_fim | medium | {
"lang": "rust",
"repo": "kriomant/mockers",
"path": "/examples/air_proc_macro/src/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lkolbly/wows-armor path: /src/download.rs
use sha2::{Sha256, Digest};
use std::path::Path;
use std::fs;
use flate2::read::GzDecoder;
use std::io::prelude::*;
use log::{warn, info};
//use url::form_urlencoded;
//use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS};
use std::collections... | code_fim | hard | {
"lang": "rust",
"repo": "lkolbly/wows-armor",
"path": "/src/download.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = Path::new("cache/").join(hex::encode(&result[..]));
if path.exists() {
return fs::read_to_string(path).unwrap();
}
let client = reqwest::blocking::Client::new();
let mut raw_params = HashMap::new();
raw_params.insert("view", view);
raw_params.insert("params... | code_fim | hard | {
"lang": "rust",
"repo": "lkolbly/wows-armor",
"path": "/src/download.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let client = reqwest::blocking::Client::new();
let mut raw_params = HashMap::new();
raw_params.insert("view", view);
raw_params.insert("params", params);
let response = client.post(url).form(&raw_params).send().unwrap();
let body = response.bytes().unwrap();
info!("Downloaded... | code_fim | hard | {
"lang": "rust",
"repo": "lkolbly/wows-armor",
"path": "/src/download.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.info.memory_size() as u32
}
/// int: (``u32``) Gets the size in bytes of the memory location or 0 if it's not accessed or unknown
///
/// Examples:
///
/// .. testcode::
///
/// from iced_x86 import *
///
/// info = MemorySizeInfo(MemorySize.UINT32)
/// assert info.size == 4... | code_fim | hard | {
"lang": "rust",
"repo": "icedland/iced",
"path": "/src/rust/iced-x86-py/src/memory_size_info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.info.is_packed()
}
/// int: (``u32``) Gets the number of elements in the packed data type or `1` if it's not packed data (:class:`MemorySizeInfo.is_packed`)
///
/// Examples:
///
/// .. testcode::
///
/// from iced_x86 import *
///
/// info = MemorySizeInfo(MemorySize.UINT32)
//... | code_fim | hard | {
"lang": "rust",
"repo": "icedland/iced",
"path": "/src/rust/iced-x86-py/src/memory_size_info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icedland/iced path: /src/rust/iced-x86-py/src/memory_size_info.rs
// SPDX-License-Identifier: MIT
// Copyright (C) 2018-present iced project and contributors
use crate::enum_utils::to_memory_size;
use pyo3::prelude::*;
/// :class:`MemorySize` enum info, see also :class:`MemorySizeExt`
///
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "icedland/iced",
"path": "/src/rust/iced-x86-py/src/memory_size_info.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Attempt to subtracts the value from the `Counter` using `Ordering::Relaxed` without overflow
pub fn try_decrement(&self, value: T) -> Result<(), ()> {
if self.get() < value {
Err(())
} else {
self.decrement(value);
Ok(())
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/rpc-perf",
"path": "/datastructures/src/counter/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns `Counter` to its default value using `Ordering::SeqCst`
pub fn reset(&self) {
self.set(Default::default())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_counter_u64() {
let counter = Counter::<u64>::default();
assert_eq!(counter.ge... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/rpc-perf",
"path": "/datastructures/src/counter/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/rpc-perf path: /datastructures/src/counter/mod.rs
// Copyright 2019 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use crate::wrapper::Wrapper;
use core::ops::*;
use std::fmt;
use std::sync::atomic::*;
#[derive(Clone)]
//... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/rpc-perf",
"path": "/datastructures/src/counter/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Method {
pub(in crate::endpoint) fn from_endpoint(
value: &serde_json::Value,
http_verb: HttpVerb,
) -> Option<Method> {
match &value.get(http_verb.to_string()) {
Some(serde_json::Value::Object(method)) => {
let params = Params::from_method(method);
Some(Method {... | code_fim | hard | {
"lang": "rust",
"repo": "cdebotton/ApiTools",
"path": "/src/endpoint/method.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub(in crate::endpoint) struct Method {
params: Params,
responses: (),
}
impl Method {
pub(in crate::endpoint) fn from_endpoint(
value: &serde_json::Value,
http_verb: HttpVerb,
) -> Option<Method> {
match &value.get(http_verb.to_string()) {
Some(serde_json::Valu... | code_fim | medium | {
"lang": "rust",
"repo": "cdebotton/ApiTools",
"path": "/src/endpoint/method.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cdebotton/ApiTools path: /src/endpoint/method.rs
use crate::params::Params;
pub enum HttpVerb {
Get,
Put,
Post,
Patch,
Delete,
}
impl HttpVerb {
fn to_string(self) -> &'static str {
<|fim_suffix|>#[derive(Debug)]
pub(in crate::endpoint) struct Method {
params: Params,
responses... | code_fim | medium | {
"lang": "rust",
"repo": "cdebotton/ApiTools",
"path": "/src/endpoint/method.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>crate::impl_for!(impl_prime_iter: unsigned);
pub struct PrimeFactor<T> {
current: T,
primes: Box<dyn Iterator<Item = T>>,
prime: T,
}
macro_rules! impl_prime_factor {
($t:ty) => {
impl PrimeFactor<$t> {
pub fn new(n: $t) -> Box<dyn Iterator<Item = $t>> {
... | code_fim | hard | {
"lang": "rust",
"repo": "irevoire/project_euler",
"path": "/src/prime.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: irevoire/project_euler path: /src/prime.rs
pub trait Prime {
fn is_prime(self) -> bool;
fn all_prime_divisors(self) -> Box<dyn Iterator<Item = Self>>;
}
macro_rules! impl_prime {
($t:ty) => {
impl Prime for $t {
fn is_prime(self) -> bool {
if self... | code_fim | hard | {
"lang": "rust",
"repo": "irevoire/project_euler",
"path": "/src/prime.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lymia/enumset path: /enumset/src/set.rs
.
///
/// This is the same as [`EnumSet::variant_count`] except in enums with "sparse" variants.
/// (e.g. `enum Foo { A = 10, B = 20 }`)
#[inline(always)]
pub fn bit_width() -> u32 {
T::BIT_WIDTH
}
/// The number of va... | code_fim | hard | {
"lang": "rust",
"repo": "Lymia/enumset",
"path": "/enumset/src/set.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Attempts to constructs a bitset from a `[u64; O]`.
///
/// If a bit that doesn't correspond to an enum variant is set, this method will panic.
pub fn from_array<const O: usize>(v: [u64; O]) -> Self {
Self::try_from_array(v).expect("Bitset contains invalid variants.")
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Lymia/enumset",
"path": "/enumset/src/set.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lymia/enumset path: /enumset/src/set.rs
) {
*self = *self & rhs;
}
}
impl<T: EnumSetType, O: Into<EnumSet<T>>> BitOrAssign<O> for EnumSet<T> {
#[inline(always)]
fn bitor_assign(&mut self, rhs: O) {
*self = *self | rhs;
}
}
impl<T: EnumSetType, O: Into<EnumSet<T>>>... | code_fim | hard | {
"lang": "rust",
"repo": "Lymia/enumset",
"path": "/enumset/src/set.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn trace_block(
&self,
ray: Ray3<f64>,
radius: f64,
debug: &mut DebugSection,
) -> Option<(BlockPos, Option<Vector3<i32>>)> {
let mut ret_pos = WorldPos(ray.origin).into();
let mut ret_norm = None;
if trace_ray(ray, radius, |pos, norm| {... | code_fim | hard | {
"lang": "rust",
"repo": "qm3ster/Notcraft",
"path": "/src/engine/world/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qm3ster/Notcraft path: /src/engine/world/mod.rs
use cgmath::{Point3, Vector3, Vector4};
use collision::{Aabb, Aabb3};
use engine::{
render::debug::{DebugSection, Shape},
world::{block::BlockRegistry, chunk::ChunkType},
};
use std::collections::{HashMap, HashSet};
use self::block::BlockI... | code_fim | hard | {
"lang": "rust",
"repo": "qm3ster/Notcraft",
"path": "/src/engine/world/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jedestep/rust-scratchpad path: /src/d_set/main.rs
#[link(name="d_set", vers="1", author="jedestep")];
#[crate_type="lib"];
#[deriving(Eq)]
struct DSet<T> {
value: T,
parent: Option<@mut DSet<T>>,
rank: int
}
impl<T:Eq> DSet<T> {
fn new(val: T) -> @mut DSet<T> {
<|fim_suffix|> if rs.rank <... | code_fim | hard | {
"lang": "rust",
"repo": "jedestep/rust-scratchpad",
"path": "/src/d_set/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rs = self.find();
let ro = other.find();
if rs == ro { return; }
if rs.rank < ro.rank { rs.parent = Some(ro); }
else if rs.rank > ro.rank { ro.parent = Some(rs); }
else { ro.parent = Some(rs); rs.rank += 1; }
}
}<|fim_prefix|>// repo: jedestep/rust-scratchpad path: /src/d_set/main.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "jedestep/rust-scratchpad",
"path": "/src/d_set/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn start_bound(&self) -> Bound<&T> {
}
}<|fim_prefix|>// repo: goose121/bimultimap path: /src/range.rs
pub struct FstRange<T, B: RangeBounds<T>>(B);
impl<T, U, B> RangeBounds<(T, U)> for <|fim_middle|>FstRange<T, B> where
B: RangeBounds<T>
{
| code_fim | easy | {
"lang": "rust",
"repo": "goose121/bimultimap",
"path": "/src/range.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: goose121/bimultimap path: /src/range.rs
pub struct FstRange<T, B: RangeBounds<T>>(<|fim_suffix|>FstRange<T, B> where
B: RangeBounds<T>
{
fn start_bound(&self) -> Bound<&T> {
}
}<|fim_middle|>B);
impl<T, U, B> RangeBounds<(T, U)> for | code_fim | easy | {
"lang": "rust",
"repo": "goose121/bimultimap",
"path": "/src/range.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ArkhamKnightXD/learning-rust path: /src/conditionals.rs
pub fn run(){
let age: u8 = 22;
let check_id: bool = true;
<|fim_suffix|> else if age < 21 && check_id {
println!("es menor de 21");
}
else{
println!("deje ver id");
}
//shorthand if e... | code_fim | hard | {
"lang": "rust",
"repo": "ArkhamKnightXD/learning-rust",
"path": "/src/conditionals.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //shorthand if ejemplo de if corto
let is_of_age = if age >= 21 {true} else {false};
println!("is of age: {}", is_of_age);
}<|fim_prefix|>// repo: ArkhamKnightXD/learning-rust path: /src/conditionals.rs
pub fn run(){
let age: u8 = 22;
let check_id: bool = true;
<|fim_middle|>
... | code_fim | hard | {
"lang": "rust",
"repo": "ArkhamKnightXD/learning-rust",
"path": "/src/conditionals.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn change(&self) -> SchemaChangeType {
FromStr::from_str(&self.change).unwrap()
}
pub fn target(&self) -> SchemaChangeTarget {
FromStr::from_str(&self.change).unwrap()
}
pub fn keyspace(&self) -> &str {
&self.ks
}
pub fn name(&self) -> Option<&Str... | code_fim | hard | {
"lang": "rust",
"repo": "zBaitu/cql-protocol",
"path": "/src/response/event.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(SchemaChange {
change,
target,
ks,
name,
args,
})
}
}
impl_display!(TopologyChange);
impl_display!(StatusChange);
impl_display!(SchemaChange);
macro_rules! match_event_type {
($sf:expr, $($E:ident),+) => (
mat... | code_fim | hard | {
"lang": "rust",
"repo": "zBaitu/cql-protocol",
"path": "/src/response/event.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zBaitu/cql-protocol path: /src/response/event.rs
use crate::codec::*;
use crate::def::*;
use crate::message::*;
use crate::result::*;
use crate::types::*;
use std::{
fmt::{self, Debug, Display, Formatter},
io,
str::FromStr
};
macro_rules! change_event {
($C:ident, $T:ident) => ... | code_fim | hard | {
"lang": "rust",
"repo": "zBaitu/cql-protocol",
"path": "/src/response/event.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: book-resources/rustlernen path: /15-Generics, Traits, Lifetimes/programmtext-263.rs
fn main() {
let s1 = "Hallo, Welt!";
let s2 = String::from("Hallo!");
<|fim_suffix|> if s1.len() > s2.len() {
s1
} else {
s2
}
}<|fim_middle|> println!("{}", some_function(s1, s2.as_str()));
}
... | code_fim | medium | {
"lang": "rust",
"repo": "book-resources/rustlernen",
"path": "/15-Generics, Traits, Lifetimes/programmtext-263.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if s1.len() > s2.len() {
s1
} else {
s2
}
}<|fim_prefix|>// repo: book-resources/rustlernen path: /15-Generics, Traits, Lifetimes/programmtext-263.rs
fn main() {
let s1 = "Hallo, Welt!";
let s2 = String::from("Hallo!");
println!("{}", some_function(s1, s2.as_str()));
}
<|fim_middl... | code_fim | easy | {
"lang": "rust",
"repo": "book-resources/rustlernen",
"path": "/15-Generics, Traits, Lifetimes/programmtext-263.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tychedelia/franz path: /src/network/messages/describe_acls_request.rs
//! THIS CODE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
#![allow(unused)]
use std::borrow::Borrow;
use std::collections::BTreeMap;
use bytes::Bytes;
use log::error;
use franz_protocol::{
Encodable, Decodable, MapEncodabl... | code_fim | hard | {
"lang": "rust",
"repo": "tychedelia/franz",
"path": "/src/network/messages/describe_acls_request.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Encodable for DescribeAclsRequest {
fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<(), EncodeError> {
types::Int8.encode(buf, &self.resource_type_filter)?;
if version == 2 {
types::CompactString.encode(buf, &self.resource_name_filter)?;
} ... | code_fim | hard | {
"lang": "rust",
"repo": "tychedelia/franz",
"path": "/src/network/messages/describe_acls_request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Other tagged fields
pub unknown_tagged_fields: BTreeMap<i32, Vec<u8>>,
}
impl Encodable for DescribeAclsRequest {
fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<(), EncodeError> {
types::Int8.encode(buf, &self.resource_type_filter)?;
if version == 2 {... | code_fim | hard | {
"lang": "rust",
"repo": "tychedelia/franz",
"path": "/src/network/messages/describe_acls_request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Clone)]
struct Config {
pub_keys: Option<Vec<String>>,
}
impl Config {
fn retrieve(yaml: Vec<u8>) -> Result<Config, serde_yaml::Error> {
let config = String::from_utf8(yaml).expect("config utf8 decoding error");
let config: Config = serde_yaml::fro... | code_fim | hard | {
"lang": "rust",
"repo": "aweis89/rust-envoy-filter",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aweis89/rust-envoy-filter path: /src/lib.rs
use jwt_simple::prelude::{JWTClaims, NoCustomClaims};
use log::info;
use proxy_wasm::traits::{Context, HttpContext, RootContext};
use proxy_wasm::types::{Action, ContextType, LogLevel};
use serde::{Deserialize, Serialize};
use serde_json::json;
use ser... | code_fim | hard | {
"lang": "rust",
"repo": "aweis89/rust-envoy-filter",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn set_all_ipv4_fields(b: &mut Bencher) {
let mut buffer = [0; 20];
let source = Ipv4Addr::new(192, 168, 0, 1);
let destination = Ipv4Addr::new(192, 168, 0, 2);
b.iter(|| {
let mut packet = MutIpv4Packet::new(black_box(&mut buffer[..])).unwrap();
packet.set_version... | code_fim | hard | {
"lang": "rust",
"repo": "kkang-wr/rips",
"path": "/packets/benches/packet_headers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kkang-wr/rips path: /packets/benches/packet_headers.rs
#![feature(test)]
extern crate rips_packets;
extern crate test;
use rips_packets::ethernet::{MutEthernetPacket, ether_types};
use rips_packets::ipv4::{self, MutIpv4Packet};
use rips_packets::macaddr::MacAddr;
use std::net::Ipv4Addr;
use te... | code_fim | medium | {
"lang": "rust",
"repo": "kkang-wr/rips",
"path": "/packets/benches/packet_headers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unnsa/rust path: /src/test/rustdoc/foreigntype.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.0 <LICENSE-APACHE or
// http://w... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/rustdoc/foreigntype.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// @has foreigntype/trait.Trait.html '//a[@class="foreigntype"]' 'ExtType'
impl Trait for ExtType {}
// @has foreigntype/index.html '//a[@class="foreigntype"]' 'ExtType'<|fim_prefix|>// repo: unnsa/rust path: /src/test/rustdoc/foreigntype.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIG... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/rustdoc/foreigntype.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ExtType {
// @has - '//a[@class="fnname"]' 'do_something'
pub fn do_something(&self) {}
}
pub trait Trait {}
// @has foreigntype/trait.Trait.html '//a[@class="foreigntype"]' 'ExtType'
impl Trait for ExtType {}
// @has foreigntype/index.html '//a[@class="foreigntype"]' 'ExtType'<|fim_prefix... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/rustdoc/foreigntype.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> the arguments given to the program.
pub fn print_args(args: &Config) {
println!("Received Arguments:");
let mut i = 0;
for a in args.argv.iter() {
println!("[{}] : {}", i, *a);
i += 1;
}
}<|fim_prefix|>// repo: data-pup/pupset path: /src/args.rs
use config::Config;
/// C... | code_fim | medium | {
"lang": "rust",
"repo": "data-pup/pupset",
"path": "/src/args.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: data-pup/pupset path: /src/args.rs
use config::Config;
/// Collect the arguments given to the program.
pub fn collect_args() -> Config {
let<|fim_suffix|> the arguments given to the program.
pub fn print_args(args: &Config) {
println!("Received Arguments:");
let mut i = 0;
for a... | code_fim | medium | {
"lang": "rust",
"repo": "data-pup/pupset",
"path": "/src/args.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drew-y/rustracer path: /examples/simple_light.rs
extern crate rustracer;
use rustracer::geometry::*;
use rustracer::material::{self, Material};
use rustracer::texture::*;
use rustracer::tracer::*;
use std::sync::Arc;
pub fn simple_light() -> Scene {
let mut list: Vec<Box<dyn Hitable>> = Ve... | code_fim | hard | {
"lang": "rust",
"repo": "drew-y/rustracer",
"path": "/examples/simple_light.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Component, Default)]
#[storage(NullStorage)]
pub struct Movable;
#[derive(Component, Default)]
#[storage(NullStorage)]
pub struct Immovable;<|fim_prefix|>// repo: fineconstant/rust_sokoban path: /src/component/mod.rs
use crate::component::position::Position;
use core::fmt;
use specs::{Component... | code_fim | hard | {
"lang": "rust",
"repo": "fineconstant/rust_sokoban",
"path": "/src/component/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Component, Default)]
#[storage(NullStorage)]
pub struct Player {}
#[derive(Component)]
#[storage(VecStorage)]
pub struct CrateObj {
pub colour: BoxColour,
}
#[derive(Component)]
#[storage(VecStorage)]
pub struct CrateSpot {
pub colour: BoxColour,
}
#[derive(Component, Default)]
#[stora... | code_fim | hard | {
"lang": "rust",
"repo": "fineconstant/rust_sokoban",
"path": "/src/component/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fineconstant/rust_sokoban path: /src/component/mod.rs
use crate::component::position::Position;
use core::fmt;
use specs::{Component, NullStorage, VecStorage, World, WorldExt};
use std::fmt::{Display, Formatter};
use crate::component::renderable::Renderable;
use crate::component::box_colour::Box... | code_fim | hard | {
"lang": "rust",
"repo": "fineconstant/rust_sokoban",
"path": "/src/component/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self: Pin<&mut Self>,
_cx: &mut task::Context<'_>,
) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn poll_close(
self: Pin<&mut Self>,
_cx: &mut task::Context<'_>,
) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Joshuaweiss/embrio-rs",
"path": "/embrio-core/src/io/cursor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_mut(&mut self) -> &mut T {
&mut self.inner
}
pub fn position(&self) -> usize {
self.position
}
}
impl<T: AsMut<[u8]>> Write for Cursor<T>
where
Self: Unpin,
{
type Error = !;
fn poll_write(
mut self: Pin<&mut Self>,
_cx: &mut task::... | code_fim | hard | {
"lang": "rust",
"repo": "Joshuaweiss/embrio-rs",
"path": "/embrio-core/src/io/cursor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Joshuaweiss/embrio-rs path: /embrio-core/src/io/cursor.rs
use core::{
cmp, fmt,
marker::Unpin,
pin::Pin,
task::{self, Poll},
};
use crate::io::Write;
pub struct Cursor<T: AsMut<[u8]>> {
inner: T,
position: usize,
}
impl<T: AsMut<[u8]>> Cursor<T> {
pub fn new(inner:... | code_fim | hard | {
"lang": "rust",
"repo": "Joshuaweiss/embrio-rs",
"path": "/embrio-core/src/io/cursor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:Mapping;
pub use memory_set::MemorySet;
pub use satp::Satp;<|fim_prefix|>// repo: VT-Tuzki/tornado-os path: /tornado-kernel/src/memory/mapping.rs
mod page_table_entry;
mod page_table;
mod segment;
mod mapping;
mod memory_set;
mod satp;
pub use page_table_entry::F<|fim_middle|>lags;
pub use segment::{Se... | code_fim | easy | {
"lang": "rust",
"repo": "VT-Tuzki/tornado-os",
"path": "/tornado-kernel/src/memory/mapping.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VT-Tuzki/tornado-os path: /tornado-kernel/src/memory/mapping.rs
mod page_table_entry;
mod page_table;
mod segment;
mod mapp<|fim_suffix|>lags;
pub use segment::{Segment, MapType};
pub use mapping::Mapping;
pub use memory_set::MemorySet;
pub use satp::Satp;<|fim_middle|>ing;
mod memory_set;
mod s... | code_fim | easy | {
"lang": "rust",
"repo": "VT-Tuzki/tornado-os",
"path": "/tornado-kernel/src/memory/mapping.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steveklabnik/simplot.rs path: /src/candlestick.rs
use std::str::MaybeOwned;
use color::Color;
use display::Display;
use {LineType, Script, Solid};
pub struct Properties {
color: Option<Color>,
label: Option<MaybeOwned<'static>>,
line_type: LineType,
linewidth: Option<f64>,
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/simplot.rs",
"path": "/src/candlestick.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(lw) = self.linewidth {
script.push_str(format!("lw {} ", lw)[])
}
if let Some(color) = self.color {
script.push_str(format!("lc rgb '{}' ", color.display())[]);
}
if let Some(ref label) = self.label {
script.push_str... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/simplot.rs",
"path": "/src/candlestick.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl Script for Properties {
fn script(&self) -> String {
let mut script = "with candlesticks ".to_string();
script.push_str(format!("lt {} ", self.line_type.display())[]);
if let Some(lw) = self.linewidth {
script.push_str(format!("lw {} ", lw)[])
}
... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/simplot.rs",
"path": "/src/candlestick.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn hello() {
let mut t = Triangular::new();
println!(
"{} {} {}",
t.next().unwrap(),
t.next().unwrap(),
t.next().unwrap()
);
println!("Hello triangle module!")
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_is_triangular() {
... | code_fim | hard | {
"lang": "rust",
"repo": "dhbradshaw/ProjectEulerFastRust",
"path": "/src/trianglenumbers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_is_triangular() {
assert_eq!(is_triangular(1), true);
assert_eq!(is_triangular(2), false);
assert_eq!(is_triangular(3), true);
assert_eq!(is_triangular(4), false);
assert_eq!(is_triangular(5), false);... | code_fim | hard | {
"lang": "rust",
"repo": "dhbradshaw/ProjectEulerFastRust",
"path": "/src/trianglenumbers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dhbradshaw/ProjectEulerFastRust path: /src/trianglenumbers.rs
pub struct Triangular {
last_added: u64,
sum: u64,
}
impl Triangular {
pub fn new() -> Triangular {
Triangular {
last_added: 0,
sum: 0,
}
}
}
<|fim_suffix|> self.last_ad... | code_fim | medium | {
"lang": "rust",
"repo": "dhbradshaw/ProjectEulerFastRust",
"path": "/src/trianglenumbers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akbandara/aoc-2020-rust path: /src/aoc_2020_solutions/aoc_day6.rs
use crate::aoc_2020_solutions::load_data;
use std::io;
pub fn solve(filename: String, day : usize, part : usize) -> io::Result<()> {
println!("Generating Solution for Advent of Code 2020 - Day {} / Part {}", day, part);
... | code_fim | hard | {
"lang": "rust",
"repo": "akbandara/aoc-2020-rust",
"path": "/src/aoc_2020_solutions/aoc_day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let group_customs_forms = customs_forms.split(|line| line.len() == 0);
let mut group_response_count = 0;
for group_customs_form in group_customs_forms {
if part == 1 {
let mut group_customs_decl = "".to_owned();
for line in group_customs_form {
... | code_fim | hard | {
"lang": "rust",
"repo": "akbandara/aoc-2020-rust",
"path": "/src/aoc_2020_solutions/aoc_day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut group_response_count = 0;
for group_customs_form in group_customs_forms {
if part == 1 {
let mut group_customs_decl = "".to_owned();
for line in group_customs_form {
group_customs_decl.push_str(&line);
}
let ... | code_fim | hard | {
"lang": "rust",
"repo": "akbandara/aoc-2020-rust",
"path": "/src/aoc_2020_solutions/aoc_day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GraphiteEditor/Graphite path: /node-graph/node-macro/src/lib.rs
use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::{format_ident, quote, ToTokens};
use syn::{
parse_macro_input, punctuated::Punctuated, token::Comma, AngleBracketedGenericArguments, AssocType, FnArg, GenericArgument, ... | code_fim | hard | {
"lang": "rust",
"repo": "GraphiteEditor/Graphite",
"path": "/node-graph/node-macro/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for ident in struct_generics.iter() {
args.push(Type::Verbatim(quote::quote!(#ident)));
}
// Generics are simply `S0` through to `Sn-1` where n is the number of secondary inputs
let node_generics = construct_node_generics(&struct_generics);
let future_generic_params = construct_node_generics(&futu... | code_fim | hard | {
"lang": "rust",
"repo": "GraphiteEditor/Graphite",
"path": "/node-graph/node-macro/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> false
} else if player.two_dim.velocity.y < 0. {
let old_y = player.two_dim.bottom();
let possible_new_y = player.two_dim.bottom() + player.two_dim.velocity.y;
let mut new_y = possible_new_y;
let mut player_on_grou... | code_fim | hard | {
"lang": "rust",
"repo": "JoshMcguigan/amethyst-2d-platformer-demo",
"path": "/src/systems/physics.rs",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JoshMcguigan/amethyst-2d-platformer-demo path: /src/systems/physics.rs
use amethyst::{
ecs::{Join, ReadStorage, System, WriteStorage},
};
use crate::{
DISPLAY_WIDTH, PLAYER_W,
components::{Player, TwoDimObject}
};
pub struct PhysicsSystem;
impl<'s> System<'s> for PhysicsSystem {
... | code_fim | hard | {
"lang": "rust",
"repo": "JoshMcguigan/amethyst-2d-platformer-demo",
"path": "/src/systems/physics.rs",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lord-Windy/rust_os path: /Bootloaders/libuefi/src/lib.rs
//!
//!
//!
#![no_std]
#![crate_name="uefi"]
#![crate_type="lib"]
pub enum Void {}
pub type Handle = *mut Void;
pub type Event = *mut Void;
#[repr(C)]
#[derive(Copy,Clone)]
pub struct Status(i32);
impl Status
{
pub fn new(val: i32) -> S... | code_fim | hard | {
"lang": "rust",
"repo": "Lord-Windy/rust_os",
"path": "/Bootloaders/libuefi/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub get_variable: extern "win64" fn(CStr16Ptr, &Guid, Option<&mut u32>, data_size: &mut usize, data: *mut Void) -> Status,
pub get_next_variable_name: extern "win64" fn(&mut usize, *mut u16, &mut Guid) -> Status,
pub set_variable: extern "win64" fn(CStr16Ptr, &Guid, u32, usize, *mut Void) -> Status,
... | code_fim | hard | {
"lang": "rust",
"repo": "Lord-Windy/rust_os",
"path": "/Bootloaders/libuefi/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emirayka/nia_server path: /src/protocol/response/define_mapping_response.rs
use nia_interpreter_core::EventLoopHandle;
use nia_interpreter_core::Interpreter;
use nia_interpreter_core::NiaDefineMappingCommandResult;
use nia_interpreter_core::NiaInterpreterCommand;
use nia_interpreter_core::NiaInt... | code_fim | hard | {
"lang": "rust",
"repo": "emirayka/nia_server",
"path": "/src/protocol/response/define_mapping_response.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut define_mapping_response =
nia_protocol_rust::DefineMappingResponse::new();
match result {
NiaDefineMappingCommandResult::Success() => {
let mut success_result =
nia_protocol_rust::DefineMappingResponse_SuccessResult::new(... | code_fim | hard | {
"lang": "rust",
"repo": "emirayka/nia_server",
"path": "/src/protocol/response/define_mapping_response.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NathanMcMillan54/mdc path: /src/main.rs
use std::env::args;
use std::fs::File;
use std::path::Path;
use std::process::exit;
use std::io::{BufReader, BufRead, Write};
fn main() {
let args: Vec<String> = args().collect();
let file = &args[1];
if !Path::new(file).exists() {
pr... | code_fim | medium | {
"lang": "rust",
"repo": "NathanMcMillan54/mdc",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if md_line.contains("#") {
// <h1>
md_line = md_line.replace("#", "<h1>");
md_line.push_str("</h1>");
} else if md_line.contains("##") {
// <h2>
md_line = md_line.replace("##", "<h2>");
md_line.push_str("</h2>");
... | code_fim | hard | {
"lang": "rust",
"repo": "NathanMcMillan54/mdc",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> output_file.write_fmt(format_args!("{}", "<html>\n<body>\n"));
for line in md_reader.lines() {
let mut md_line = line.unwrap();
if md_line.contains("#") {
// <h1>
md_line = md_line.replace("#", "<h1>");
md_line.push_str("</h1>");
} else... | code_fim | hard | {
"lang": "rust",
"repo": "NathanMcMillan54/mdc",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Print out our settings
println!("{:?}", settings);
}<|fim_prefix|>// repo: mehcode/config-rs path: /examples/hierarchical-env/main.rs
mod settings;
use settings::Settings;
<|fim_middle|>fn main() {
let settings = Settings::new();
| code_fim | easy | {
"lang": "rust",
"repo": "mehcode/config-rs",
"path": "/examples/hierarchical-env/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mehcode/config-rs path: /examples/hierarchical-env/main.rs
mod settings;
use settings::Settings;
<|fim_suffix|> let settings = Settings::new();
// Print out our settings
println!("{:?}", settings);
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "mehcode/config-rs",
"path": "/examples/hierarchical-env/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn join(&self, other: &Self) -> Self {
Self {
min: self.min.min(other.min),
max: self.max.max(other.max),
}
}
pub fn largest_direction(&self) -> Axis {
let extents = self.max - self.min;
if extents.x() > extents.y() {
if... | code_fim | hard | {
"lang": "rust",
"repo": "Vengarioth/7dfps-2020",
"path": "/fpsgame/src/physics/bvh/bounds.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vengarioth/7dfps-2020 path: /fpsgame/src/physics/bvh/bounds.rs
use bevy::math::*;
use crate::math::Ray;
use super::Axis;
#[derive(Debug, Clone)]
pub struct Bounds {
pub min: Vec3,
pub max: Vec3,
}
impl Bounds {
pub fn new(min: Vec3, max: Vec3) -> Self {
Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "Vengarioth/7dfps-2020",
"path": "/fpsgame/src/physics/bvh/bounds.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (tmin, tmax) = min_max(self.min.x(), self.max.x(), ray.origin.x(), ray.direction.x());
let (tymin, tymax) = min_max(self.min.y(), self.max.y(), ray.origin.y(), ray.direction.y());
if tmin > tymax || tymin > tmax {
return false;
}
let tmin = tmin.ma... | code_fim | hard | {
"lang": "rust",
"repo": "Vengarioth/7dfps-2020",
"path": "/fpsgame/src/physics/bvh/bounds.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use Ty::*;
match self {
Bool => write!(f, "Bool"),
Int => write!(f, "Int"),
Unit => write!(f, "Unit"),
Arrow(t1, t2) => {
if let Arrow(_, _) = t1.as_ref() {
write!(f, "({}) -> {}", t1, t2)
}... | code_fim | medium | {
"lang": "rust",
"repo": "Atul9/pijama",
"path": "/pijama_ty/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Atul9/pijama path: /pijama_ty/src/lib.rs
//! Pijama's types.
//!
//! This module exposes the `Ty` type which is the type representation used by the
//! type-checker.
use std::fmt;
use pijama_ast::ty::Ty as TyAST;
/// A type used by the type-checker.
#[derive(Debug, Clone, PartialEq, Eq)]
pub e... | code_fim | hard | {
"lang": "rust",
"repo": "Atul9/pijama",
"path": "/pijama_ty/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: divvun/pahkat-client-sdk-swift path: /crate/pahkat-client-core/src/lib.rs
#![recursion_limit = "2048"]
#![deny(unused_must_use)]
#![deny(rust_2018_idioms)]
pub extern crate pahkat_types as types;
<|fim_suffix|>#[cfg(all(windows, feature = "windows"))]
pub use package_store::windows::WindowsPac... | code_fim | hard | {
"lang": "rust",
"repo": "divvun/pahkat-client-sdk-swift",
"path": "/crate/pahkat-client-core/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "prefix")]
pub use package_store::prefix::PrefixPackageStore;
#[cfg(all(windows, feature = "windows"))]
pub use package_store::windows::WindowsPackageStore;
pub(crate) mod generated {
fbs_build::include_fbs!("index");
}<|fim_prefix|>// repo: divvun/pahkat-client-sdk-swift path: /cra... | code_fim | hard | {
"lang": "rust",
"repo": "divvun/pahkat-client-sdk-swift",
"path": "/crate/pahkat-client-core/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(strings)
}
#[test]
fn test_extract_frontmatter() {
use std::{path::PathBuf};
let fm = Frontmatter::load(&PathBuf::from("fixtures/test_frontmatter.md")).unwrap();
println!("{:?}", kv_to_hash(flatten_yaml(None, &fm.yaml).unwrap()))
}
#[test]
fn test_condense_keys() {
let mut h1 =... | code_fim | hard | {
"lang": "rust",
"repo": "Carrigan/fmp",
"path": "/src/csv_processor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Carrigan/fmp path: /src/csv_processor.rs
use std::{collections::HashMap};
use itertools::Itertools;
use yaml_rust::Yaml;
use super::Frontmatter;
pub fn to_csv(fms: &Vec<Frontmatter>) -> String {
let (flattened, keys) = process_frontmatters(&fms);
let mut output = keys.iter().join(","... | code_fim | hard | {
"lang": "rust",
"repo": "Carrigan/fmp",
"path": "/src/csv_processor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sorted: Vec<String> = Iterator::flatten(mapped)
.unique()
.collect();
sorted.sort();
// Move `date` to front
if let Some(date_index) = sorted.iter().position(|p| p == "date") {
let date = sorted.remove(date_index);
sorted.insert(0, date);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Carrigan/fmp",
"path": "/src/csv_processor.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.