text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> self.sender.send(Message::NewJob(job)).unwrap();
}
}
impl Drop for ThreadPool {
fn drop(&mut self) {
println!("Sending terminate message to all workers.");
for _ in &self.workers {
self.sender.send(Message::Terminate).unwrap();
}
println!("Shu... | code_fim | hard | {
"lang": "rust",
"repo": "rdesarz/rust-http-server",
"path": "/src/thread/pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// let res = resize1(Rc::clone(&img1));
// let res = resize1(Rc::clone(&img1));
// assert_eq!(res.is_ok(), true);
// let img2 = Rc::new(RefCell::new(
// image::open("test_resources/DSC_0003.JPG").unwrap(),
// ));
// let res2 = resize1(Rc::clone... | code_fim | hard | {
"lang": "rust",
"repo": "vansweej/mtcnn-rs",
"path": "/src/image_ops/rust/resize_ops.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vansweej/mtcnn-rs path: /src/image_ops/rust/resize_ops.rs
use crate::image_ops::image_ops::*;
use image::imageops::FilterType;
use image::DynamicImage;
use std::cell::RefCell;
use std::rc::Rc;
use std::result::Result;
struct RustResizeOp {
width: u32,
height: u32,
}
impl RustResizeOp {... | code_fim | medium | {
"lang": "rust",
"repo": "vansweej/mtcnn-rs",
"path": "/src/image_ops/rust/resize_ops.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub const fn invalid() -> Shader {
Shader {
gl_handle: 0,
proj_loc: 0,
view_loc: 0,
}
}
pub fn use_program(&self) {
unsafe {
gl::UseProgram(self.gl_handle);
}
}
pub fn get_uniform_loc(&self, uniform: &str) -> i32 {
use std::ffi::CString;
unsafe {
// TODO: Make sure we're... | code_fim | hard | {
"lang": "rust",
"repo": "manpat/wsrs-test",
"path": "/client/src/rendering/shader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Shader {
gl_handle: program,
proj_loc: gl::GetUniformLocation(program, b"proj\0".as_ptr()),
view_loc: gl::GetUniformLocation(program, b"view\0".as_ptr()),
}
}
}
pub const fn invalid() -> Shader {
Shader {
gl_handle: 0,
proj_loc: 0,
view_loc: 0,
}
}
pub fn use_progra... | code_fim | hard | {
"lang": "rust",
"repo": "manpat/wsrs-test",
"path": "/client/src/rendering/shader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: manpat/wsrs-test path: /client/src/rendering/shader.rs
use std;
use common::math::*;
use rendering::gl;
use std::mem::transmute;
#[derive(Copy, Clone)]
pub struct Shader {
pub gl_handle: u32,
pub proj_loc: i32,
pub view_loc: i32,
}
impl Shader {
pub fn new(vertex_shader_src: &str, fragme... | code_fim | hard | {
"lang": "rust",
"repo": "manpat/wsrs-test",
"path": "/client/src/rendering/shader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // sign data
// let data_hash = keccak256(req.message.as_bytes());
let mut eth_data: Vec<u8> =
format!("\x19Ethereum Signed Message:\n{}", req.message.len()).into_bytes();
eth_data.extend_from_slice(&req.message.as_bytes());
let hash = keccak256(ð_data);
let message = s... | code_fim | hard | {
"lang": "rust",
"repo": "Rexagon/axie-skipper",
"path": "/backend/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rexagon/axie-skipper path: /backend/src/main.rs
use std::convert::TryInto;
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use warp::Filter;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct SignRequest {
pub account_id: u16,
pub message: String,
}
#[... | code_fim | hard | {
"lang": "rust",
"repo": "Rexagon/axie-skipper",
"path": "/backend/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(SignResponse {
owner: format!("0x{}", hex::encode(&address)),
message: req.message,
signature: format!("0x{}", hex::encode(&ex_sign)),
})
}
pub fn compute_eth_address(public_key: &secp256k1::PublicKey) -> [u8; 20] {
let pub_key = &public_key.serialize_uncompressed()... | code_fim | hard | {
"lang": "rust",
"repo": "Rexagon/axie-skipper",
"path": "/backend/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn ensure_note_and_frequency_correct_for_a4() {
let note = NoteFrequency {
reference_frequency: REFERENCE_FREQUENCY,
octave: 4,
interval: 9
};
assert_eq!(439.99999999999994, note.frequency());
}<|fim_prefix|>// repo: PurpleHexagon/note-frequency-calculator pat... | code_fim | hard | {
"lang": "rust",
"repo": "PurpleHexagon/note-frequency-calculator",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PurpleHexagon/note-frequency-calculator path: /src/main.rs
const REFERENCE_FREQUENCY: f64 = 261.6255653005986;
/// Structure to hold data relating to a note
/// Accepts an interval and an octave which will be used to calculate the note and frequency
struct NoteFrequency {
reference_frequenc... | code_fim | hard | {
"lang": "rust",
"repo": "PurpleHexagon/note-frequency-calculator",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> window.build(ui, || {
ui.text("Build");
//create a button for eaxh interaction il the area
for build in &player_info.possible_builds {
let name = build.name.clone();
if ui.button(&im... | code_fim | hard | {
"lang": "rust",
"repo": "Elliosson/rogue_client_bevy",
"path": "/src/systems/build_ui_system.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Elliosson/rogue_client_bevy path: /src/systems/build_ui_system.rs
use amethyst::ecs::prelude::*;
use crate::Data;
use crate::UiCom;
use crate::PlayerInfo;
use amethyst_imgui::{imgui, imgui::im_str};
use std::sync::{Arc, Mutex};
pub struct BuildUiSystem {
active: bool,
}
impl Default for ... | code_fim | hard | {
"lang": "rust",
"repo": "Elliosson/rogue_client_bevy",
"path": "/src/systems/build_ui_system.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.active {
let mut to_send_guard = to_send.lock().unwrap();
let data_guard = data.lock().unwrap();
let mut open = true;
amethyst_imgui::with(|ui| {
let title = im_str!("Build");
let window = imgui::Window::new(&t... | code_fim | hard | {
"lang": "rust",
"repo": "Elliosson/rogue_client_bevy",
"path": "/src/systems/build_ui_system.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: J-AugustoManzano/livro_Rust path: /ExerciciosAprendizagem/Cap09/c09ex39/src/main.rs
extern crate crypto;
use std::io;
use std::io::prelude::*;
use crypto::digest::Digest;
use crypto::md5::Md5;
use crypto::sha1::Sha1;
use crypto::whirlpool::Whirlpool;
<|fim_suffix|> println!();
print!... | code_fim | hard | {
"lang": "rust",
"repo": "J-AugustoManzano/livro_Rust",
"path": "/ExerciciosAprendizagem/Cap09/c09ex39/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("button drawn");
}
}
struct SelectBox {
width: u32,
height: u32,
options: Vec<String>,
}
impl Draw for SelectBox {
fn draw(&self) {
println!("select box drawn");
}
}<|fim_prefix|>// repo: kotamat/rust_tutorial path: /oop/src/trait_object.rs
pub(crate) fn... | code_fim | hard | {
"lang": "rust",
"repo": "kotamat/rust_tutorial",
"path": "/oop/src/trait_object.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kotamat/rust_tutorial path: /oop/src/trait_object.rs
pub(crate) fn main() {
let screen = Screen {
components: vec![
Box::new(SelectBox {
width: 75,
height: 10,
options: vec!["Yes", "Maybe", "No"]
.iter()
... | code_fim | hard | {
"lang": "rust",
"repo": "kotamat/rust_tutorial",
"path": "/oop/src/trait_object.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if result {
println!("{} is a prime.", candidate);
}
else {
println!("{} is not a prime.", candidate);
}
}
}<|fim_prefix|>// repo: froocpu/learn_rust path: /projects/primes/src/main.rs
mod tests;
mod tools;
use std::env;
use tools::primes::*;
u... | code_fim | hard | {
"lang": "rust",
"repo": "froocpu/learn_rust",
"path": "/projects/primes/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = prime_loop(candidate);
if result {
println!("{} is a prime.", candidate);
}
else {
println!("{} is not a prime.", candidate);
}
}
}<|fim_prefix|>// repo: froocpu/learn_rust path: /projects/primes/src/main.rs
mod tests;
mod ... | code_fim | hard | {
"lang": "rust",
"repo": "froocpu/learn_rust",
"path": "/projects/primes/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: froocpu/learn_rust path: /projects/primes/src/main.rs
mod tests;
mod tools;
use std::env;
use tools::primes::*;
use tools::validation::validate;
fn main() {
let args: Vec<String> = env::args().collect();
let candidate_str = &args[1];
validate(candidate_str);
check_prime(candi... | code_fim | hard | {
"lang": "rust",
"repo": "froocpu/learn_rust",
"path": "/projects/primes/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pierre-l/spatiub path: /demo_server/src/server.rs
use futures::{Future, future, Stream, stream, Sink};
use spatiub::futures_sub;
use spatiub::spatial::Entity;
use spatiub::spatial::MapDefinition;
use spatiub::spatial::Point;
use spatiub::spatial::SpatialChannel;
use tokio_codec::Decoder;
use tok... | code_fim | hard | {
"lang": "rust",
"repo": "pierre-l/spatiub",
"path": "/demo_server/src/server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> channel: &SpatialChannelCell,
event: Event,
) {
match channel.try_borrow_mut(){
Ok(mut channel_ref) => {
channel_ref.publish(event);
},
Err(err) => {
panic!("Could not publish {:?}. Cause: {}", event, err)
}
}
}
fn subscribe(
cha... | code_fim | hard | {
"lang": "rust",
"repo": "pierre-l/spatiub",
"path": "/demo_server/src/server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nilsmartel/text-editor path: /src/render.rs
use crate::{State, Data};
use colored::Colorize;
use termion::{clear, terminal_size};
pub fn render(display: &mut impl std::io::Write, data: &Data, state: &State) -> Result<(), std::io::Error> {
// clear the entire screen
write!(display, "{}",... | code_fim | hard | {
"lang": "rust",
"repo": "nilsmartel/text-editor",
"path": "/src/render.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if cursor_on_line {
std::write!(display, "{}", " ".on_bright_blue())?;
}
// print chars
for (col,c) in content.iter().take(width-4).enumerate() {
if cursor_on_line && state.cursor.0 == col{
use colored::*;
let s = S... | code_fim | hard | {
"lang": "rust",
"repo": "nilsmartel/text-editor",
"path": "/src/render.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cfg_expected = "
*.foreground: #ffffff
*.background: #323232
*.color0: #000000
*.color8: #080808
*.color1: #010101
*.color9: #090909
*.color2: #020202
*.color10: #0a0a0a
*.color3: #030303
*.color11: #0b0b0b
*.color4: #040404
*.color12: #0c0c0c
*.color5: #050505
*.color13: #0d0d0d
*.color6: #06... | code_fim | hard | {
"lang": "rust",
"repo": "cideM/teems-rust",
"path": "/src/apps/x.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cideM/teems-rust path: /src/apps/x.rs
use crate::Theme;
use failure::Error;
use regex::Regex;
pub fn convert_colors(theme: &Theme, app_config: &str) -> Result<String, Error> {
let mut results: Vec<String> = vec![];
let re_line_with_color = Regex::new(
r"(?x)
^\*.
... | code_fim | hard | {
"lang": "rust",
"repo": "cideM/teems-rust",
"path": "/src/apps/x.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Sub for TimeStamp {
type Output = TimeSpan;
fn sub(self, rhs: TimeStamp) -> TimeSpan {
TimeSpan::from(self.0 - rhs.0)
}
}
impl Sub<TimeSpan> for TimeStamp {
type Output = TimeStamp;
fn sub(self, rhs: TimeSpan) -> TimeStamp {
TimeStamp(self.0 - Duration::from(rhs... | code_fim | medium | {
"lang": "rust",
"repo": "LiveSplit/livesplit-core",
"path": "/src/timing/time_stamp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LiveSplit/livesplit-core path: /src/timing/time_stamp.rs
use crate::{
platform::{Duration, Instant},
TimeSpan,
};
use core::ops::Sub;
<|fim_suffix|> TimeSpan::from(self.0 - rhs.0)
}
}
impl Sub<TimeSpan> for TimeStamp {
type Output = TimeStamp;
fn sub(self, rhs: Time... | code_fim | hard | {
"lang": "rust",
"repo": "LiveSplit/livesplit-core",
"path": "/src/timing/time_stamp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl EogLcdsGameDto {
pub fn new() -> EogLcdsGameDto {
EogLcdsGameDto {
banned_champions: None,
game_state: None,
id: None,
team_one: None,
team_two: None,
}
}
}<|fim_prefix|>// repo: Potato-Gaming/crystal path: /league-c... | code_fim | hard | {
"lang": "rust",
"repo": "Potato-Gaming/crystal",
"path": "/league-client/src/models/eog_lcds_game_dto.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Potato-Gaming/crystal path: /league-client/src/models/eog_lcds_game_dto.rs
/*
*
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
... | code_fim | hard | {
"lang": "rust",
"repo": "Potato-Gaming/crystal",
"path": "/league-client/src/models/eog_lcds_game_dto.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl VM {
pub fn new() -> VM {
VM { ip: 0, stack: vec![] }
}
pub fn interpret(&mut self, chunk: &Chunk) -> InterpretResult {
self.ip = 0;
self.run(chunk)
}
fn run(&mut self, chunk: &Chunk) -> InterpretResult {
loop {
if cfg!(feature = "tra... | code_fim | hard | {
"lang": "rust",
"repo": "jffjs/blintz",
"path": "/vm/src/vm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.run(chunk)
}
fn run(&mut self, chunk: &Chunk) -> InterpretResult {
loop {
if cfg!(feature = "trace_execution") {
print!(" ");
for val in &self.stack {
print!("[ {} ]", val);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jffjs/blintz",
"path": "/vm/src/vm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jffjs/blintz path: /vm/src/vm.rs
use failure::Error;
use num_traits::FromPrimitive;
use chunk::Chunk;
use debug::disassemble_instruction;
use opcode::OpCode;
use opcode::OpCode::*;
use value::Value;
#[derive(Debug, Fail)]
pub enum VmError {
#[fail(display = "Compile error")]
CompileErr... | code_fim | hard | {
"lang": "rust",
"repo": "jffjs/blintz",
"path": "/vm/src/vm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //タプルの取り出し方2つ
let (_x, _y, _z) = t1;
println!("The value of t1 is : {} {} {}", t1.0, t1.1, t1.2);
let mut t2 = ((0, 1), (2, 3));
let ((ref mut x1_ptr, ref mut y1_ptr), _) = t2; //入れ子のタプルにアクセスする方法refを使う。
*x1_ptr = 5; //参照を外す方法。先頭に*(アスタリスク)を付ける。
*y1_ptr = -4;
println!("{:?}", t2); //出力結果→ (... | code_fim | hard | {
"lang": "rust",
"repo": "kazu-S-1110/rust-lesson210712",
"path": "/src/vars.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kazu-S-1110/rust-lesson210712 path: /src/vars.rs
// pub mod sub_a; //サブモジュールを親でも使いたい場合はpubをつける
// mod sub_b;
// 定数はconstで宣言が可能,定数名は全て大文字で書く。
const MAX_POINT: u32 = 100_000;
// 変数はスコープの外では宣言が不可能。
// let z = 1; <- error
pub fn run() {
println!("Here is vars module");
// sub_a::func_a();
//... | code_fim | hard | {
"lang": "rust",
"repo": "kazu-S-1110/rust-lesson210712",
"path": "/src/vars.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn create_attachment_image(
vk_context: &super::context::VkContext,
command_pool: vk::CommandPool,
transition_queue: vk::Queue,
usage: vk::ImageUsageFlags,
layout: vk::ImageLayout,
extent: vk::Extent2D,
format: vk::Format,
sampler: Op... | code_fim | hard | {
"lang": "rust",
"repo": "chfi/gfaestus",
"path": "/src/vulkan/texture.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (img, mem) = super::GfaestusVk::create_image(
vk_context,
vk::MemoryPropertyFlags::DEVICE_LOCAL,
swapchain_props.extent,
msaa_samples,
format,
vk::ImageTiling::OPTIMAL,
Usage::TRANSIENT_ATTACHMENT | Usage::COLO... | code_fim | hard | {
"lang": "rust",
"repo": "chfi/gfaestus",
"path": "/src/vulkan/texture.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chfi/gfaestus path: /src/vulkan/texture.rs
_ix = super::find_memory_type(
mem_reqs,
vk_context.get_mem_properties(),
vk::MemoryPropertyFlags::DEVICE_LOCAL,
);
let alloc_info = vk::MemoryAllocateInfo::builder()
.allocation_size(mem_... | code_fim | hard | {
"lang": "rust",
"repo": "chfi/gfaestus",
"path": "/src/vulkan/texture.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: binh-vu/semantic-modeling path: /exec/src/functions.rs
use serde_json;
use input::RustInput;
use mira::assembling::models::annotator::Annotator;
use mira::assembling::learning::gen_train_data::gen_train_data;
use std::fs::File;
use mira::settings::Settings;
use std::path::Path;
use std::io::BufW... | code_fim | hard | {
"lang": "rust",
"repo": "binh-vu/semantic-modeling",
"path": "/exec/src/functions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return mrr_model;
}
pub fn predict(input: &RustInput, mrr_model: &MRRModel) {
let workdir = Path::new(&input.workdir);
let evaluate_sms = input.get_test_sms();
let pred_sms = predicting(&mrr_model, &evaluate_sms);
evaluate(&evaluate_sms, &pred_sms, &workdir.join("result.csv"));
se... | code_fim | hard | {
"lang": "rust",
"repo": "binh-vu/semantic-modeling",
"path": "/exec/src/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dskkato/custom-string-serde path: /tests/serde_test.rs
use custom_string_serde::custom_string_serde;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
custom_string_serde!(10, 60, 100);
pub struct Block {
x: i32,
y: i32,
name10: CustomString10,
_name60: Cu... | code_fim | medium | {
"lang": "rust",
"repo": "dskkato/custom-string-serde",
"path": "/tests/serde_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(block.x, 10);
assert_eq!(block.y, 20);
assert_eq!(block.name10.bytes, [0; 10]);
}<|fim_prefix|>// repo: dskkato/custom-string-serde path: /tests/serde_test.rs
use custom_string_serde::custom_string_serde;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
custom_... | code_fim | hard | {
"lang": "rust",
"repo": "dskkato/custom-string-serde",
"path": "/tests/serde_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn update(&mut self) {
self.rate = f64::max(self.rate - self.step, self.min)
}
}<|fim_prefix|>// repo: dkohlsdorf/RustWord2Vec path: /src/rate.rs
#[derive(Clone)]
pub struct LearningRate {
pub rate: f64,
pub min: f64,
pub step: f64
}
<|fim_middle|>impl LearningRate {
| code_fim | easy | {
"lang": "rust",
"repo": "dkohlsdorf/RustWord2Vec",
"path": "/src/rate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dkohlsdorf/RustWord2Vec path: /src/rate.rs
#[derive(Clone)]
pub struct LearningRate {
pub rate: f64,
pub min: f64,
pub step: f64
}
<|fim_suffix|> pub fn update(&mut self) {
self.rate = f64::max(self.rate - self.step, self.min)
}
}<|fim_middle|>impl LearningRate {
| code_fim | easy | {
"lang": "rust",
"repo": "dkohlsdorf/RustWord2Vec",
"path": "/src/rate.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[repr(C)]
#[derive(Debug)]
#[allow(non_snake_case)]
pub struct PROCESSOR_POWER_INFORMATION {
pub Number: minwindef::ULONG,
pub MaxMhz: minwindef::ULONG,
pub CurrentMhz: minwindef::ULONG,
pub MhzLimit: minwindef::ULONG,
pub MaxIdleState: minwindef::ULONG,
pub CurrentIdleState: minw... | code_fim | easy | {
"lang": "rust",
"repo": "ilya-epifanov/heim",
"path": "/heim-cpu/src/sys/windows/bindings/power.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ilya-epifanov/heim path: /heim-cpu/src/sys/windows/bindings/power.rs
#![allow(clippy::upper_case_acronyms)] // It is fine for bindings
<|fim_suffix|>#[repr(C)]
#[derive(Debug)]
#[allow(non_snake_case)]
pub struct PROCESSOR_POWER_INFORMATION {
pub Number: minwindef::ULONG,
pub MaxMhz: mi... | code_fim | easy | {
"lang": "rust",
"repo": "ilya-epifanov/heim",
"path": "/heim-cpu/src/sys/windows/bindings/power.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: philhofer/calc-rs path: /src/calculus.rs
//! The `calculus` module contains utilities
//! for performing integration, differentiation,
//! and root-finding.
use std::f64;
/// `UnivariateFn` is a function that
/// takes one `f64` and returns another.
/// Its implementors are assumed to be
/// a... | code_fim | hard | {
"lang": "rust",
"repo": "philhofer/calc-rs",
"path": "/src/calculus.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> macro_rules! test_square {
($a:expr, $b:expr) => {
{
want!(quad_slow(&square, $a, $b), square_integral($a, $b));
want!(quad_fast(&square, $a, $b), square_integral($a, $b));
want!(romberg_integral(&square, $a, $b, 1e-8f64).unwrap(), square_integral($a, $b));
want!(diff(&square, $a).un... | code_fim | hard | {
"lang": "rust",
"repo": "philhofer/calc-rs",
"path": "/src/calculus.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut res = self.clone();
res.clear();
for i in 0..self.0.len() {
for j in 0..self.0.len() {
for k in 0..self.0.len() {
res.0[i][j] = (res.0[i][j] + (self.0[i][k] * rhs.0[k][j])%res.1)%res.1;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "TangliziGit/leetcode",
"path": "/rust/offer10-1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TangliziGit/leetcode path: /rust/offer10-1.rs
#[derive(Clone, Debug)] // ! Clone impl
struct Matrix(Vec<Vec<u64>>, u64); // ! semicolon
impl Matrix {
fn new(data: Vec<Vec<u64>>, m: u64) -> Matrix {
Matrix(data, m)
}
fn clear(&mut se... | code_fim | hard | {
"lang": "rust",
"repo": "TangliziGit/leetcode",
"path": "/rust/offer10-1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while i <= n {
println!("{}: {:?} {}", i, self, n & i);
if n & i != 0 {
self = self.mul(tmp.clone());
}
i <<= 1;
tmp = tmp.mul(tmp.clone());
println!("tmp: {:?}", tmp);
}
println!("res: {:?}", s... | code_fim | hard | {
"lang": "rust",
"repo": "TangliziGit/leetcode",
"path": "/rust/offer10-1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>1));
println!("{:?}", a.saturating_add(1));
f(n);
println!("{}", 12i32.abs());
}
fn f(n: i32) {
println!("n={}", n)
}<|fim_prefix|>// repo: softlightwebinfo/symfony-codeunic path: /rust/hola_mundo/src/main2.rs
fn main2() {
let n = 10_100_234;
let a:u8 = 255;
print<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "softlightwebinfo/symfony-codeunic",
"path": "/rust/hola_mundo/src/main2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: softlightwebinfo/symfony-codeunic path: /rust/hola_mundo/src/main2.rs
fn main2() {
let n = 10_100_234;
let a:u8 = 255;
print<|fim_suffix|>ln!("{}", 12i32.abs());
}
fn f(n: i32) {
println!("n={}", n)
}<|fim_middle|>ln!("{:?}", a.checked_add(1));
println!("{:?}", a.wrapping_ad... | code_fim | medium | {
"lang": "rust",
"repo": "softlightwebinfo/symfony-codeunic",
"path": "/rust/hola_mundo/src/main2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gilescope/clique path: /src/membership/mod.rs
mod view;
use crate::transport::Request;
use view::View;
<|fim_suffix|> pub async fn handle_message(&mut self, req: Request) {
unimplemented!()
}
pub async fn tick(&mut self) {
unimplemented!()
}
}<|fim_middle|>#[der... | code_fim | hard | {
"lang": "rust",
"repo": "gilescope/clique",
"path": "/src/membership/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn handle_message(&mut self, req: Request) {
unimplemented!()
}
pub async fn tick(&mut self) {
unimplemented!()
}
}<|fim_prefix|>// repo: gilescope/clique path: /src/membership/mod.rs
mod view;
use crate::transport::Request;
use view::View;
<|fim_middle|>#[der... | code_fim | hard | {
"lang": "rust",
"repo": "gilescope/clique",
"path": "/src/membership/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>he bit returns its current enable state."]
#[inline(always)]
pub fn clrena32(&self) -> CLRENA32_R {
CLRENA32_R::new((self.bits & 0x01) != 0)
}
}
impl W {
#[doc = "Bits 6:31 - 31:6\\]
Software should not rely on the value of a reserved. Writing any other value than the reset value m... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/cpu_scs/nvic_icer1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeandudey/cc13x2-rs path: /src/cpu_scs/nvic_icer1.rs
#[doc = "Reader of register NVIC_ICER1"]
pub type R = crate::R<u32, super::NVIC_ICER1>;
#[doc = "Writer for register NVIC_ICER1"]
pub type W = crate::W<u32, super::NVIC_ICER1>;
#[doc = "Register NVIC_ICER1 `reset()`'s with value 0"]
impl crate... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/cpu_scs/nvic_icer1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devpts00/generust path: /src/main.rs
#![feature(try_trait)]
#![feature(test)]
use std::io::{BufWriter, Read, Write};
use structopt::StructOpt;
use options::Options;
use crate::generust::{Error, Parser, Result};
mod generust;
mod logger;
mod options;
fn quit(code: Option<i32>) {
std::pr... | code_fim | medium | {
"lang": "rust",
"repo": "devpts00/generust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stdout = std::io::stdout();
let output = stdout.lock();
let mut buffer = BufWriter::new(output);
let mut p = 0;
for i in 0..opts.count {
generust.generate(i, &mut buffer)?;
let n = 100 * i / opts.count;
if n > p {
p = n;
log::debug!("... | code_fim | hard | {
"lang": "rust",
"repo": "devpts00/generust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nambrosini/adventofcode path: /2015/src/day04.rs
use md5::{Digest, Md5};
#[aoc(day4, part1)]
pub fn part1(input: &str) -> usize {
let key = input.as_bytes();
for i in 0.. {
let mut hasher = Md5::new();
hasher.update(key);
hasher.update(i.to_string().as_bytes());
... | code_fim | hard | {
"lang": "rust",
"repo": "nambrosini/adventofcode",
"path": "/2015/src/day04.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn sample1_test1() {
let s = "abcdef";
assert_eq!(part1(s), 609043);
}
#[test]
fn sample2_test1() {
let s = "pqrstuv";
assert_eq!(part1(s), 1048970);
}
}<|fim_prefix|>// repo: nambrosini/adventofcode path: /2015/src/day04.rs
use md5::{Dig... | code_fim | hard | {
"lang": "rust",
"repo": "nambrosini/adventofcode",
"path": "/2015/src/day04.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nipierre/mcai_worker_sdk path: /c_mcai_worker_sdk/src/lib.rs
mod constants;
#[cfg(feature = "media")]
mod media;
mod parameters;
mod process_return;
mod types;
#[macro_use]
mod utils;
pub mod worker;
<|fim_suffix|>#[macro_use]
extern crate serde_derive;<|fim_middle|>pub use utils::{get_worker_p... | code_fim | medium | {
"lang": "rust",
"repo": "nipierre/mcai_worker_sdk",
"path": "/c_mcai_worker_sdk/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_use]
extern crate serde_derive;<|fim_prefix|>// repo: nipierre/mcai_worker_sdk path: /c_mcai_worker_sdk/src/lib.rs
mod constants;
#[cfg(feature = "media")]
mod media;
mod parameters;
mod process_return;
mod types;
#[macro_use]
mod utils;
pub mod worker;
<|fim_middle|>pub use utils::{get_worker_p... | code_fim | medium | {
"lang": "rust",
"repo": "nipierre/mcai_worker_sdk",
"path": "/c_mcai_worker_sdk/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/syn/v1/crate/src/path.rs
}
if input.peek(Lit) || input.peek(token::Brace) {
return const_argument(input).map(GenericArgument::Const);
}
#[cfg(feature = "full")]
let begin = input.fork(... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/syn/v1/crate/src/path.rs",
"mode": "psm",
"license": "GPL-1.0-or-later",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn qpath(input: ParseStream, expr_style: bool) -> Result<(Option<QSelf>, Path)> {
if input.peek(Token![<]) {
let lt_token: Token![<] = input.parse()?;
let this: Type = input.parse()?;
let path = if input.peek(Token![as]) {
let as_token: T... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/syn/v1/crate/src/path.rs",
"mode": "spm",
"license": "GPL-1.0-or-later",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for Path {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.leading_colon.to_tokens(tokens);
self.segments.to_tokens(tokens);
}
}
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing"... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/syn/v1/crate/src/path.rs",
"mode": "spm",
"license": "GPL-1.0-or-later",
"source": "the-stack-v2"
} |
<|fim_suffix|> for include in includes {
cmd.arg("-I").arg(include.as_ref());
}
// Set the protoc include after the user includes in case the user wants to
// override one of the built-in .protos.
cmd.arg("-I").arg(protoc_include);
for proto in protos {
cmd.arg(proto.as_ref());
... | code_fim | hard | {
"lang": "rust",
"repo": "overvenus/prost",
"path": "/prost-build/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: overvenus/prost path: /prost-build/src/lib.rs
//! `prost-build` is a small library which makes it easy to add build-time code generation of
//! `.proto` files to a Cargo project.
//!
//! ## Example
//!
//! Let's create a small crate, `snazzy`, that defines a collection of
//! snazzy new items in... | code_fim | hard | {
"lang": "rust",
"repo": "overvenus/prost",
"path": "/prost-build/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>use prost::Message;
use prost_codegen::google::protobuf::FileDescriptorSet;
use prost_codegen::CodeGeneratorConfig;
/// Compile `.proto` files into Rust files during a Cargo build.
///
/// The generated `.rs` files will be written to the Cargo `OUT_DIR` directory, suitable for use
/// with the [include!... | code_fim | hard | {
"lang": "rust",
"repo": "overvenus/prost",
"path": "/prost-build/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if layer_properties.is_empty() {
return Err(UrnError::Generic("No available layers."));
}
for layer_needed in validation_layer_names.iter() {
let mut is_layer_found = false;
for layer in layer_properties.iter() {
if *layer_needed == vk_to_string(&layer.laye... | code_fim | hard | {
"lang": "rust",
"repo": "leod/ash-urn",
"path": "/src/base/validation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leod/ash-urn path: /src/base/validation.rs
use crate::error::UrnError;
use crate::util::vk_to_string;
use ash::version::EntryV1_0;
unsafe extern "system" fn vulkan_debug_utils_callback(
message_severity: ash::vk::DebugUtilsMessageSeverityFlagsEXT,
message_type: ash::vk::DebugUtilsMessa... | code_fim | hard | {
"lang": "rust",
"repo": "leod/ash-urn",
"path": "/src/base/validation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn clips_in_range(&self, start: TicksTime, until: TicksTime) -> impl Iterator<Item = &Clip> {
// TODO use an Interval Tree (http://www.davismol.net/2016/02/07/data-structures-augmented-interval-tree-to-search-for-interval-overlapping/)
self.clips.iter().filter(move |clip| {
let end = c... | code_fim | hard | {
"lang": "rust",
"repo": "chris-zen/hero-studio",
"path": "/core/src/song/track/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chris-zen/hero-studio path: /core/src/song/track/mod.rs
pub mod audio;
pub mod instrument;
pub mod midi;
use crate::color::Color;
use crate::song::{
clips::Clip,
track::{audio::AudioTrack, instrument::InstrumentTrack, midi::MidiTrack},
};
use crate::time::TicksTime;
pub enum TrackMedia {... | code_fim | medium | {
"lang": "rust",
"repo": "chris-zen/hero-studio",
"path": "/core/src/song/track/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: appcypher/wasmo path: /runtime/lib/compiler/imports.rs
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Imports {
pub memories: Vec<Import>,
pub tables: Vec<Import>,
pub functions: Vec<Import>,
pub globals: Vec<Import>,
}
<|fim_s... | code_fim | medium | {
"lang": "rust",
"repo": "appcypher/wasmo",
"path": "/runtime/lib/compiler/imports.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Import {
pub fn new(module: String, field: Option<String>, index: u32) -> Self {
Self {
module,
field,
index,
}
}
}<|fim_prefix|>// repo: appcypher/wasmo path: /runtime/lib/compiler/imports.rs
use serde::{Deserialize, Serialize};
#[derive(... | code_fim | medium | {
"lang": "rust",
"repo": "appcypher/wasmo",
"path": "/runtime/lib/compiler/imports.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FSMaxB/rust-genealogy path: /genealogy-java-apis/src/completable_future.rs
use crate::exception::Exception;
use futures_lite::future::block_on;
use pin_project::pin_project;
use std::convert::identity;
use std::future::{ready, Future};
use std::ops::FnOnce;
use std::pin::Pin;
<|fim_suffix|> pub... | code_fim | hard | {
"lang": "rust",
"repo": "FSMaxB/rust-genealogy",
"path": "/genealogy-java-apis/src/completable_future.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn exceptionally_compose_async(
self,
function: impl FnOnce(Exception) -> Result<Self, Exception> + 'static,
) -> Self {
async move {
match self.future.await {
ok @ Ok(_) => ok,
Err(exception) => match function(exception) {
Ok(completable_future) => completable_future.future.aw... | code_fim | hard | {
"lang": "rust",
"repo": "FSMaxB/rust-genealogy",
"path": "/genealogy-java-apis/src/completable_future.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brendanrbrown/extendr path: /extendr-api/src/logical.rs
/// Bool is a wrapper for i32 in the context of an R's tristate boolean.
/// It can be TRUE, FALSE or NA_LOGICAL.
#[derive(PartialEq, Eq)]
pub struct Bool(pub i32);
impl Bool {
/// Convert this Bool to a bool. Note NA will be true.
... | code_fim | hard | {
"lang": "rust",
"repo": "brendanrbrown/extendr",
"path": "/extendr-api/src/logical.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<i32> for Bool {
fn from(v: i32) -> Self {
Self(v)
}
}
impl From<bool> for Bool {
fn from(v: bool) -> Self {
Self(v as i32)
}
}
impl From<Bool> for bool {
fn from(v: Bool) -> Self {
v.0 != 0
}
}
impl From<&Bool> for bool {
fn from(v: &Bool) -... | code_fim | hard | {
"lang": "rust",
"repo": "brendanrbrown/extendr",
"path": "/extendr-api/src/logical.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<&Bool> for bool {
fn from(v: &Bool) -> Self {
v.0 != 0
}
}
impl std::fmt::Debug for Bool {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Bool(0) => write!(f, "FALSE"),
Bool(1) => write!(f, "TRUE"),
... | code_fim | hard | {
"lang": "rust",
"repo": "brendanrbrown/extendr",
"path": "/extendr-api/src/logical.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atsamd-rs/atsamd path: /boards/xiao_m0/examples/blink.rs
#![no_main]
#![no_std]
extern crate panic_halt;
use hal::{clock::GenericClockController, delay::Delay, prelude::*};
use pac::{CorePeripherals, Peripherals};
use bsp::{entry, hal, pac, Led0};
use xiao_m0 as bsp;
<|fim_suffix|> let mu... | code_fim | medium | {
"lang": "rust",
"repo": "atsamd-rs/atsamd",
"path": "/boards/xiao_m0/examples/blink.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut delay = Delay::new(core.SYST, &mut clocks);
let mut led0: Led0 = pins.led0.into_push_pull_output();
loop {
delay.delay_ms(200u8);
led0.toggle().unwrap();
}
}<|fim_prefix|>// repo: atsamd-rs/atsamd path: /boards/xiao_m0/examples/blink.rs
#![no_main]
#![no_std]
ext... | code_fim | hard | {
"lang": "rust",
"repo": "atsamd-rs/atsamd",
"path": "/boards/xiao_m0/examples/blink.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kirillt/hypercube path: /src/core.rs
use nalgebra::{Point3, Point4, Vector4, Matrix, MatrixArray, U4};
use std::rc::Rc;
pub use std::f32::consts::PI;
pub type CoordFloat = f32;
pub type Vector = Vector4<CoordFloat>;
pub type Point = Point4<CoordFloat>;
pub fn origin() -> Point { Point::origin... | code_fim | hard | {
"lang": "rust",
"repo": "kirillt/hypercube",
"path": "/src/core.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn scale(factor: CoordFloat) -> Matrix4 {
Matrix4::new(factor, 0., 0., 0.,
0., factor, 0., 0.,
0., 0., factor, 0.,
0., 0., 0., factor)
}
pub type Refs<T> = Vec<Rc<T>>;
pub fn clone_points(refs: Refs<Vec<Point>... | code_fim | hard | {
"lang": "rust",
"repo": "kirillt/hypercube",
"path": "/src/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/ordered-float/src/lib.rs
:
meta
]
)
*
impl
(
OrderedFloat
<
U
:
ty
>
)
)
=
>
{
(
#
[
cfg
]
)
*
impl
AsPrimitive
<
OrderedFloat
<
U
>
>
for
T
{
#
[
inline
]
fn
as_
(
self
)
-
>
OrderedFloat
<
U
>
{
OrderedFloat
(
self
as
U
)
}
}
}
;
(
(
Ordered... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/ordered-float/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
{
unsafe
{
NotNan
:
:
new_unchecked
(
v
.
0
as
f64
)
}
}
}
impl
<
T
:
Float
>
Deref
for
NotNan
<
T
>
{
type
Target
=
T
;
#
[
inline
]
fn
deref
(
&
self
)
-
>
&
Self
:
:
Target
{
&
self
.
0
}
}
impl
<
T
:
Float
+
PartialEq
>
Eq
for
NotNan
<
T
>
{
}
impl
<
T
:
Float
>
PartialEq
<
T
>
for
NotNan
<
T
>
{
#
[... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/ordered-float/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/ordered-float/src/lib.rs
2
(
&
self
)
-
>
Option
<
u32
>
{
self
.
0
.
to_u32
(
)
}
fn
to_f32
(
&
self
)
-
>
Option
<
f32
>
{
self
.
0
.
to_f32
(
)
}
fn
to_f64
(
&
self
)
-
>
Option
<
f64
>
{
self
.
0
.
to_f64
(
)
}
}
/
/
/
An
error
indicating
a... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/ordered-float/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn on_record(&self, id: &tracing::Id, values: &tracing::span::Record<'_>, ctx: Context<'_, S>) {
if let Some(span_ref) = ctx.span(id) {
if let Some(debug_record) = span_ref.extensions_mut().get_mut::<LogLineBuffer>() {
values.record(debug_record);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "finos/perspective",
"path": "/rust/perspective-viewer/src/rust/utils/console_logger.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A custom logger modelled afer the `tracing_wasm` crate.
struct WasmLogger {
max_level: tracing::Level,
}
impl Default for WasmLogger {
fn default() -> Self {
Self {
max_level: tracing::Level::TRACE,
}
}
}
impl<S: Subscriber + for<'a> LookupSpan<'a>> Layer<S> f... | code_fim | hard | {
"lang": "rust",
"repo": "finos/perspective",
"path": "/rust/perspective-viewer/src/rust/utils/console_logger.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: finos/perspective path: /rust/perspective-viewer/src/rust/utils/console_logger.rs
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████... | code_fim | hard | {
"lang": "rust",
"repo": "finos/perspective",
"path": "/rust/perspective-viewer/src/rust/utils/console_logger.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // # types of closure traits
// - FnOnce: consumes the variables it captures from its enclosing scope, known as the closure’s environment. To consume the captured variables, the closure must take ownership of these variables and move them into the closure when it is defined. The Once part of the n... | code_fim | hard | {
"lang": "rust",
"repo": "Hermitter/rust-book-2018-notes",
"path": "/src/bin/ch13_functional_language_features/closures.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hermitter/rust-book-2018-notes path: /src/bin/ch13_functional_language_features/closures.rs
// closures are anonymous functions that can capture values from
// the scope of which they're defined.
use std::thread;
use std::time::Duration;
pub fn run() {
println!("testing");
// # Exampl... | code_fim | hard | {
"lang": "rust",
"repo": "Hermitter/rust-book-2018-notes",
"path": "/src/bin/ch13_functional_language_features/closures.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(equal_to_x(4));
// # types of closure traits
// - FnOnce: consumes the variables it captures from its enclosing scope, known as the closure’s environment. To consume the captured variables, the closure must take ownership of these variables and move them into the closure when it is de... | code_fim | hard | {
"lang": "rust",
"repo": "Hermitter/rust-book-2018-notes",
"path": "/src/bin/ch13_functional_language_features/closures.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eddiehoyle/wasm-webgl path: /pong/src/input/mod.rs
use shrev::EventChannel;
use crate::event::*;
use std::collections::HashMap;
use std::collections::HashSet;
<|fim_suffix|>#[derive(Default)]
pub struct InputHandler {
keyset: HashSet<String>,
}
impl InputHandler {
pub fn new() -> Self ... | code_fim | medium | {
"lang": "rust",
"repo": "eddiehoyle/wasm-webgl",
"path": "/pong/src/input/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl InputHandler {
pub fn new() -> Self {
Default::default()
}
pub fn press(&mut self, key: &String) {
self.keyset.insert(key.clone());
}
pub fn release(&mut self, key: &String) {
self.keyset.remove(key);
}
pub fn is_pressed(&self, key: &String) -> bool... | code_fim | medium | {
"lang": "rust",
"repo": "eddiehoyle/wasm-webgl",
"path": "/pong/src/input/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oc-soft/glrs path: /src/wasm/distance_indices.rs
use crate::Distance;
use js_sys::Uint32Array;
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
/// create instance
pub fn distance_indices_create_0(
di: BTreeMap<Distance, Rc<RefCell<Vec<u... | code_fim | hard | {
"lang": "rust",
"repo": "oc-soft/glrs",
"path": "/src/wasm/distance_indices.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut keys = Vec::new();
for key in keys_itr {
keys.push(*key);
}
Rc::into_raw(Rc::new(keys))
}
} else {
std::ptr::null()
}
}
/// get indices
#[wasm_bindgen]
pub fn distance_indices_get_indices(
di: *const BTree... | code_fim | hard | {
"lang": "rust",
"repo": "oc-soft/glrs",
"path": "/src/wasm/distance_indices.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// get indices
#[wasm_bindgen]
pub fn distance_indices_get_indices(
di: *const BTreeMap<Distance, Rc<RefCell<Vec<usize>>>>,
distance: *const Distance,
) -> Option<Uint32Array> {
if !di.is_null() && !distance.is_null() {
unsafe {
match (*di).get(&*distance) {
... | code_fim | hard | {
"lang": "rust",
"repo": "oc-soft/glrs",
"path": "/src/wasm/distance_indices.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amethyst/grumpy_visitors path: /bins/client/src/ecs/systems/mod.rs
mod animation;
mod camera_translation;
mod client_network;
mod custom_sprite_sorting;
mod game_updates_broadcasting;
mod hud;
mod imgui_network_debug_info;
mod input;<|fim_suffix|>,
imgui_network_debug_info::ImguiNetworkDebug... | code_fim | hard | {
"lang": "rust",
"repo": "amethyst/grumpy_visitors",
"path": "/bins/client/src/ecs/systems/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>,
imgui_network_debug_info::ImguiNetworkDebugInfoSystem,
input::InputSystem,
menu::MenuSystem,
overlay::OverlaySystem,
particle::ParticleSystem,
};<|fim_prefix|>// repo: amethyst/grumpy_visitors path: /bins/client/src/ecs/systems/mod.rs
mod animation;
mod camera_translation;
mod clien... | code_fim | hard | {
"lang": "rust",
"repo": "amethyst/grumpy_visitors",
"path": "/bins/client/src/ecs/systems/mod.rs",
"mode": "spm",
"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.