text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> /// Retrieve the next row group writer. May trigger creation of a new file if limit of the
/// previous one is reached.
///
/// # Parameters
///
/// * `num_batch`: Zero based num batch index
pub fn next_row_group(&mut self, num_batch: u32) -> Result<Box<dyn RowGroupWriter>, Err... | code_fim | hard | {
"lang": "rust",
"repo": "Bernolt/odbc2parquet",
"path": "/src/query.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jes44bc/mio path: /src/sys/unix/io.rs
use std::io;
use crate::sys::unix::cvt;
pub fn set_nonblock(fd: libc::c_int) -> io::Result<()> {
unsafe {
let flags = libc::fcntl(fd, libc::F_GETFL);
<|fim_suffix|>_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os ... | code_fim | medium | {
"lang": "rust",
"repo": "jes44bc/mio",
"path": "/src/sys/unix/io.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>esult<()> {
unsafe {
let flags = libc::fcntl(fd, libc::F_GETFD);
cvt(libc::fcntl(fd, libc::F_SETFD, flags | libc::FD_CLOEXEC)).map(|_| ())
}
}<|fim_prefix|>// repo: jes44bc/mio path: /src/sys/unix/io.rs
use std::io;
use crate::sys::unix::cvt;
pub fn set_nonblock(fd: libc::c_int)... | code_fim | hard | {
"lang": "rust",
"repo": "jes44bc/mio",
"path": "/src/sys/unix/io.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn push(&mut self, e: Elem) {
self.elems.push(e);
while self.elems.len() >= 2 && self.elems[self.elems.len()-1].height == self.elems[self.elems.len()-2].height {
self.collapse();
}
}
fn collapse(&mut self) {
let last = self.elems.len()-1;
self.hash.reset();
self.hash.input(&self.elems[l... | code_fim | medium | {
"lang": "rust",
"repo": "rlkelly/p2p",
"path": "/src/tree_utils/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: crypto::digest::Digest> Stack<T> {
pub fn new(hash: T) -> Stack<T> {
Stack{
hash: hash,
elems: Vec::new(),
}
}
fn push(&mut self, e: Elem) {
self.elems.push(e);
while self.elems.len() >= 2 && self.elems[self.elems.len()-1].height == self.elems[self.elems.len()-2].height {
self... | code_fim | medium | {
"lang": "rust",
"repo": "rlkelly/p2p",
"path": "/src/tree_utils/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rlkelly/p2p path: /src/tree_utils/mod.rs
use std::io::prelude::*;
extern crate rustc_serialize as serialize;
use serialize::hex::ToHex;
const SEGSIZE: usize = 64;
pub struct Stack<T: crypto::digest::Digest> {
hash: T,
elems: Vec<Elem>,
}
<|fim_suffix|> fn push(&mut self, e: Elem) {
self.... | code_fim | medium | {
"lang": "rust",
"repo": "rlkelly/p2p",
"path": "/src/tree_utils/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Conf {
window_title: "ShipGame".to_string(),
window_width: 640,
window_height: 480,
//window_resizable: false,
..Default::default()
}
}
#[macroquad::main(configure_window)]
async fn main() {
let camera = Camera2D::from_display_rect(Rect::new(0., 0., 640... | code_fim | medium | {
"lang": "rust",
"repo": "KamilM1205/shipgame",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KamilM1205/shipgame path: /src/main.rs
use macroquad::camera::{set_camera, Camera2D};
use macroquad::color::BLACK;
use macroquad::math::Rect;
use macroquad::text::draw_text;
use macroquad::time::{get_fps, get_frame_time};
use macroquad::window::{next_frame, Conf};
mod config;
mod game_objects;
... | code_fim | hard | {
"lang": "rust",
"repo": "KamilM1205/shipgame",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aiuto/starlark-rust path: /starlark/src/eval/runtime/evaluator.rs
/*
* Copyright 2019 The Starlark in Rust Authors.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with th... | code_fim | hard | {
"lang": "rust",
"repo": "aiuto/starlark-rust",
"path": "/starlark/src/eval/runtime/evaluator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Run the computation
let res = within(self);
// Restore them all back
self.set_codemap(old_codemap);
self.module_variables = old_module_variables;
res
}
pub(crate) fn walk(&mut self, walker: &Walker<'v>) {
let mut roots = self.module_env.... | code_fim | hard | {
"lang": "rust",
"repo": "aiuto/starlark-rust",
"path": "/starlark/src/eval/runtime/evaluator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<N: RealField + Copy> PolylineCompatibleCap<N> for ArrowheadCap<N> {
fn gen_end_cap(
&self,
attach_id: u32,
pattern: &[Point3<N>],
pt: &Point3<N>,
dir: &Vector3<N>,
closed: bool,
coords: &mut Vec<Point3<N>>,
indices: &mut Vec<Point3<u... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/ncollide",
"path": "/src/procedural/path/arrowhead_cap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimforge/ncollide path: /src/procedural/path/arrowhead_cap.rs
use crate::procedural::path::PolylineCompatibleCap;
use crate::procedural::utils;
use na::{self, Isometry3, Point3, Vector3};
use simba::scalar::RealField;
/// A cap that looks like an arrow.
pub struct ArrowheadCap<N> {
radius_s... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/ncollide",
"path": "/src/procedural/path/arrowhead_cap.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !(self.radius_scale == na::convert(1.0)) || !back_dist_to_head.is_zero() {
let mut new_pattern: Vec<Point3<N>> =
pattern.iter().map(|p| p * self.radius_scale).collect();
// NOTE: this is done exactly the same on the PolylinePattern::stroke method.
... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/ncollide",
"path": "/src/procedural/path/arrowhead_cap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_native_system_info() -> SystemInfo {
let mut info = mem::MaybeUninit::<sysinfoapi::SYSTEM_INFO>::uninit();
unsafe {
// https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getnativesysteminfo
// Returns nothing and can't fail, apparently
sysinf... | code_fim | hard | {
"lang": "rust",
"repo": "eeyun/heim",
"path": "/heim-host/src/sys/windows/platform.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eeyun/heim path: /heim-host/src/sys/windows/platform.rs
use std::ffi::OsString;
use std::fmt;
use std::mem;
use std::os::windows::ffi::OsStringExt;
use ntapi::ntrtl;
use winapi::shared::{minwindef, ntstatus};
use winapi::um::{sysinfoapi, winbase, winnt};
use heim_common::prelude::{Error, Resul... | code_fim | hard | {
"lang": "rust",
"repo": "eeyun/heim",
"path": "/heim-host/src/sys/windows/platform.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Based on the `platform-info` crate source:
/// https://github.com/uutils/platform-info/blob/8fa071f764d55bd8e41a96cf42009da9ae20a650/src/windows.rs
fn rtl_get_version() -> winnt::OSVERSIONINFOEXW {
let mut osinfo = mem::MaybeUninit::<winnt::RTL_OSVERSIONINFOEXW>::uninit();
unsafe {
(*... | code_fim | hard | {
"lang": "rust",
"repo": "eeyun/heim",
"path": "/heim-host/src/sys/windows/platform.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Noah2610/pong-cli path: /src/systems/move_entities/mod.rs
mod collision;
use super::system_prelude::*;
use collision::*;
#[derive(Default)]
pub struct MoveEntitiesSystem;
impl<'a> System<'a> for MoveEntitiesSystem {
type SystemData = (
Entities<'a>,
Read<'a, Deltatime>,
... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/pong-cli",
"path": "/src/systems/move_entities/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let collision_grid =
gen_collision_grid(&entities, &positions, &sizes, &collisions);
for (
entity,
mut position,
velocity,
size_opt,
collider_opt,
collision_opt,
) in (
&entities,
... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/pong-cli",
"path": "/src/systems/move_entities/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (
entity,
mut position,
velocity,
size_opt,
collider_opt,
collision_opt,
) in (
&entities,
&mut positions,
&velocities,
sizes.maybe(),
(&mut colliders).ma... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/pong-cli",
"path": "/src/systems/move_entities/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akane10/gtrend path: /src/developers.rs
use crate::error::Error;
use crate::*;
use select::document::Document;
use select::predicate::{Class, Name};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use std::borrow::Borrow;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub s... | code_fim | hard | {
"lang": "rust",
"repo": "akane10/gtrend",
"path": "/src/developers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if y.len() > 0 {
Some(y[0].to_string())
} else {
None
}
});
let repo_name: Option<String> = node.find(Class("h4")).next().map(|x| escape(x.text()));
let url... | code_fim | hard | {
"lang": "rust",
"repo": "akane10/gtrend",
"path": "/src/developers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yananlulu/arete path: /src/app/http/routes.rs
use rocket::config::{ConfigBuilder, Environment, LoggingLevel};
<|fim_suffix|>pub fn run() -> Result<()> {
let app = super::rocket(
ConfigBuilder::new(Environment::Production)
.log_level(LoggingLevel::Off)
.finali... | code_fim | medium | {
"lang": "rust",
"repo": "Yananlulu/arete",
"path": "/src/app/http/routes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run() -> Result<()> {
let app = super::rocket(
ConfigBuilder::new(Environment::Production)
.log_level(LoggingLevel::Off)
.finalize()?,
);
println!("METHOD\tRANK\tURI");
app.routes()
.for_each(|it| println!("{}\t{}\t{}", it.method, it.rank, it.... | code_fim | medium | {
"lang": "rust",
"repo": "Yananlulu/arete",
"path": "/src/app/http/routes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iLGunners/Algorithms-in-Rust path: /sort/selection-sort/src/main.rs
fn selection_sort(array: &mut [i8]) {
for i in 0..array.len() {
let min_index = (i..array.len()).min_by_key(|x| array[*x]).unwrap();
array.swap(min_index, i)
}
}
fn main() {
<|fim_suffix|> selection_s... | code_fim | medium | {
"lang": "rust",
"repo": "iLGunners/Algorithms-in-Rust",
"path": "/sort/selection-sort/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("___ Selection Sort ___");
let mut num_list = [ 5, 9, 8, 4, 1, 10, 7, 2, 3, 6, 0 ];
println!("unsorted list: {:?}", num_list);
selection_sort(&mut num_list);
println!("sorted list: {:?}", num_list);
}<|fim_prefix|>// repo: iLGunners/Algorithms-in-Rust path: /sort/selection... | code_fim | easy | {
"lang": "rust",
"repo": "iLGunners/Algorithms-in-Rust",
"path": "/sort/selection-sort/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in (0..(n as usize - 1)).rev() {
ret[i] += ret[i + 1];
}
ret
}
}<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1109-Corporate Flight Bookings/Solution.rs
impl Solution {
pub fn corp_flight_bookings(bookings: Vec<Vec<i32>>, n: i32) -> Vec<i32> {
... | code_fim | hard | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/1109-Corporate Flight Bookings/Solution.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1109-Corporate Flight Bookings/Solution.rs
impl Solution {
pub fn corp_flight_bookings(bookings: Vec<Vec<i32>>, n: i32) -> Vec<i32> {
let mut ret = vec![0; n as usize];
<|fim_suffix|> for i in (0..(n as usize - 1)).rev() {
ret[i] +... | code_fim | hard | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/1109-Corporate Flight Bookings/Solution.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leod/hooks path: /hooks_util/src/profile.rs
// This module's implementation has been inspired by hprof:
// <https://cmr.github.io/hprof/src/hprof/lib.rs.html>
use std::cell::RefCell;
use std::rc::Rc;
use std::time::{Duration, Instant};
use debug;
use timer;
thread_local!(pub static PROFILER: ... | code_fim | hard | {
"lang": "rust",
"repo": "leod/hooks",
"path": "/hooks_util/src/profile.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.duration_sum = self.duration_sum
.checked_add(self.start_instant.unwrap().elapsed())
.unwrap();
}
}
pub struct Guard;
impl Drop for Guard {
fn drop(&mut self) {
PROFILER.with(|p| p.borrow_mut().leave());
}
}
pub struct Profiler {
root: Rc<Ref... | code_fim | hard | {
"lang": "rust",
"repo": "leod/hooks",
"path": "/hooks_util/src/profile.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
pub(crate) async fn read_message_with_timeout(
&mut self,
duration: Duration,
) -> Result<Option<Message>> {
match tokio::time::timeout(duration, self.read_message()).await {
Ok(read_result) => read_result,
Err(elapsed) => Err(E... | code_fim | hard | {
"lang": "rust",
"repo": "ymgyt/kvsd",
"path": "/src/protocol/connection/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ymgyt/kvsd path: /src/protocol/connection/mod.rs
use std::io::{self, Cursor};
use bytes::{Buf, BytesMut};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, BufWriter};
use tokio::net::TcpStream;
use tokio::time::Duration;
use crate::common::{Error, Result};
use crate::error::... | code_fim | hard | {
"lang": "rust",
"repo": "ymgyt/kvsd",
"path": "/src/protocol/connection/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) async fn read_message_with_timeout(
&mut self,
duration: Duration,
) -> Result<Option<Message>> {
match tokio::time::timeout(duration, self.read_message()).await {
Ok(read_result) => read_result,
Err(elapsed) => Err(Error::from(elapsed)),
... | code_fim | hard | {
"lang": "rust",
"repo": "ymgyt/kvsd",
"path": "/src/protocol/connection/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = {
let dir = dir.as_ref();
let name = name.as_ref();
let toml_path = dir.join(format!("{}.toml", name));
let path = dir.join(name);
check_path(name, &toml_path)
.or_else(|| check_path(name, &path))
... | code_fim | hard | {
"lang": "rust",
"repo": "BrainiumLLC/cargo-mobile",
"path": "/src/templating/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BrainiumLLC/cargo-mobile path: /src/templating/mod.rs
mod fancy;
mod filter;
mod init;
pub use self::{fancy::*, filter::*, init::*};
use crate::util::{self, Git};
use std::{
fmt::{self, Display},
fs, io,
path::{Path, PathBuf},
};
// These packs only show in builds using the braini... | code_fim | hard | {
"lang": "rust",
"repo": "BrainiumLLC/cargo-mobile",
"path": "/src/templating/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: realtiger/zmq.rs path: /tests/req_rep.rs
use zeromq::prelude::*;
use zeromq::RepSocket;
use zeromq::__async_rt as async_rt;
use futures::StreamExt;
use std::convert::TryInto;
use std::error::Error;
use std::time::Duration;
async fn run_rep_server(mut rep_socket: RepSocket) -> Result<(), Box<dy... | code_fim | hard | {
"lang": "rust",
"repo": "realtiger/zmq.rs",
"path": "/tests/req_rep.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..10i32 {
req_socket.send(format!("Req - {}", i).into()).await?;
let repl: String = req_socket.recv().await?.try_into()?;
assert_eq!(format!("Req - {} Rep - {}", i, i), repl)
}
req_socket.close().await;
let events: Vec<_> = monitor.collect().await;
ass... | code_fim | hard | {
"lang": "rust",
"repo": "realtiger/zmq.rs",
"path": "/tests/req_rep.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..100i32 {
let cloned_endpoint = endpoint.to_string();
async_rt::task::spawn(async move {
// yield for a moment to ensure that server has some time to open socket
async_rt::task::sleep(Duration::from_millis(100)).await;
let mut req_socket =... | code_fim | hard | {
"lang": "rust",
"repo": "realtiger/zmq.rs",
"path": "/tests/req_rep.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MilanLoveless/couchbase-rs path: /couchbase/src/api/mod.rs
ster = Cluster::connect("127.0.0.1", "username", "password");
/// let result = cluster.query("select * from bucket", QueryOptions::default());
/// ```
///
/// This will return an async result, which can be consumed:
/... | code_fim | hard | {
"lang": "rust",
"repo": "MilanLoveless/couchbase-rs",
"path": "/couchbase/src/api/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (sender, receiver) = oneshot::channel();
self.core.send(Request::Mutate(MutateRequest {
id: id.into(),
content: serialized,
sender,
bucket: self.bucket_name.clone(),
ty,
scope: self.scope_name.clone(),
... | code_fim | hard | {
"lang": "rust",
"repo": "MilanLoveless/couchbase-rs",
"path": "/couchbase/src/api/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MilanLoveless/couchbase-rs path: /couchbase/src/api/mod.rs
},
/// Err(e) => panic!("Query failed: {:?}", e),
/// }
/// ```
/// See the [SearchResult](struct.SearchResult.html) for more information on what and how it can be consumed.
pub async fn search_query<S: Into<Strin... | code_fim | hard | {
"lang": "rust",
"repo": "MilanLoveless/couchbase-rs",
"path": "/couchbase/src/api/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn push<'a>(&self, line: &mut String, map: &mut BTreeMap<&str, &'a str>, s: &'a str) {
map.insert("full_text", s);
let json = serde_json::to_string(&map).unwrap();
line.push_str(json.as_ref());
line.push_str(",");
}
fn build<'a>(&self, line: &mut String, map: &... | code_fim | hard | {
"lang": "rust",
"repo": "Ploppz/unixbar",
"path": "/src/format/i3bar.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ploppz/unixbar path: /src/format/i3bar.rs
use super::data::*;
use std::collections::BTreeMap;
use serde_json;
pub struct I3BarFormatter;
impl Formatter for I3BarFormatter {
fn format(&self, data: &Format) -> String {
self.format_all(&[data.clone()])
}
<|fim_suffix|>impl I3BarF... | code_fim | hard | {
"lang": "rust",
"repo": "Ploppz/unixbar",
"path": "/src/format/i3bar.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::color::Color;
mod color;
pub use self::material::Material;
mod material;
pub use self::scene_object::SceneObject;
mod scene_object;
pub use self::lights::{Light, DirectionalLight, PointLight};
mod lights;<|fim_prefix|>// repo: DerLando/rust_ray path: /src/scene/mod.rs
pub use self::camer... | code_fim | medium | {
"lang": "rust",
"repo": "DerLando/rust_ray",
"path": "/src/scene/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DerLando/rust_ray path: /src/scene/mod.rs
pub use self::camera::Camera;
mod camera;
pub use self::transformation::Transformation;
mod transformation;
pub use self::transformation::Transformable;
pub use self::renderer::Renderer;
mod renderer;
<|fim_suffix|>pub use self::color::Color;
mod col... | code_fim | easy | {
"lang": "rust",
"repo": "DerLando/rust_ray",
"path": "/src/scene/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::lights::{Light, DirectionalLight, PointLight};
mod lights;<|fim_prefix|>// repo: DerLando/rust_ray path: /src/scene/mod.rs
pub use self::camera::Camera;
mod camera;
pub use self::transformation::Transformation;
mod transformation;
<|fim_middle|>pub use self::transformation::Transformable;... | code_fim | hard | {
"lang": "rust",
"repo": "DerLando/rust_ray",
"path": "/src/scene/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likewhatevs/rust-socketio path: /src/engineio/socket.rs
#![allow(unused)]
use std::thread;
use super::packet::{Packet, PacketId};
use crate::engineio::transport::TransportClient;
use crate::error::{Error, Result};
use bytes::Bytes;
use log::error;
use std::sync::{
atomic::{AtomicBool, Order... | code_fim | hard | {
"lang": "rust",
"repo": "likewhatevs/rust-socketio",
"path": "/src/engineio/socket.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Sends a socketio binary attachement to the server.
pub fn emit_binary_attachement(&mut self, attachement: Bytes) -> Result<()> {
if !self.serving.load(Ordering::Relaxed) {
return Err(Error::ActionBeforeOpen);
}
let packet = Packet::new(PacketId::Message, att... | code_fim | hard | {
"lang": "rust",
"repo": "likewhatevs/rust-socketio",
"path": "/src/engineio/socket.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut socket = EngineSocket::new(true);
assert!(socket
.on_open(|_| {
println!("Open event!");
})
.is_ok());
assert!(socket
.on_close(|_| {
println!("Close event!");
})
.is_o... | code_fim | hard | {
"lang": "rust",
"repo": "likewhatevs/rust-socketio",
"path": "/src/engineio/socket.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.get_mut().as_mut().cancel_write(wait)
}
}
impl<T> AsyncWrite for &mut T
where
T: AsyncWrite + Unpin + ?Sized,
{
unsafe fn poll_write(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &IoSlice<'_>,
) -> Poll<io::Result<usize>> {
Pin::new(&mu... | code_fim | hard | {
"lang": "rust",
"repo": "raftario/wae",
"path": "/src/io/write/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raftario/wae path: /src/io/write/mod.rs
#[cfg(feature = "io-ext")]
mod ext;
#[cfg(feature = "io-ext")]
pub use ext::*;
use std::{
fmt, io,
marker::PhantomData,
mem,
ops::{Deref, DerefMut},
pin::Pin,
slice,
task::{Context, Poll},
};
use winapi::shared::ws2def::WSABUF;... | code_fim | hard | {
"lang": "rust",
"repo": "raftario/wae",
"path": "/src/io/write/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe impl Send for IoSlice<'_> {}
unsafe impl Sync for IoSlice<'_> {}
impl IoSlice<'_> {
pub fn as_wsabuf(&self) -> &WSABUF {
unsafe { &*(self as *const Self as *const WSABUF) }
}
}
impl<'a> From<&'a [u8]> for IoSlice<'a> {
fn from(buf: &'a [u8]) -> Self {
Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "raftario/wae",
"path": "/src/io/write/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emgyrz/snake.rs path: /game/src/view/sprites.rs
use opengl_graphics::{Texture, TextureSettings};
use snake_ctrl::{Direction, SnakeCornerVariant};
use sprite::Sprite;
use std::rc::Rc;
static STEP: f64 = 64.0;
pub struct Sprites {
// texture: Rc<Texture>,
apple: Sprite<Texture>,
head_top: ... | code_fim | hard | {
"lang": "rust",
"repo": "emgyrz/snake.rs",
"path": "/game/src/view/sprites.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn body(&self, is_vertical: bool) -> &Sprite<Texture> {
if is_vertical {
&self.body_vert
} else {
&self.body_hor
}
}
pub fn corner(&self, variant: SnakeCornerVariant) -> &Sprite<Texture> {
match variant {
SnakeCornerVariant::TopLeft => &self.corner_top_left,
... | code_fim | hard | {
"lang": "rust",
"repo": "emgyrz/snake.rs",
"path": "/game/src/view/sprites.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: diesel-rs/diesel path: /diesel_compile_tests/tests/fail/distinct_on_requires_matching_order_clause.rs
extern crate diesel;
use diesel::*;
table! {
users {
id -> Integer,
name -> Text,
hair_color -> Nullable<Text>,
}
}
fn main() {
// verify that we could us... | code_fim | hard | {
"lang": "rust",
"repo": "diesel-rs/diesel",
"path": "/diesel_compile_tests/tests/fail/distinct_on_requires_matching_order_clause.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // it's not possible to set an invalid order clause after we set
// for multiple order by and distinct on
let _ = users::table
.order_by((users::id, users::name))
.distinct_on((users::name, users::id))
.into_boxed();
// it's not possible to set an invalid order cla... | code_fim | hard | {
"lang": "rust",
"repo": "diesel-rs/diesel",
"path": "/diesel_compile_tests/tests/fail/distinct_on_requires_matching_order_clause.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let owner_account = storage
.get(diem_global_constants::OWNER_ACCOUNT)
.unwrap()
.value;
let mut sr_test = diem_config::config::SafetyRulesTestConfig::new(owner_account);
sr_test.consensus_key(
storage
.export_private_key(diem_global_constants::CONSE... | code_fim | hard | {
"lang": "rust",
"repo": "danhper/diem",
"path": "/config/management/genesis/src/config_builder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danhper/diem path: /config/management/genesis/src/config_builder.rs
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::validator_builder::ValidatorBuilder;
use diem_config::config::NodeConfig;
use diem_crypto::ed25519::Ed25519PrivateKey;
use diem_secur... | code_fim | hard | {
"lang": "rust",
"repo": "danhper/diem",
"path": "/config/management/genesis/src/config_builder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut config = configs.swap_remove(0);
config.set_data_dir(path.path().to_path_buf());
let backend = &config
.validator_network
.as_ref()
.unwrap()
.identity_from_storage()
.backend;
let storage: Storage = std::convert::TryFrom::try_from(backend).u... | code_fim | hard | {
"lang": "rust",
"repo": "danhper/diem",
"path": "/config/management/genesis/src/config_builder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn PyErr_BadArgument() -> c_int;
pub fn PyErr_NoMemory() -> *mut PyObject;
pub fn PyErr_SetFromErrno(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyErr_SetFromErrnoWithFilenameObject(
arg1: *mut PyObject,
arg2: *mut PyObject,
) -> *mut PyObject;
pub fn PyErr_Se... | code_fim | hard | {
"lang": "rust",
"repo": "dgrunwald/rust-cpython",
"path": "/python27-sys/src/pyerrors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgrunwald/rust-cpython path: /python27-sys/src/pyerrors.rs
use libc::{c_char, c_int};
use crate::classobject::*;
use crate::object::*;
use crate::pyport::Py_ssize_t;
use crate::stringobject::PyString_AS_STRING;
#[cfg(py_sys_config = "Py_USING_UNICODE")]
use crate::unicodeobject::Py_UNICODE;
#[... | code_fim | hard | {
"lang": "rust",
"repo": "dgrunwald/rust-cpython",
"path": "/python27-sys/src/pyerrors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kilork/rustorrent path: /service/src/types/mod.rs
#[macro_use]
mod bencode;
mod configuration;
mod handshake;
pub mod info;
mod message;
mod message_codec;
mod message_codec_error;
mod peer;
pub mod public;
mod torrent;
mod tracker_announce;
pub(crate) mod udp_tracker;
<|fim_suffix|>pub(crate) ... | code_fim | hard | {
"lang": "rust",
"repo": "kilork/rustorrent",
"path": "/service/src/types/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) const HANDSHAKE_PREFIX: [u8; 28] =
*b"\x13BitTorrent protocol\x00\x00\x00\x00\x00\x00\x00\x00";<|fim_prefix|>// repo: kilork/rustorrent path: /service/src/types/mod.rs
#[macro_use]
mod bencode;
mod configuration;
mod handshake;
pub mod info;
mod message;
mod message_codec;
mod message_code... | code_fim | hard | {
"lang": "rust",
"repo": "kilork/rustorrent",
"path": "/service/src/types/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l4/src/stm32l4r9/dfsdm1/dfsdm_flt1cnvtimr.rs
#[doc = "Register `DFSDM_FLT1CNVTIMR` reader"]
pub type R = crate::R<DFSDM_FLT1CNVTIMR_SPEC>;
#[doc = "Field `CNVCNT` reader - 28-bit timer counting conversion time t = CNVCNT\\[27:0\\]
/ fDFSDM_CKIN"]
pub type ... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l4/src/stm32l4r9/dfsdm1/dfsdm_flt1cnvtimr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>)` method returns [`dfsdm_flt1cnvtimr::R`](R) reader structure"]
impl crate::Readable for DFSDM_FLT1CNVTIMR_SPEC {}
#[doc = "`reset()` method sets DFSDM_FLT1CNVTIMR to value 0"]
impl crate::Resettable for DFSDM_FLT1CNVTIMR_SPEC {
const RESET_VALUE: Self::Ux = 0;
}<|fim_prefix|>// repo: stm32-rs/stm32-... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l4/src/stm32l4r9/dfsdm1/dfsdm_flt1cnvtimr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmshvetsov/adventofcode path: /2022/01/2.rs
use std::fs;
/// return top 3 sum of numbers in blocks of lines separated by a blank line
fn solution(input: String) -> i32 {
const LINE_BREAK: &str = "";
let mut res = (0, 0, 0);
let mut acc = 0;
for line_item in input.split("\n") {
... | code_fim | medium | {
"lang": "rust",
"repo": "dmshvetsov/adventofcode",
"path": "/2022/01/2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = fs::read_to_string("./01/input")
.expect("Should have been able to read the 01/input file");
let res1 = solution(input);
println!("01/1 solution: {res1}"); // expected 200116
}<|fim_prefix|>// repo: dmshvetsov/adventofcode path: /2022/01/2.rs
use std::fs;
/// return top 3... | code_fim | hard | {
"lang": "rust",
"repo": "dmshvetsov/adventofcode",
"path": "/2022/01/2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>EM_BROKER_META_VERSION: &str = "mem-broker-0.2";<|fim_prefix|>// repo: doyoubi/undermoon path: /src/common/version.rs
pub const UNDERMOON_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const UNDERMOON_MIGRATION_V<|fim_middle|>ERSION: &str = "mgr-0.2";
pub const UNDERMOON_M | code_fim | easy | {
"lang": "rust",
"repo": "doyoubi/undermoon",
"path": "/src/common/version.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doyoubi/undermoon path: /src/common/version.rs
pub const UNDERMOON_VERSION: &str = env!("CARGO<|fim_suffix|>EM_BROKER_META_VERSION: &str = "mem-broker-0.2";<|fim_middle|>_PKG_VERSION");
pub const UNDERMOON_MIGRATION_VERSION: &str = "mgr-0.2";
pub const UNDERMOON_M | code_fim | medium | {
"lang": "rust",
"repo": "doyoubi/undermoon",
"path": "/src/common/version.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let projection = {
let (width, height) = frame.get_dimensions();
let r: f32 = width as f32 / 2.0;
let t: f32 = height as f32 / 2.0;
let n: f32 = 128.0;
let f: f32 = -128.0;
[
[1.0f32 / r, 0.0, 0.0, 0.0],
... | code_fim | hard | {
"lang": "rust",
"repo": "Maxjen/inferno",
"path": "/src/rendering/sprite_triangle_batch.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Maxjen/inferno path: /src/rendering/sprite_triangle_batch.rs
use glium;
use super::vertex::SpriteVertex;
use ::resources::TextureAtlas;
use std::rc::Rc;
use std::cell::RefCell;
pub struct SpriteTriangleBatch<'a> {
display: &'a glium::backend::glutin_backend::GlutinFacade,
pub atlas: Rc<... | code_fim | hard | {
"lang": "rust",
"repo": "Maxjen/inferno",
"path": "/src/rendering/sprite_triangle_batch.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn create_buffers(&mut self) {
self.vertex_buffer = Some(glium::VertexBuffer::new(self.display, &self.vertices).unwrap());
self.index_buffer = Some(glium::IndexBuffer::new(self.display, glium::index::PrimitiveType::TrianglesList, &self.indices).unwrap());
}
pub fn draw(&se... | code_fim | hard | {
"lang": "rust",
"repo": "Maxjen/inferno",
"path": "/src/rendering/sprite_triangle_batch.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: UsairimIsani/teaching-rs path: /src/bin/sha.rs
use std::fs;
use std::io::prelude::*;
use std::path::Path;
fn main() {
let file_path = Path::new("./read.txt");
let mut file = match fs::File::open(file_path) {
Ok(file) => file,
Err(e) => panic!("Unable to open the file {}:... | code_fim | hard | {
"lang": "rust",
"repo": "UsairimIsani/teaching-rs",
"path": "/src/bin/sha.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(_) => println!(
"\nSuccessfully wrote reversed contents to file {}: \n{}",
out_path.display(),
reversed
),
Err(e) => println!("Unable to write contents on {}: {}", out_path.display(), e),
}
}<|fim_prefix|>// repo: UsairimIsani/teaching-rs pa... | code_fim | hard | {
"lang": "rust",
"repo": "UsairimIsani/teaching-rs",
"path": "/src/bin/sha.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lincolnq/advent-2018 path: /src/advent3_claim_grid.rs
use nom::{digit, multispace0, multispace1};
use std::str::FromStr;
use std::num::ParseIntError;
use ndarray::Array2;
#[derive(Debug,PartialEq)]
pub struct Claim {
pub id: i32,
pub x: i32,
pub y: i32,
pub w: i32,
pub h: i3... | code_fim | hard | {
"lang": "rust",
"repo": "lincolnq/advent-2018",
"path": "/src/advent3_claim_grid.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut slice = b.slice_mut(s![c.x..c.x+c.w, c.y..c.y+c.h]);
slice.mapv_inplace(|v|
if v == 0 {
// no conflict
c.id
} else {
// conflict, return -1
-1
}
)
}
fn check_claim(b: &Board, c: &Claim) -> bool {
let slice = ... | code_fim | hard | {
"lang": "rust",
"repo": "lincolnq/advent-2018",
"path": "/src/advent3_claim_grid.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn point_at_dist(&self, dist: f64) -> Vec3
{
self.origin + self.dir * dist
}
pub fn reflect_at(&self, dist: f64, normal: Vec3) -> Ray
{
Ray {
origin: self.point_at_dist(dist),
dir: self.dir.reflect(normal),
}
}
}<|fim_prefix|>// ... | code_fim | medium | {
"lang": "rust",
"repo": "AndreasOlofsson/raytracer",
"path": "/src/ray.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndreasOlofsson/raytracer path: /src/ray.rs
use crate::math::Vec3;
#[derive(Debug, Clone, Copy)]
pub struct Ray
{
pub origin: Vec3,
pub dir: Vec3,
}
<|fim_suffix|> pub fn reflect_at(&self, dist: f64, normal: Vec3) -> Ray
{
Ray {
origin: self.point_at_dist(dis... | code_fim | hard | {
"lang": "rust",
"repo": "AndreasOlofsson/raytracer",
"path": "/src/ray.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
const INTERFACE_WITH_TEMPLATE_METHODS: &'static str = r#"
struct Foo {
template <typename T> void foo(T bar);
};
"#;
let model = create_model(INTERFACE_WITH_TEMPLATE_METHODS);
assert_eq!(model.interfaces[0]
... | code_fim | hard | {
"lang": "rust",
"repo": "zachChilders/cpp-codegen-rs",
"path": "/src/parser_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let model = create_model(INTERFACE_WITH_NAMELESS_ARGUMENT_METHODS);
assert!(serde_json::ser::to_string(&model.interfaces[0].methods[0].arguments[0].name)
.unwrap()
.len() > 0)
}
#[test]
fn should_parse_template_methods() {
const INTERFACE_WITH_... | code_fim | hard | {
"lang": "rust",
"repo": "zachChilders/cpp-codegen-rs",
"path": "/src/parser_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zachChilders/cpp-codegen-rs path: /src/parser_tests.rs
#[cfg(test)]
mod tests {
use model::{Model, TemplateParameter};
use std::fs::File;
use std::io::Write;
use clang::{Clang, Index};
use tempdir::TempDir;
use serde_json;
use std::fmt::Debug;
use response_file... | code_fim | hard | {
"lang": "rust",
"repo": "zachChilders/cpp-codegen-rs",
"path": "/src/parser_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adam-mcdaniel/oakc path: /src/lib.rs
#![allow(warnings, clippy, unknown_lints)]
use std::{
collections::BTreeMap,
env::consts::{FAMILY, OS},
fmt::Display,
io::Result,
path::PathBuf,
process::exit,
};
pub type Identifier = String;
pub type StringLiteral = String;
pub mod ... | code_fim | hard | {
"lang": "rust",
"repo": "adam-mcdaniel/oakc",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Get the column number from the location
let mut column = {
let mut current_column = 0;
// For every character in the script until the location of the error,
// keep track of the column location
for ch in script[..location].chars() {
if ch == '\n' {
... | code_fim | hard | {
"lang": "rust",
"repo": "adam-mcdaniel/oakc",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: charliejeynes/arc path: /src/file/io/load.rs
//! Load trait.
use json5;
use serde::Deserialize;
use std::{collections::BTreeMap, fs::read_to_string, path::Path};
<|fim_suffix|>}
/// Deserialise the type in json format.
#[inline]
#[must_use]
pub fn from_json<T>(path: &Path) -> T
where
for<... | code_fim | medium | {
"lang": "rust",
"repo": "charliejeynes/arc",
"path": "/src/file/io/load.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Deserialise the type in json format.
#[inline]
#[must_use]
pub fn from_json<T>(path: &Path) -> T
where
for<'de> T: Deserialize<'de>,
{
json5::from_str(
&read_to_string(path).unwrap_or_else(|_| panic!("Unable to read file: {}", path.display())),
)
.expect("Unable to parse json f... | code_fim | medium | {
"lang": "rust",
"repo": "charliejeynes/arc",
"path": "/src/file/io/load.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeffparsons/planetkit path: /planetkit/src/globe/icosahedron.rs
// Golden ratio
#[allow(clippy::unreadable_literal, clippy::excessive_precision)]
const PHI: f64 = 1.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475;
<|fim_suffix|>// Vertice... | code_fim | hard | {
"lang": "rust",
"repo": "jeffparsons/planetkit",
"path": "/planetkit/src/globe/icosahedron.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> [ 0, 5, 9 ],
[ 10, 9, 5 ],
[ 9, 10, 6 ],
[ 2, 6, 10 ],
[ 0, 9, 1 ],
[ 6, 1, 9 ],
[ 1, 6, 7 ],
[ 2, 7, 6 ],
];<|fim_prefix|>// repo: jeffparsons/planetkit path: /planetkit/src/globe/icosahedron.rs
// Golden ratio
#[allow(clippy::unreadable_literal, cli... | code_fim | hard | {
"lang": "rust",
"repo": "jeffparsons/planetkit",
"path": "/planetkit/src/globe/icosahedron.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: silvia-odwyer/gdl path: /crate/src/bin/bin.rs
use gdl::text::*;
use gdl::{new_with_background, presets, Rgb};
use std::time::Instant;
// See the examples dir for more examples
fn main() {
// GRAPHIC 1
let start = Instant::now();
let yellow = Rgb {
r: 255,
g: 226,
... | code_fim | medium | {
"lang": "rust",
"repo": "silvia-odwyer/gdl",
"path": "/crate/src/bin/bin.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> draw_text(&mut alleyway, "Visit", 230, 270, "BebasKai", 140.0, &white);
draw_text(
&mut alleyway,
"Stockholm",
230,
390,
"BebasKai",
140.0,
&white,
);
gdl::helpers::save_image(alleyway, "output_graphic2.png");
println!(
... | code_fim | hard | {
"lang": "rust",
"repo": "silvia-odwyer/gdl",
"path": "/crate/src/bin/bin.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nilsso/ray-tracing-rs path: /src/color.rs
//! Basic color printing utility.
use std::fmt::{Display, Formatter};
use crate::vector::Vec3;
pub struct Color {
pub r: u32,
pub g: u32,
pub b: u32,
}
impl Color {
pub const BLACK: Color = Color { r: 0, g: 0, b: 0 };
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "nilsso/ray-tracing-rs",
"path": "/src/color.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Display for Color {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{} {} {}", self.r, self.g, self.b)
}
}
impl From<Vec3> for Color {
fn from(other: Vec3) -> Self {
Self::new(
other.x,
other.y,
other.z,
)
... | code_fim | hard | {
"lang": "rust",
"repo": "nilsso/ray-tracing-rs",
"path": "/src/color.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wgwoods/enarx-keepldr path: /internal/shim-sgx/src/ssa.rs
// SPDX-License-Identifier: Apache-2.0
use core::mem::size_of;
use primordial::{Page, Register};
use xsave::XSave;
pub use x86_64::InterruptVector as Vector;
/// Section 38.9.1.1, Table 38-9
#[repr(C, align(4))]
#[derive(Copy, Clone)]... | code_fim | hard | {
"lang": "rust",
"repo": "wgwoods/enarx-keepldr",
"path": "/internal/shim-sgx/src/ssa.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Section 38.9.2, Table 38-11
#[derive(Debug)]
#[repr(C)]
pub struct Miscellaneous {
/// Exception info for GP or page fault occurring inside an enclave can be written to
/// this struct under some conditions (see Table 38.11).
exinfo: ExceptionInfo,
}
/// When an AEX occurs while running i... | code_fim | hard | {
"lang": "rust",
"repo": "wgwoods/enarx-keepldr",
"path": "/internal/shim-sgx/src/ssa.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> reserved: u32,
}
/// Section 38.9.2, Table 38-11
#[derive(Debug)]
#[repr(C)]
pub struct Miscellaneous {
/// Exception info for GP or page fault occurring inside an enclave can be written to
/// this struct under some conditions (see Table 38.11).
exinfo: ExceptionInfo,
}
/// When an AEX ... | code_fim | hard | {
"lang": "rust",
"repo": "wgwoods/enarx-keepldr",
"path": "/internal/shim-sgx/src/ssa.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result = HashSet::new();
for point in path {
if gcd(point.x as usize, point.y as usize) != 1 {
result.insert(point);
}
}
result
}
#[derive(Hash, PartialEq, Eq)]
struct Fraction {
pub numerator: i32,
pub denominator: i32,
}
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "ThomasZumsteg/cantor_map",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ThomasZumsteg/cantor_map path: /src/main.rs
use cantor::Point;
use std::collections::HashSet;
use std::mem::swap;
use svg::Document;
use svg::node::element::Path;
use svg::node::element::path::Data;
fn gcd(mut a: usize, mut b: usize) -> usize {
if a < b {
swap(&mut a, &mut b);
... | code_fim | hard | {
"lang": "rust",
"repo": "ThomasZumsteg/cantor_map",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result = HashSet::new();
let mut seen = HashSet::new();
for point in path {
let f = Fraction::new(point.x, point.y);
if seen.contains(&f) {
result.insert(point);
}
seen.insert(f);
}
result
}
fn draw_svg(filename: &str, points: &HashS... | code_fim | hard | {
"lang": "rust",
"repo": "ThomasZumsteg/cantor_map",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mut opt: cli::Opt,
is_light_mode: bool,
writer: &mut dyn Write,
stdin: Option<&Vec<u8>>,
) -> std::io::Result<()> {
use bytelines::ByteLines;
use std::io::BufReader;
let input = match stdin {
Some(stdin_data) => &stdin_data[..],
None => {
b"\
diff --... | code_fim | hard | {
"lang": "rust",
"repo": "dandavison/delta",
"path": "/src/subcommands/show_syntax_themes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use std::io::{Cursor, Seek};
use super::*;
use crate::ansi;
use crate::tests::integration_test_utils;
#[test]
#[ignore] // Not working (timing out) when run by tarpaulin, presumably due to stdin detection.
fn test_show_syntax_themes() {
let op... | code_fim | hard | {
"lang": "rust",
"repo": "dandavison/delta",
"path": "/src/subcommands/show_syntax_themes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dandavison/delta path: /src/subcommands/show_syntax_themes.rs
use crate::cli;
use crate::config;
use crate::delta;
use crate::env::DeltaEnv;
use crate::options::theme::is_light_syntax_theme;
use crate::utils;
use crate::utils::bat::output::{OutputType, PagingMode};
use clap::Parser;
use std::io:... | code_fim | hard | {
"lang": "rust",
"repo": "dandavison/delta",
"path": "/src/subcommands/show_syntax_themes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sk3w/amber path: /src/config.rs
use std::{collections::HashMap, path::Path};
use anyhow::*;
use serde::{Deserialize, Serialize};
use sodiumoxide::crypto::hash::sha256::{self, Digest};
use sodiumoxide::{
crypto::{
box_,
box_::{PublicKey, SecretKey},
sealedbox,
},
... | code_fim | hard | {
"lang": "rust",
"repo": "sk3w/amber",
"path": "/src/config.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.