text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>const WEBROOT: &str = "/webroot";
fn make_response(buffer: &[u8]) -> Result<Vec<u8>, Error>{
let http_pattern = Regex::new(r"(.*) (.*) HTTP/1.([0-1])\r\n.*")?;
let captures = match http_pattern.captures(str::from_utf8(buffer)?){
Some(cap) => cap,
None => {
retur... | code_fim | hard | {
"lang": "rust",
"repo": "hsmtkk/psychic-octo-giggle",
"path": "/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hsmtkk/psychic-octo-giggle path: /src/server.rs
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::{BufReader,Read,Write};
use std::str;
use failure::Error;
use mio::{Events, Poll, Interest, Token};
use mio::event::Event;
use mio::net::{TcpListener, TcpStream};
... | code_fim | hard | {
"lang": "rust",
"repo": "hsmtkk/psychic-octo-giggle",
"path": "/src/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let msg_bytes = match outgoing_receiver.recv() {
Ok(msg_bytes) => msg_bytes,
Err(err) => panic!("Received error: {}", err),
};
let network_msg: NetworkMessage = Message::parse_from_bytes(&msg_bytes).unwrap();
let circuit_msg: CircuitMessage =
... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/libsplinter/src/runtime/service/instance/processor/sender.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let network_msg: NetworkMessage = Message::parse_from_bytes(&msg_bytes).unwrap();
let circuit_msg: CircuitMessage =
Message::parse_from_bytes(network_msg.get_payload()).unwrap();
let mut direct_message: CircuitDirectMessage =
Message::parse_from_bytes(circui... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/libsplinter/src/runtime/service/instance/processor/sender.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cargill/splinter path: /libsplinter/src/runtime/service/instance/processor/sender.rs
{
let mut admin_direct_message = AdminDirectMessage::new();
admin_direct_message.set_circuit("admin".into());
admin_direct_message.set_sender(sender.to_string());
admin_direct_mes... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/libsplinter/src/runtime/service/instance/processor/sender.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust-bindgen path: /bindgen-tests/tests/expectations/tests/replace_use.rs
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
/// <div rustbindgen replaces="nsTArray"></div>
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct nsTArray {
pub y... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-bindgen",
"path": "/bindgen-tests/tests/expectations/tests/replace_use.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
::std::mem::size_of::<nsTArray>(),
4usize,
concat!("Size of template specialization: ", stringify!(nsTArray)),
);
assert_eq!(
::std::mem::align_of::<nsTArray>(),
4usize,
concat!("Alignment of template specialization: ", stringify!(nsT... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-bindgen",
"path": "/bindgen-tests/tests/expectations/tests/replace_use.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BlueTheDuck/crustacean_6502_assembler path: /src/parser/mod.rs
use crate::addressing_modes::AddressingMode;
use crate::nom;
use crate::opcodes::OpcodeType;
mod arguments;
mod helpers;
mod lines;
mod types;
<|fim_suffix|>// Public exports
pub use lines::parse_line;
pub use types::{LineType, Nom... | code_fim | medium | {
"lang": "rust",
"repo": "BlueTheDuck/crustacean_6502_assembler",
"path": "/src/parser/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Public exports
pub use lines::parse_line;
pub use types::{LineType, NomError, Value};<|fim_prefix|>// repo: BlueTheDuck/crustacean_6502_assembler path: /src/parser/mod.rs
use crate::addressing_modes::AddressingMode;
use crate::nom;
use crate::opcodes::OpcodeType;
mod arguments;
mod helpers;
mod lines... | code_fim | medium | {
"lang": "rust",
"repo": "BlueTheDuck/crustacean_6502_assembler",
"path": "/src/parser/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: csherratt/amethyst path: /amethyst_renderer/src/pass/shaded.rs
//! Forward physically-based drawing pass.
use std::marker::PhantomData;
use std::mem;
use cgmath::{Matrix4, One};
use gfx::pso::buffer::ElemStride;
use gfx::traits::Pod;
use error::Result;
use light::{DirectionalLight, Light, Poi... | code_fim | hard | {
"lang": "rust",
"repo": "csherratt/amethyst",
"path": "/amethyst_renderer/src/pass/shaded.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let directional_lights: Vec<DirectionalLight> = scene
.par_iter_lights()
.filter_map(|light| if let Light::Directional(ref light) = *light {
Some(light.clone())
} else {
None
})
.collect();
let fra... | code_fim | hard | {
"lang": "rust",
"repo": "csherratt/amethyst",
"path": "/amethyst_renderer/src/pass/shaded.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fragment_args = FragmentArgs {
point_light_count: point_lights.len() as i32,
directional_light_count: directional_lights.len() as i32,
};
effect.update_constant_buffer("FragmentArgs", &fragment_args, enc);
effect.update_buffer("PointLights", &po... | code_fim | hard | {
"lang": "rust",
"repo": "csherratt/amethyst",
"path": "/amethyst_renderer/src/pass/shaded.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gmadrid/yewknit path: /libs/renderer/src/interact/colored.rs
use super::{Interactions, Interactor};
use grids::{CellId, Color, GridTrait};
use std::convert::TryInto;
#[derive(Default)]
pub struct ColoredInteractor {
active: bool,
current_color: Color,
}
impl ColoredInteractor {
pub... | code_fim | hard | {
"lang": "rust",
"repo": "gmadrid/yewknit",
"path": "/libs/renderer/src/interact/colored.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn mouse_exit(&mut self, _: &mut dyn GridTrait, _: CellId) -> bool {
false
}
fn mouse_up(&mut self, _: &mut dyn GridTrait, _: CellId) -> bool {
self.active = false;
false
}
}
impl Interactor for ColoredInteractor {
fn update(
&mut self,
grid: &... | code_fim | hard | {
"lang": "rust",
"repo": "gmadrid/yewknit",
"path": "/libs/renderer/src/interact/colored.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ergoplatform/sigma-rust path: /gf2_192/src/gf2_192poly.rs
//! By Leonid Reyzin
//! This is free and unencumbered software released into the public domain.
//!
//! Anyone is free to copy, modify, publish, use, compile, sell, or
//! distribute this software, either in source code form or as a ... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/gf2_192/src/gf2_192poly.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_interpolation() {
// Try with arrays of length 0
// Constant polynomial with value 0
let mut p = Gf2_192Poly::interpolate(&[], &[], Gf2_192::new()).unwrap();
assert!(p.evaluate(0).is_zero());
assert!(p.evaluate(5).is_zero());
// Con... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/gf2_192/src/gf2_192poly.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: image-rs/image path: /src/codecs/webp/decoder.rs
use byteorder::{LittleEndian, ReadBytesExt};
use std::convert::TryFrom;
use std::io::{self, Cursor, Error, Read};
use std::marker::PhantomData;
use std::{error, fmt, mem};
use crate::error::{DecodingError, ImageError, ImageResult, ParameterError,... | code_fim | hard | {
"lang": "rust",
"repo": "image-rs/image",
"path": "/src/codecs/webp/decoder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(io::Cursor::new(framedata))
}
/// Reads a chunk header FourCC
/// Returns None if and only if we hit end of file reading the four character code of the chunk
/// The inner error is `Err` if and only if the chunk header FourCC is present but unknown
pub(crate) fn read_fourcc<R: Read>(r: &mut R) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "image-rs/image",
"path": "/src/codecs/webp/decoder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(WebPImage::Extended(image))
}
None => Err(ImageError::IoError(Error::from(
io::ErrorKind::UnexpectedEof,
))),
Some((_, chunk)) => Err(DecoderError::ChunkHeaderInvalid(chunk.to_fourcc()).into()),
}
}
fn read... | code_fim | hard | {
"lang": "rust",
"repo": "image-rs/image",
"path": "/src/codecs/webp/decoder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn identifier<'a>() -> impl Parser<'a, Identifier> {
one_or_more(
any_char.pred(|ch| *ch != ':' && *ch != '\n' && *ch != ' ' && *ch != ';')
).map(|chs| chs.iter().collect())
}
fn arg_del<'a>() -> impl Parser<'a, ()> {
ignore_spaces(char(','))
.map(|_| ())
}
fn reg<'a>() -> im... | code_fim | hard | {
"lang": "rust",
"repo": "DeH4er/assembler",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DeH4er/assembler path: /src/parser.rs
use crate::structs::*;
use crate::combinators::*;
pub fn parse(input: &str) -> Vec<Instruction> {
let mut instructions = vec![];
let mut input = input;
while let Some((next_input, instruction)) = instruction().parse(input) {
instruction... | code_fim | hard | {
"lang": "rust",
"repo": "DeH4er/assembler",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: limira/ws_stream_wasm path: /src/ws_event.rs
use crate::{ import::* };
/// Events related to the WebSocket. You can filter like:
///
/// ```
/// use
///{
/// ws_stream_wasm :: * ,
/// pharos :: * ,
/// wasm_bindgen ... | code_fim | hard | {
"lang": "rust",
"repo": "limira/ws_stream_wasm",
"path": "/src/ws_event.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The reason why the connection was closed
/// See: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close)
//
pub reason : String ,
/// Whether the connection was closed cleanly
/// See: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocke... | code_fim | hard | {
"lang": "rust",
"repo": "limira/ws_stream_wasm",
"path": "/src/ws_event.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uuhan/yata path: /src/methods/ema.rs
use crate::core::Method;
use crate::core::{Error, PeriodType, ValueType};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// [Exponential Moving Average](https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average) of specified `... | code_fim | hard | {
"lang": "rust",
"repo": "uuhan/yata",
"path": "/src/methods/ema.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_tema_const() {
for i in 1..255 {
let input = (i as ValueType + 56.0) / 16.3251;
let mut method = TEMA::new(i, input).unwrap();
let output = method.next(input);
test_const_float(&mut method, input, output);
}
}
#[test]
fn test_tema1() {
use super::{Method, TEMA as T... | code_fim | hard | {
"lang": "rust",
"repo": "uuhan/yata",
"path": "/src/methods/ema.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ema1 = alpha * x + (1. - alpha) * prev_value1;
let ema2 = alpha * ema1 + (1. - alpha) * prev_value2;
let ema3 = alpha * ema2 + (1. - alpha) * prev_value3;
prev_value1 = ema1;
prev_value2 = ema2;
prev_value3 = ema3;
let value2 = ema3;
assert_eq_float(value2, value);
... | code_fim | hard | {
"lang": "rust",
"repo": "uuhan/yata",
"path": "/src/methods/ema.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KiChjang/chalk path: /src/db.rs
use crate::error::ChalkError;
use crate::lowering::LowerGoal;
use crate::program::Program;
use crate::query::{Lowering, LoweringDatabase};
use chalk_ir::could_match::CouldMatch;
use chalk_ir::family::ChalkIr;
use chalk_ir::tls;
use chalk_ir::Canonical;
use chalk_i... | code_fim | hard | {
"lang": "rust",
"repo": "KiChjang/chalk",
"path": "/src/db.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.program_ir()
.unwrap()
.impl_data
.iter()
.filter(|(_, impl_datum)| {
impl_datum.trait_id() == trait_id && impl_datum.impl_type == ImplType::Local
})
.map(|(&impl_id, _)| impl_id)
.collect()
... | code_fim | hard | {
"lang": "rust",
"repo": "KiChjang/chalk",
"path": "/src/db.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: innoave/genevo path: /src/prelude.rs
// Genetic
//
pub use crate::genetic::{Fitness, FitnessFunction, Genotype, Phenotype};
// Algorithm
//
pub use crate::{
algorithm::Algorithm,
ga::{genetic_algorithm, GeneticAlgorithm},
random::{Prng, Rng, Seed},
};
<|fim_suffix|>// Termination
/... | code_fim | hard | {
"lang": "rust",
"repo": "innoave/genevo",
"path": "/src/prelude.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Population
//
pub use crate::population::{build_population, GenomeBuilder, Population};
// Simulation
//
pub use crate::simulation::{simulator::simulate, SimResult, Simulation, SimulationBuilder};
// Termination
//
pub use crate::termination::{
combinator::{and, or, And, Or},
limit::*,
};<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "innoave/genevo",
"path": "/src/prelude.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Termination
//
pub use crate::termination::{
combinator::{and, or, And, Or},
limit::*,
};<|fim_prefix|>// repo: innoave/genevo path: /src/prelude.rs
// Genetic
//
pub use crate::genetic::{Fitness, FitnessFunction, Genotype, Phenotype};
// Algorithm
//
pub use crate::{
algorithm::Algorithm... | code_fim | medium | {
"lang": "rust",
"repo": "innoave/genevo",
"path": "/src/prelude.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.current_len.is_none() && buf.len() >= self.field_size {
let bs = buf.drain_to(self.field_size);
self.current_len = Some(B::read_uint(bs.as_slice(), self.field_size) as usize);
}
if let Some(cl) = self.current_len {
if buf.len() >= cl {
... | code_fim | hard | {
"lang": "rust",
"repo": "dantodor/tokio-framecodecs",
"path": "/src/frame/length_field.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dantodor/tokio-framecodecs path: /src/frame/length_field.rs
use tokio_core::io::{Codec, Io, EasyBuf, Framed};
use tokio_proto::pipeline::{ServerProto, ClientProto};
use byteorder::ByteOrder;
use std::marker::PhantomData;
use std::io;
/// Length field prepending protocol.
///
/// A protocol such... | code_fim | hard | {
"lang": "rust",
"repo": "dantodor/tokio-framecodecs",
"path": "/src/frame/length_field.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmrolfs/address-propensity path: /src/tracing.rs
use tracing::{subscriber::set_global_default, Subscriber};
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
use tracing_log::LogTracer;
use tracing_subscriber::fmt::MakeWriter;
use tracing_subscriber::{layer::SubscriberExt,... | code_fim | medium | {
"lang": "rust",
"repo": "dmrolfs/address-propensity",
"path": "/src/tracing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn init_subscriber(subscriber: impl Subscriber + Sync + Send) {
LogTracer::init().expect("Failed to set logger");
set_global_default(subscriber).expect("Failed to set subscriber");
}<|fim_prefix|>// repo: dmrolfs/address-propensity path: /src/tracing.rs
use tracing::{subscriber::set_global_de... | code_fim | medium | {
"lang": "rust",
"repo": "dmrolfs/address-propensity",
"path": "/src/tracing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_subscriber(
name: impl Into<String>, env_filter: impl AsRef<str>, sink: impl MakeWriter + Send + Sync + 'static,
) -> impl Subscriber + Sync + Send {
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(env_filter));
let formatting_layer = BunyanForm... | code_fim | hard | {
"lang": "rust",
"repo": "dmrolfs/address-propensity",
"path": "/src/tracing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MisterUncloaked/rbx-dom path: /rbx_dom_weak/src/tree.rs
use std::collections::HashMap;
use serde_derive::{Deserialize, Serialize};
use crate::{
id::RbxId,
instance::{RbxInstance, RbxInstanceProperties},
};
/// Represents a tree containing Roblox instances.
///
/// Instances are descri... | code_fim | hard | {
"lang": "rust",
"repo": "MisterUncloaked/rbx-dom",
"path": "/rbx_dom_weak/src/tree.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// An iterator over all descendants of an instance in an [`RbxTree`]. Returned
/// by [`RbxTree::descendants`].
///
/// [`RbxTree`]: struct.RbxTree.html
/// [`RbxTree::descendants`]: struct.RbxTree.html#method.descendants
pub struct Descendants<'a> {
tree: &'a RbxTree,
ids_to_visit: Vec<RbxId>,
}... | code_fim | hard | {
"lang": "rust",
"repo": "MisterUncloaked/rbx-dom",
"path": "/rbx_dom_weak/src/tree.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: khollbach/google-kickstart path: /code-jam-qual/qual-5/src/main.rs
use std::io::{self, prelude::*};
use std::error::Error;
const NUM_STUDENTS: usize = 100;
const NUM_QUESTIONS: usize = 10_000;
const HARD_Q_PCT_THRESH: f64 = 0.20; // Anything at or below this is "hard".
fn find_cheater(answers... | code_fim | hard | {
"lang": "rust",
"repo": "khollbach/google-kickstart",
"path": "/code-jam-qual/qual-5/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut answers = Vec::with_capacity(NUM_STUDENTS);
for _ in 0..NUM_STUDENTS {
let line = lines.next().unwrap()?;
assert_eq!(line.len(), NUM_QUESTIONS);
let row: Vec<_> = line.chars().map(|c| match c {
'0' => false,
'1' => true,
_ => pa... | code_fim | hard | {
"lang": "rust",
"repo": "khollbach/google-kickstart",
"path": "/code-jam-qual/qual-5/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: henrikpersson/potatis path: /nes-embedded/src/board.rs
use display_interface_spi::SPIInterface;
use embedded_hal::blocking::delay::DelayUs;
use embedded_hal::digital::v2::OutputPin;
use embedded_hal::spi::MODE_0;
use fugit::RateExtU32;
use hal::gpio::bank0::Gpio16;
use hal::gpio::bank0::Gpio17;
... | code_fim | hard | {
"lang": "rust",
"repo": "henrikpersson/potatis",
"path": "/nes-embedded/src/board.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dc = pins.lcd_dc.into_push_pull_output();
let cs = pins.lcd_cs.into_push_pull_output();
let sck = pins.spi_sclk.into_mode::<FunctionSpi>();
let mosi = pins.spi_mosi.into_mode::<FunctionSpi>();
let spi_screen = Spi::<_, _, 8>::new(spi0).init(resets, 125u32.MHz(), 16u32.MHz(), &MODE... | code_fim | hard | {
"lang": "rust",
"repo": "henrikpersson/potatis",
"path": "/nes-embedded/src/board.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn as_byte_slice<T>(slice: &[T]) -> &[u8] {
let len = slice.len() * std::mem::size_of::<T>();
let ptr = slice.as_ptr() as *const u8;
unsafe { std::slice::from_raw_parts(ptr, len) }
}<|fim_prefix|>// repo: Yatekii/sailor path: /src/lib/drawing/mod.rs
mod line_tesselator;
mod loaded_gpu_til... | code_fim | medium | {
"lang": "rust",
"repo": "Yatekii/sailor",
"path": "/src/lib/drawing/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yatekii/sailor path: /src/lib/drawing/mod.rs
mod line_tesselator;
mod loaded_gpu_tile;
mod mesh;
mod vertex;
<|fim_suffix|>pub fn as_byte_slice<T>(slice: &[T]) -> &[u8] {
let len = slice.len() * std::mem::size_of::<T>();
let ptr = slice.as_ptr() as *const u8;
unsafe { std::slice::fr... | code_fim | medium | {
"lang": "rust",
"repo": "Yatekii/sailor",
"path": "/src/lib/drawing/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn rotation_x(matrix: cgmath::Matrix4<f32>, rotate_x: f32) -> cgmath::Matrix4<f32> {
cgmath::Matrix4::from_angle_x(cgmath::Rad(rotate_x)) * matrix
}
pub fn rotation_y(matrix: cgmath::Matrix4<f32>, rotate_y: f32) -> cgmath::Matrix4<f32> {
cgmath::Matrix4::from_angle_y(cgmath::Rad(rotate_y)) * ... | code_fim | hard | {
"lang": "rust",
"repo": "markd88/wgpu",
"path": "/src/helper.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: markd88/wgpu path: /src/helper.rs
use obj::{load_obj, Obj};
use std::fs::File;
use std::io::BufReader;
/// This function takes in a file_name, accesses the file to load in the object and returns the data in the format (Positions, Normals, Indices)
pub fn load_model(file_name: &str) -> (Vec<[f32... | code_fim | hard | {
"lang": "rust",
"repo": "markd88/wgpu",
"path": "/src/helper.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn rotate_vec4(start: &[[f32; 4]], delta_y: f32) -> Vec<[f32; 4]> {
let mut temp_vec3 = cgmath::Vector4::new(start[0][0], start[0][1], start[0][2], start[0][3]);
temp_vec3 = cgmath::Matrix4::from_angle_x(cgmath::Rad(delta_y)) * temp_vec3;
vec![[temp_vec3.x, temp_vec3.y, temp_vec3.z, temp_v... | code_fim | hard | {
"lang": "rust",
"repo": "markd88/wgpu",
"path": "/src/helper.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stream = stream::iter(futures.into_iter().map(Ok)).buffer_unordered(num_cpus::get());
let mut failures = Vec::new();
t!(core.run(stream.for_each(|(test, output)| {
if output.status.success() {
println!("test {} ... ok", test.name);
} else {
println!... | code_fim | hard | {
"lang": "rust",
"repo": "godaddy-icfp/icfp-2020",
"path": "/vendor/jobserver/tests/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut failures = Vec::new();
t!(core.run(stream.for_each(|(test, output)| {
if output.status.success() {
println!("test {} ... ok", test.name);
} else {
println!("test {} ... FAIL", test.name);
failures.push((test, output));
}
O... | code_fim | hard | {
"lang": "rust",
"repo": "godaddy-icfp/icfp-2020",
"path": "/vendor/jobserver/tests/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: godaddy-icfp/icfp-2020 path: /vendor/jobserver/tests/client.rs
extern crate futures;
extern crate jobserver;
extern crate num_cpus;
extern crate tempdir;
extern crate tokio_core;
extern crate tokio_process;
use std::env;
use std::fs::File;
use std::io::Write;
use std::process::Command;
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "godaddy-icfp/icfp-2020",
"path": "/vendor/jobserver/tests/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl V1beta1CertificateSigningRequestStatus {
pub fn new() -> V1beta1CertificateSigningRequestStatus {
V1beta1CertificateSigningRequestStatus {
certificate: None,
conditions: None,
}
}
}<|fim_prefix|>// repo: alberthuang24/kube-rust path: /crates/kubernetes... | code_fim | hard | {
"lang": "rust",
"repo": "alberthuang24/kube-rust",
"path": "/crates/kubernetes-client/src/models/v1beta1_certificate_signing_request_status.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkhan45/two-flappy path: /src/bird.rs
use quicksilver::{
geom::{Rectangle, Shape},
};
const ACCEL: f32 = 1.5;
const JUMP: f32 = 26.0;
pub struct Player{
pub hitbox: Rectangle,
pub vel: f32,
}
<|fim_suffix|> pub fn update(&mut self){
self.hitbox = self.hitbox.translate((... | code_fim | medium | {
"lang": "rust",
"repo": "mkhan45/two-flappy",
"path": "/src/bird.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn jump(&mut self){
self.vel -= JUMP;
}
}<|fim_prefix|>// repo: mkhan45/two-flappy path: /src/bird.rs
use quicksilver::{
geom::{Rectangle, Shape},
};
const ACCEL: f32 = 1.5;
const JUMP: f32 = 26.0;
pub struct Player{
pub hitbox: Rectangle,
pub vel: f32,
}
<|fim_middle|>... | code_fim | hard | {
"lang": "rust",
"repo": "mkhan45/two-flappy",
"path": "/src/bird.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nabla-containers/rumprun-packages path: /rust/examples/hello-tcp/src/main.rs
use std::io::{BufReader, BufRead, Write, Result};
use std::net::{TcpListener, TcpStream};
use std::thread;
<|fim_suffix|> let mut stream = try!(stream);
try!(stream.write_all(b"Hello, this is rumprun. Who are yo... | code_fim | medium | {
"lang": "rust",
"repo": "nabla-containers/rumprun-packages",
"path": "/rust/examples/hello-tcp/src/main.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let listener = TcpListener::bind("0.0.0.0:9023").unwrap();
println!("listening on port 9023 started, ready to accept");
for stream in listener.incoming() {
thread::spawn(|| {
if let Err(err) = handle(stream) {
println!("an error occured: {}", err);
... | code_fim | medium | {
"lang": "rust",
"repo": "nabla-containers/rumprun-packages",
"path": "/rust/examples/hello-tcp/src/main.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let listener = TcpListener::bind("0.0.0.0:9023").unwrap();
println!("listening on port 9023 started, ready to accept");
for stream in listener.incoming() {
thread::spawn(|| {
if let Err(err) = handle(stream) {
println!("an error occured: {}", err... | code_fim | medium | {
"lang": "rust",
"repo": "nabla-containers/rumprun-packages",
"path": "/rust/examples/hello-tcp/src/main.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match fd.read_to_end(dst) {
Ok(_) => Ok(true),
Err(e) => {
if e.raw_os_error() == Some(libc::EWOULDBLOCK)
|| e.raw_os_error() == Some(libc::EAGAIN)
{
Ok(false)
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "apache/incubator-teaclave-sgx-sdk",
"path": "/sgx_tstd/src/sys/pipe.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apache/incubator-teaclave-sgx-sdk path: /sgx_tstd/src/sys/pipe.rs
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF lice... | code_fim | hard | {
"lang": "rust",
"repo": "apache/incubator-teaclave-sgx-sdk",
"path": "/sgx_tstd/src/sys/pipe.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![my_custom_command])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}<|fim_prefix|>// repo: fabienbellanger/test-tauri-svelte path: /src-tauri/src/main.rs
#![cfg_attr(
all(not... | code_fim | medium | {
"lang": "rust",
"repo": "fabienbellanger/test-tauri-svelte",
"path": "/src-tauri/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> tauri::Builder::default()
.invoke_handler(tauri::generate_handler![my_custom_command])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}<|fim_prefix|>// repo: fabienbellanger/test-tauri-svelte path: /src-tauri/src/main.rs
#![cfg_attr(
all(not(debug_asser... | code_fim | medium | {
"lang": "rust",
"repo": "fabienbellanger/test-tauri-svelte",
"path": "/src-tauri/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fabienbellanger/test-tauri-svelte path: /src-tauri/src/main.rs
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
#[tauri::command]
fn my_custom_command(invoke_message: String) -> String {
<|fim_suffix|> tauri::Builder::default()
.invoke_ha... | code_fim | medium | {
"lang": "rust",
"repo": "fabienbellanger/test-tauri-svelte",
"path": "/src-tauri/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sflanaga/clutch path: /src/main.rs
#![allow(dead_code)]
#![allow(unused_imports)]
use std::fmt::Display;
use std::time::{Instant, Duration};
use structopt::StructOpt;
use clutch::*;
use crate::cli::Cli;
use std::rc::Rc;
use crate::util::{StatTrack, PeriodicThread};
use std::sync::atomic::Ord... | code_fim | hard | {
"lang": "rust",
"repo": "sflanaga/clutch",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cs = ClutchStore::new();
let mut om_count = 0u64;
let mut row_count = 0u64;
let start_t = std::time::Instant::now();
let group = cm.find_or_new_group("level1");
let mut c_key = ClutchKey::new(group.idx, String::with_capacity(32), 1960, 32, 0);
... | code_fim | hard | {
"lang": "rust",
"repo": "sflanaga/clutch",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yelp/casper path: /casper-server/src/config_loader.rs
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::time::{Duration, Instant, SystemTime};
use once_cell::sync::Lazy;
use serde_yaml::Value as YamlValue;
use tokio::{fs, sync::RwLock};
static CONFIGS: Lazy<RwLock<HashMap... | code_fim | hard | {
"lang": "rust",
"repo": "Yelp/casper",
"path": "/casper-server/src/config_loader.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> let modified = fs::metadata(config).await?.modified()?;
let value = Value {
yaml: serde_yaml::from_slice(&fs::read(config).await?)?,
last_checked: Instant::now(),
modified,
interval: interval.unwrap_or_else(|| Duration... | code_fim | hard | {
"lang": "rust",
"repo": "Yelp/casper",
"path": "/casper-server/src/config_loader.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> let next_value = match keys.get(0) {
Some(IndexKey::Usize(i)) => value.get(i),
Some(IndexKey::String(s)) => value.get(s),
Some(IndexKey::None) | None => return Some(value),
};
match next_value {
Some(value) => traverse_value(value, &keys[1..]),
None => N... | code_fim | hard | {
"lang": "rust",
"repo": "Yelp/casper",
"path": "/casper-server/src/config_loader.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jdtatz/rusty-cuda path: /cuda_driver/src/nvrtc.rs
#[cfg(feature = "dynamic-nvrtc")]
use dlopen::{
utils::platform_file_name,
wrapper::{Container, WrapperApi},
};
#[cfg(feature = "dynamic-nvrtc")]
use dlopen_derive::WrapperApi;
#[cfg(feature = "dynamic-nvrtc")]
use once_cell::sync::OnceCe... | code_fim | hard | {
"lang": "rust",
"repo": "jdtatz/rusty-cuda",
"path": "/cuda_driver/src/nvrtc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! nvrtc {
($func:ident($($arg:expr),*)) => { {
#[cfg(feature = "dynamic-nvrtc")] {
let driver = NVRTC.get().expect("Nvrtc called before initialization");
unsafe { driver.$func( $($arg, )* ) }
} #[cfg(not(feature = "dynamic-nvrtc"))] {
unsa... | code_fim | hard | {
"lang": "rust",
"repo": "jdtatz/rusty-cuda",
"path": "/cuda_driver/src/nvrtc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scalarwaves/ninja-rs path: /src/line_printer.rs
// Copyright 2013 Google Inc. All Rights Reserved.
// Copyright 2017 The Ninja-rs Project Developers. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with ... | code_fim | hard | {
"lang": "rust",
"repo": "scalarwaves/ninja-rs",
"path": "/src/line_printer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct LinePrinter {
LinePrinter();
bool is_smart_terminal() const { return smart_terminal_; }
void set_smart_terminal(bool smart) { smart_terminal_ = smart; }
/// Overprints the current line. If type is ELIDE, elides to_print to fit on
/// one line.
void Print(string to_print, LineType typ... | code_fim | hard | {
"lang": "rust",
"repo": "scalarwaves/ninja-rs",
"path": "/src/line_printer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cargo_test(nightly, reason = "bench")]
fn bench_twice_with_build_cmd() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
build = "build.rs"... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/tests/testsuite/bench.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/cargo path: /tests/testsuite/bench.rs
t_contains("test foo ... bench: [..]")
.run();
p.cargo("bench")
.with_stderr(
"[FINISHED] bench [optimized] target(s) in [..]
[RUNNING] [..] (target/release/deps/foo-[..][EXE])",
)
.with_stdout_conta... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/tests/testsuite/bench.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/cargo path: /tests/testsuite/bench.rs
#![feature(test)]
#[cfg(test)]
extern crate test;
#[bench]
fn foo(_b: &mut test::Bencher) {}
",
)
.build();
p.cargo("bench")
.with_stderr(
"\
[COMPILIN... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/tests/testsuite/bench.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Oyelowo/coding_practice path: /rust/rust-by-examples/_13_attributes/src/main.rs
fn main() {
used_function();
cfg_stuff();
conditional_function();
}
////////////////////////////////////////////////////////////////
// Custom cfg
/*
Some conditionals like target_os are implicitly provi... | code_fim | hard | {
"lang": "rust",
"repo": "Oyelowo/coding_practice",
"path": "/rust/rust-by-examples/_13_attributes/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: salimclevy/csml-interpreter path: /tests/if_statments.rs
pub mod support;
use csmlinterpreter::data::{Event, MessageData};
use csmlinterpreter::interpret;
use serde_json::Value;
use support::tools::{gen_context, gen_event, message_to_jsonvalue, read_file};
fn format_message(event: Event, step... | code_fim | hard | {
"lang": "rust",
"repo": "salimclevy/csml-interpreter",
"path": "/tests/if_statments.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let msg = format_message(gen_event(""), "step4");
let data = r#"{"messages":[{"content":{"text":"quoi"},"content_type":"text"}],"next_flow":null,"memories":[],"next_step":"end"}"#;
let v1: Value = message_to_jsonvalue(msg);
let v2: Value = serde_json::from_str(data).unwrap();
assert_... | code_fim | hard | {
"lang": "rust",
"repo": "salimclevy/csml-interpreter",
"path": "/tests/if_statments.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(v1, v2)
}
#[test]
fn ok_var_to_numeric_comparison() {
let msg = format_message(gen_event(""), "step1");
let data = r#"{"messages":[{"content":{"text":"var10 > 9"},"content_type":"text"}],"next_flow":null,"memories":[],"next_step":"end"}"#;
let v1: Value = message_to_jsonvalue(... | code_fim | hard | {
"lang": "rust",
"repo": "salimclevy/csml-interpreter",
"path": "/tests/if_statments.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/yansi/src/windows.rs
#[cfg(windows)]
mod windows_console {
use std::os::raw::c_void;
#[allow(non_camel_case_types)] type c_ulong = u32;
#[allow(non_camel_case_types)] type c_int = i32;
type DWORD = c_ulong;
type LPDWORD = *mut DWORD;
... | code_fim | medium | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/yansi/src/windows.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
unsafe fn get_handle(handle_num: DWORD) -> Result<HANDLE, ()> {
match GetStdHandle(handle_num) {
handle if handle == INVALID_HANDLE_VALUE => Err(()),
handle => Ok(handle)
}
}
unsafe fn enable_vt(handle: HANDLE) -> Result<(), ()> {
let mut... | code_fim | medium | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/yansi/src/windows.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>elf::i_cor_profiler_info_8::ICorProfilerInfo8;
pub use self::i_cor_profiler_info_9::ICorProfilerInfo9;
pub use self::i_cor_profiler_method_enum::ICorProfilerMethodEnum;
pub use self::i_cor_profiler_module_enum::ICorProfilerModuleEnum;
pub use self::i_cor_profiler_object_enum::ICorProfilerObjectEnum;
pub u... | code_fim | hard | {
"lang": "rust",
"repo": "longde123/clr-profiler",
"path": "/clr_profiler/src/ffi/interface.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: longde123/clr-profiler path: /clr_profiler/src/ffi/interface.rs
mod i_class_factory;
mod i_cor_profiler_assembly_reference_provider;
mod i_cor_profiler_callback;
mod i_cor_profiler_callback_2;
mod i_cor_profiler_callback_3;
mod i_cor_profiler_callback_4;
mod i_cor_profiler_callback_5;
mod i_cor_... | code_fim | hard | {
"lang": "rust",
"repo": "longde123/clr-profiler",
"path": "/clr_profiler/src/ffi/interface.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jens1o/elder-solutions path: /src/problem-seventeen/src/main.rs
#[macro_use]
extern crate lazy_static;
use std::collections::HashMap;
use std::time::Instant;
lazy_static! {
static ref NUMBER_TO_STRING: HashMap<u16, String> = {
let mut m = HashMap::with_capacity(29);
macro_... | code_fim | hard | {
"lang": "rust",
"repo": "jens1o/elder-solutions",
"path": "/src/problem-seventeen/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result_string = String::new();
let mut min_difference = number;
let mut closest_number = 0;
// look for the number we know is the closest number to the we were given
for key in NUMBER_TO_STRING.keys().filter(|key| key < &&number) {
// calculate difference to value
... | code_fim | hard | {
"lang": "rust",
"repo": "jens1o/elder-solutions",
"path": "/src/problem-seventeen/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // look for the number we know is the closest number to the we were given
for key in NUMBER_TO_STRING.keys().filter(|key| key < &&number) {
// calculate difference to value
let difference = number - key;
// if we are closer than what we already saw, remember this.
... | code_fim | hard | {
"lang": "rust",
"repo": "jens1o/elder-solutions",
"path": "/src/problem-seventeen/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sigma = ConstantTexture::new(0.0);
let sigma = Arc::new(sigma);
MatteMaterial::new(kd, sigma, None)
};
let material = Box::new(material);
let primitive = GeometricPrimitive {
shape: sphere,
material: Some(material),
... | code_fim | hard | {
"lang": "rust",
"repo": "callym/pbrst",
"path": "/pbrt/examples/bvh.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let camera = {
let film = {
let full_resolution = Point2i::new(512, 512);
let crop_window = Bounds2f::new(
Point2f::new(float(0.0), float(0.0)),
Point2f::new(float(1.0), float(1.0)),
);
let filter = TriangleFilter... | code_fim | hard | {
"lang": "rust",
"repo": "callym/pbrst",
"path": "/pbrt/examples/bvh.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: callym/pbrst path: /pbrt/examples/bvh.rs
#![feature(nll, underscore_imports)]
extern crate cgmath;
extern crate pbrt;
use std::sync::{ Arc, Mutex };
use cgmath::{ Deg, Matrix4 };
use pbrt::prelude::*;
use pbrt::aggregate::{ BvhAccel, SplitMethod };
use pbrt::camera::{ OrthographicCamera, Per... | code_fim | hard | {
"lang": "rust",
"repo": "callym/pbrst",
"path": "/pbrt/examples/bvh.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hedonhermdev/RedisLess path: /redisless/storage/src/lib.rs
pub mod in_memory;
<|fim_suffix|> fn get(&self, key: &[u8]) -> Option<&[u8]>;
fn del(&mut self, key: &[u8]) -> u32;
}<|fim_middle|>pub trait Storage {
fn set(&mut self, key: &[u8], value: &[u8]);
| code_fim | medium | {
"lang": "rust",
"repo": "hedonhermdev/RedisLess",
"path": "/redisless/storage/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get(&self, key: &[u8]) -> Option<&[u8]>;
fn del(&mut self, key: &[u8]) -> u32;
}<|fim_prefix|>// repo: hedonhermdev/RedisLess path: /redisless/storage/src/lib.rs
pub mod in_memory;
<|fim_middle|>pub trait Storage {
fn set(&mut self, key: &[u8], value: &[u8]);
| code_fim | medium | {
"lang": "rust",
"repo": "hedonhermdev/RedisLess",
"path": "/redisless/storage/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn del(&mut self, key: &[u8]) -> u32;
}<|fim_prefix|>// repo: hedonhermdev/RedisLess path: /redisless/storage/src/lib.rs
pub mod in_memory;
<|fim_middle|>pub trait Storage {
fn set(&mut self, key: &[u8], value: &[u8]);
fn get(&self, key: &[u8]) -> Option<&[u8]>;
| code_fim | medium | {
"lang": "rust",
"repo": "hedonhermdev/RedisLess",
"path": "/redisless/storage/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xanahopper/simple_laxer path: /src/laxer.rs
use std::str::Chars;
use std::iter::Peekable;
use std::fmt;
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum DfaState {
Initial,
Identifier,
GreatThen,
GreatEqual,
IntLiteral,
Int,
IdInt1,
IdInt2,
Equal,
Plus,
... | code_fim | hard | {
"lang": "rust",
"repo": "xanahopper/simple_laxer",
"path": "/src/laxer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ch) = self.char_iter.peek() {
let current_state = self.state;
self.state = match self.state {
DfaState::Initial =>
match ch {
'i' => DfaState::IdInt1,
'a'..='z' | 'A'..='Z' | '_'... | code_fim | hard | {
"lang": "rust",
"repo": "xanahopper/simple_laxer",
"path": "/src/laxer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
use std::io::{Write, stderr};
use std::process::exit;
let args: Vec<String> = std::env::args().collect();
if args.len() != 2 {
writeln!(stderr(), "need 1 command-line argument").unwrap();
exit(1);
}
let path = &args[1];
let s = parser::load_file(path... | code_fim | hard | {
"lang": "rust",
"repo": "Rufflewind/howl",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rufflewind/howl path: /src/main.rs
extern crate howl;
use std::io;
use howl::parser::{self, Node, Elem};
fn write_children<L, W: io::Write>(f: &mut W, elem: &Elem<&[u8], L>)
-> io::Result<()> {
for child in &elem.children {
write_html(child, f)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "Rufflewind/howl",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> file_handle: &mut HANDLE,
desired_access: u32,
object_attributes: &ObjectAttributes,
io_status_block: &mut IoStatusBlock,
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: DemiMarie/winpat... | code_fim | medium | {
"lang": "rust",
"repo": "DemiMarie/winpath.rs",
"path": "/openat/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DemiMarie/winpath.rs path: /openat/src/lib.rs
#[cfg(windows)]
mod ffi {
use std::os::windows::raw::HANDLE;
type PHANDLE = *mut HANDLE;
type HRESULT = libc::c_long;
#[repr(C)]
struct UnicodeString {
length: u16,
maximum_length: u16,
buffer: *const u16,
... | code_fim | hard | {
"lang": "rust",
"repo": "DemiMarie/winpath.rs",
"path": "/openat/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let uri = URI::from_parts(
"http",
Some("example.com"),
"",
Some("query"),
None::<Fragment>
).unwrap();
assert_eq!(uri.to_string(), "http://example.com/?query");
}<|fim_prefix|>// repo: ultrasaurus/rust-uri-comparison path: /examples/uriparse.rs
use std::convert::TryFr... | code_fim | hard | {
"lang": "rust",
"repo": "ultrasaurus/rust-uri-comparison",
"path": "/examples/uriparse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ultrasaurus/rust-uri-comparison path: /examples/uriparse.rs
use std::convert::TryFrom;
use uriparse::{Authority, Fragment, Path, Scheme, URI};
fn main() {
let uri = URI::try_from("http://example.com:80/my/path").unwrap();
assert_eq!(uri.authority().unwrap().to_string(), "example.com:80");
... | code_fim | hard | {
"lang": "rust",
"repo": "ultrasaurus/rust-uri-comparison",
"path": "/examples/uriparse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn handle_client(mut stream: TcpStream) {
let read = stream.read_to_end().unwrap();
let _ = stream.write(read.as_slice());
}<|fim_prefix|>// repo: talentdeficit/echo.rs path: /echo.rs
use std::io::{TcpListener, TcpStream};
use std::io::{Acceptor, Listener};
<|fim_middle|>fn main() {
let mut accept... | code_fim | hard | {
"lang": "rust",
"repo": "talentdeficit/echo.rs",
"path": "/echo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: talentdeficit/echo.rs path: /echo.rs
use std::io::{TcpListener, TcpStream};
use std::io::{Acceptor, Listener};
<|fim_suffix|> let read = stream.read_to_end().unwrap();
let _ = stream.write(read.as_slice());
}<|fim_middle|>fn main() {
let mut acceptor = TcpListener::bind("127.0.0.1", 8000).... | code_fim | hard | {
"lang": "rust",
"repo": "talentdeficit/echo.rs",
"path": "/echo.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.