text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let facade = MessageDispatcher::new();
facade.report_news();
facade.report_mail();
facade.report_post();
}
}<|fim_prefix|>// repo: raiote/design-pattern path: /facade/src/lib.rs
pub trait Message: std::fmt::Debug {
fn content(&self) {
println!("This is a {:... | code_fim | hard | {
"lang": "rust",
"repo": "raiote/design-pattern",
"path": "/facade/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cfg.service(web::resource("/redis&key={key}").route(web::get().to(db_request_handlers::redis_get_handler)));
cfg.route("/redis", web::post().to(db_request_handlers::redis_post_handler));
cfg.route("/apitest", web::get().to(api_requests::api_request));
cfg.service(web::resource("/spotify&to... | code_fim | hard | {
"lang": "rust",
"repo": "alexm622/Rust-REST-API",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
SimpleLogger::new()
.with_level(LevelFilter::Off)
.with_module_level("rest", LevelFilter::Info)
.with_module_level("actix", LevelFilter::Info)
.init()
.unwrap();
HttpServer::new(|| {
App::new()
.configure(general_routes)
})
.workers(20)
... | code_fim | hard | {
"lang": "rust",
"repo": "alexm622/Rust-REST-API",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexm622/Rust-REST-API path: /src/main.rs
use actix_web::{ App, HttpServer, web, HttpResponse, Responder};
use serde::{Serialize, Deserialize};
extern crate simple_logger;
use simple_logger::{SimpleLogger};
use log::LevelFilter;
pub mod rest_server{
pub mod db_tools;
pub mod http_req... | code_fim | hard | {
"lang": "rust",
"repo": "alexm622/Rust-REST-API",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if input_map.just_active(EditorAction::Keys) {
action_window.enabled = !action_window.enabled;
}
}
// first frame after 'Loading', we set state to 'Playing'
fn loaded(mut state: ResMut<State<EditorState>>) {
if state.current().eq(&EditorState::Loading) {
state
.set... | code_fim | hard | {
"lang": "rust",
"repo": "slyedoc/bevy_slyedoc_template",
"path": "/src/editor/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
EditorAction::Editor => write!(f, "Toggle Editor"),
EditorAction::World => write!(f, "Open World Inspector"),
EditorAction::Keys => write!(f, "Toggle Key Mappings"),
}
}
}
fn setup(mut input_map: ResMut<InputMap<EditorAction>>) {
in... | code_fim | hard | {
"lang": "rust",
"repo": "slyedoc/bevy_slyedoc_template",
"path": "/src/editor/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slyedoc/bevy_slyedoc_template path: /src/editor/mod.rs
pub mod camera;
pub mod grid;
pub mod ui;
use bevy::{ecs::schedule::ShouldRun, prelude::*};
use bevy_input_actionmap::{ActionPlugin, InputMap};
use bevy_inspector_egui::{WorldInspectorParams, WorldInspectorPlugin};
use std::fmt;
pub use cam... | code_fim | hard | {
"lang": "rust",
"repo": "slyedoc/bevy_slyedoc_template",
"path": "/src/editor/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut game_state = GameState::new(args.flag_difficulty.unwrap_or(5));
let window = window::create();
let mut last_time = PreciseTime::now();
while game_state.is_playing {
let elapsed = last_time.to(PreciseTime::now());
let event = window.handle_input(&mut game_state);
... | code_fim | hard | {
"lang": "rust",
"repo": "wellborns/robco-term",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wellborns/robco-term path: /src/main.rs
#[macro_use]
extern crate log;
extern crate docopt;
extern crate itertools;
extern crate log4rs;
extern crate ncurses;
extern crate rand;
extern crate rustc_serialize;
extern crate time;
mod game;
mod window;
mod consts;
use docopt::Docopt;
use time::Pre... | code_fim | hard | {
"lang": "rust",
"repo": "wellborns/robco-term",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub points: i32,
pub outcome: bool,
}<|fim_prefix|>// repo: rlee570/predictions_backend path: /src/models/vote.rs
#[derive(Queryable, Serialize, Debug)]
pu<|fim_middle|>b struct Vote {
pub id: i32,
pub prediction: i32,
pub user_id: i32,
| code_fim | medium | {
"lang": "rust",
"repo": "rlee570/predictions_backend",
"path": "/src/models/vote.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rlee570/predictions_backend path: /src/models/vote.rs
#[derive(Queryable, Serialize, Debug)]
pu<|fim_suffix|> pub points: i32,
pub outcome: bool,
}<|fim_middle|>b struct Vote {
pub id: i32,
pub prediction: i32,
pub user_id: i32,
| code_fim | medium | {
"lang": "rust",
"repo": "rlee570/predictions_backend",
"path": "/src/models/vote.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abusch/rustracer path: /rustracer-core/src/filter/mitchell.rs
use crate::filter::Filter;
use crate::paramset::ParamSet;
pub struct MitchellNetravali {
width: f32,
height: f32,
inv_width: f32,
inv_height: f32,
b: f32,
c: f32,
}
impl MitchellNetravali {
pub fn new(w: ... | code_fim | hard | {
"lang": "rust",
"repo": "abusch/rustracer",
"path": "/rustracer-core/src/filter/mitchell.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (self.width, self.height)
}
fn inv_width(&self) -> (f32, f32) {
(self.inv_width, self.inv_height)
}
}
impl Default for MitchellNetravali {
fn default() -> Self {
MitchellNetravali::new(2.0, 2.0, 1.0 / 3.0, 1.0 / 3.0)
}
}<|fim_prefix|>// repo: abusch/rustracer ... | code_fim | hard | {
"lang": "rust",
"repo": "abusch/rustracer",
"path": "/rustracer-core/src/filter/mitchell.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, Copy, Component)]
pub struct LastRepelTime(pub Instant);
#[derive(Clone, Debug, Copy, Component)]
pub struct LastRespawnTime(pub Instant);
#[derive(Clone, Debug, Copy, Component)]
pub struct LastScoreBoardTime(pub Instant);
macro_rules! impl_default {
{
$( $name:ident, )*
} =... | code_fim | hard | {
"lang": "rust",
"repo": "airmash-refugees/airmash-server-eu",
"path": "/server/src/component/time.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: airmash-refugees/airmash-server-eu path: /server/src/component/time.rs
use specs::*;
use std::time::Instant;
#[derive(Clone, Debug, Copy)]
pub struct LastFrame(pub Instant);
#[derive(Clone, Debug, Copy)]
pub struct ThisFrame(pub Instant);
#[derive(Clone, Debug, Copy)]
pub struct StartTime(pub... | code_fim | hard | {
"lang": "rust",
"repo": "airmash-refugees/airmash-server-eu",
"path": "/server/src/component/time.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: haraldh/chainerror path: /examples/tutorial6.rs
#![allow(clippy::single_match)]
#![allow(clippy::redundant_pattern_matching)]
use chainerror::Context as _;
use std::error::Error;
use std::io;
fn do_some_io() -> Result<(), Box<dyn Error + Send + Sync>> {
Err(io::Error::from(io::ErrorKind::... | code_fim | medium | {
"lang": "rust",
"repo": "haraldh/chainerror",
"path": "/examples/tutorial6.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(e) = func1() {
eprintln!("Error: {}", e);
let mut s: &(dyn Error) = e.as_ref();
while let Some(c) = s.source() {
if let Some(ioerror) = c.downcast_ref::<io::Error>() {
eprintln!("caused by: std::io::Error: {}", ioerror);
ma... | code_fim | hard | {
"lang": "rust",
"repo": "haraldh/chainerror",
"path": "/examples/tutorial6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hirtol/Rustyboi path: /sdl_frontend/src/data/communication.rs
use crate::data::state::DisplayColourConfigurable;
use rustyboi_core::gb_emu::GameBoyModel;
use rustyboi_core::hardware::ppu::debugging_features::PaletteDebugInfo;
use rustyboi_core::InputKey;
<|fim_suffix|>impl Into<EmulatorNotifica... | code_fim | hard | {
"lang": "rust",
"repo": "Hirtol/Rustyboi",
"path": "/sdl_frontend/src/data/communication.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> EmulatorNotification::Debug(self)
}
}
impl Into<EmulatorResponse> for DebugMessage {
fn into(self) -> EmulatorResponse {
EmulatorResponse::Debug(self)
}
}<|fim_prefix|>// repo: Hirtol/Rustyboi path: /sdl_frontend/src/data/communication.rs
use crate::data::state::DisplayColour... | code_fim | hard | {
"lang": "rust",
"repo": "Hirtol/Rustyboi",
"path": "/sdl_frontend/src/data/communication.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> const SIZES: [usize; 6] = [1024, 12_345, 1 << 17, 1 << 25, 1 << 26, 76_543_210];
let mut group = c.benchmark_group("FrequencySketch::reset");
for size in SIZES {
let mut sketch = FrequencySketch::with_capacity(size);
for i in 0..size {
sketch.increment(&i);
... | code_fim | hard | {
"lang": "rust",
"repo": "zRedShift/tinylfu",
"path": "/benches/fastmod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zRedShift/tinylfu path: /benches/fastmod.rs
use ahash::RandomState;
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
use moka_sketch::MokaSketch;
use std::hash::{BuildHasher, Hash};
use tinylfu::sketch::FrequencySketch;
mod moka_sketch;
fn make_hash<Q: Hash ... | code_fim | hard | {
"lang": "rust",
"repo": "zRedShift/tinylfu",
"path": "/benches/fastmod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: topecongiro/openrr path: /openrr-apps/src/lib.rs
mod error;
mod robot_client;
mod robot_c<|fim_suffix|>bot_command::*;
pub use robot_config::*;<|fim_middle|>ommand;
mod robot_config;
pub use error::*;
pub use robot_client::*;
pub use ro | code_fim | medium | {
"lang": "rust",
"repo": "topecongiro/openrr",
"path": "/openrr-apps/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>bot_command::*;
pub use robot_config::*;<|fim_prefix|>// repo: topecongiro/openrr path: /openrr-apps/src/lib.rs
mod error;
mod robot_client;
mod robot_command;
mod robot_config;
pub use error<|fim_middle|>::*;
pub use robot_client::*;
pub use ro | code_fim | easy | {
"lang": "rust",
"repo": "topecongiro/openrr",
"path": "/openrr-apps/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>::*;
pub use robot_client::*;
pub use robot_command::*;
pub use robot_config::*;<|fim_prefix|>// repo: topecongiro/openrr path: /openrr-apps/src/lib.rs
mod error;
mod robot_client;
mod robot_c<|fim_middle|>ommand;
mod robot_config;
pub use error | code_fim | easy | {
"lang": "rust",
"repo": "topecongiro/openrr",
"path": "/openrr-apps/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Write the result of our drawing to the window's frame.
draw.to_frame(app, &frame).unwrap();
}
fn display(vehicle: &Vehicle, draw: &Draw) {
let Vehicle {
position,
velocity,
r,
..
} = vehicle;
// Draw a triangle rotated in the direction of velocity
... | code_fim | hard | {
"lang": "rust",
"repo": "MacTuitui/nannou",
"path": "/nature_of_code/chp_06_agents/6_03_stay_within_walls.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MacTuitui/nannou path: /nature_of_code/chp_06_agents/6_03_stay_within_walls.rs
// The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
// Stay Within Walls
// "Made-up" Steering behavior to stay within walls
// Implements Craig Reynold's autonomous steering behaviors
// One vehicle... | code_fim | hard | {
"lang": "rust",
"repo": "MacTuitui/nannou",
"path": "/nature_of_code/chp_06_agents/6_03_stay_within_walls.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.is_dirty
}
fn is_dirty_mut(&mut self) -> &mut bool {
&mut self.is_dirty
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn header_page_test() {
let mut header_page = HeaderPage::new();
assert_eq!(0, header_page.record_count());
ass... | code_fim | hard | {
"lang": "rust",
"repo": "pourplusquoi/db-rust",
"path": "/src/page/header_page.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pourplusquoi/db-rust path: /src/page/header_page.rs
// Database use the first page (page_id = 1) as header page to store metadata, in
// our case, we will contain information about table/index name (length less than
// 32 bytes) and their corresponding root_id
//
// Format (size in byte):
// --... | code_fim | hard | {
"lang": "rust",
"repo": "pourplusquoi/db-rust",
"path": "/src/page/header_page.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn header_page_test() {
let mut header_page = HeaderPage::new();
assert_eq!(0, header_page.record_count());
assert!(header_page.root_id("Table A").is_err());
assert!(header_page.insert_record("Table A", 12).is_ok());
assert!(header_page.insert_recor... | code_fim | hard | {
"lang": "rust",
"repo": "pourplusquoi/db-rust",
"path": "/src/page/header_page.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.output = match gather_process_stdout(cmd, "Build crate or workspace", parent_job_id) {
Ok(output) => output,
Err(err) => return err.to_string().into(),
};
CompletionStatus::Ok
}
}<|fim_prefix|>// repo: PhilipDaniels/rtest path: /rtest_core/src/job... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipDaniels/rtest",
"path": "/rtest_core/src/jobs/build_workspace.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PhilipDaniels/rtest path: /rtest_core/src/jobs/build_workspace.rs
use crate::{
configuration::BuildMode,
jobs::{gather_process_stdout, CompletionStatus, JobId, JobKind, PendingJob},
shadow_copy_destination::ShadowCopyDestination,
};
use duct::cmd;
use log::info;
use std::fmt::Display... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipDaniels/rtest",
"path": "/rtest_core/src/jobs/build_workspace.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> kind.into()
}
#[must_use = "Don't ignore the completion status, caller needs to store it"]
pub fn execute(&mut self, parent_job_id: JobId) -> CompletionStatus {
let cwd = self.destination.cwd();
info!(
"{} Building crate or workspace in {}",
par... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipDaniels/rtest",
"path": "/rtest_core/src/jobs/build_workspace.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ~A()
{
if m_p!=null
r_delete<int>m_p
m_p=null
}
void operator=(A& a)
{
this.~A
this.A(a)
}
}
void main()
{
A a
a.m_p[1]=2
a.m_p[1].printl
b=a
b.m_p[1].printl
}<|fim_prefix|>// repo: mm304321141/rush path: /src/example/test/26_2.rs
class A
{
int* m_p
... | code_fim | medium | {
"lang": "rust",
"repo": "mm304321141/rush",
"path": "/src/example/test/26_2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mm304321141/rush path: /src/example/test/26_2.rs
class A
{
int* m_p
A()
{
m_p=r_new<int>5
}
<|fim_suffix|> {
this.~A
this.A(a)
}
}
void main()
{
A a
a.m_p[1]=2
a.m_p[1].printl
b=a
b.m_p[1].printl
}<|fim_middle|> A(A& a)
{
m_p=r_new<int>5
for i... | code_fim | medium | {
"lang": "rust",
"repo": "mm304321141/rush",
"path": "/src/example/test/26_2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = "012345678";
let mut buf = JSBuffer::from(s);
for _ in 0..8 {
assert!(buf.at_octal());
let _ = buf.next_char();
}
assert!(!buf.at_octal());
}
#[test]
fn at_dec_number() {
let s = "0123456789a";
let mut buf... | code_fim | hard | {
"lang": "rust",
"repo": "FreeMasen/RESS",
"path": "/src/tokenizer/buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FreeMasen/RESS path: /src/tokenizer/buffer.rs
use super::unicode::is_other_whitespace;
use std::char;
pub struct JSBuffer<'a> {
pub buffer: &'a [u8],
pub idx: usize,
pub len: usize,
}
/// Re-implementation of
/// the std::str::Chars logic
const CONT_MASK: u8 = 0b0011_1111;
const TAG_... | code_fim | hard | {
"lang": "rust",
"repo": "FreeMasen/RESS",
"path": "/src/tokenizer/buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Check if the next few bytes match the provided bytes
#[inline]
pub fn look_ahead_matches(&self, s: &[u8]) -> bool {
let len = s.len();
let end = self.idx + len;
if end > self.len {
return false;
}
end <= self.len && &self.buffer[self.idx.... | code_fim | hard | {
"lang": "rust",
"repo": "FreeMasen/RESS",
"path": "/src/tokenizer/buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Crates by owner
if let Some(user_id) = user_json["id"].as_u64() {
if let Some(user_json) = crates::get(crates::user_url(user_id)) {
if let Some(array) = user_json["crates"].as_array() {
for thing in ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/chit",
"path": "/src/chit/owners.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/chit path: /src/chit/owners.rs
use colored::*;
use super::crates;
use super::format;
pub fn print_owners(crate_name: String) {
let width = format::get_width();
println!("{} {}...", "Searching for".magenta(), &crate_name.blue());
match crates::get(crates::owners_url(&crate_... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/chit",
"path": "/src/chit/owners.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn set_inner_size_physical(&self, width: u32, height: u32) {
unsafe {
(self.xconn.xlib.XResizeWindow)(
self.xconn.display,
self.xwindow,
width as c_uint,
height as c_uint,
);
self.xco... | code_fim | hard | {
"lang": "rust",
"repo": "Moxinilian/winit",
"path": "/src/platform/linux/x11/window.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Moxinilian/winit path: /src/platform/linux/x11/window.rs
_title(&self, title: &str) {
self.set_title_inner(title)
.flush()
.expect("Failed to set window title");
}
fn set_decorations_inner(&self, decorations: bool) -> util::Flusher {
let wm_hints ... | code_fim | hard | {
"lang": "rust",
"repo": "Moxinilian/winit",
"path": "/src/platform/linux/x11/window.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Moxinilian/winit path: /src/platform/linux/x11/window.rs
on_top).queue();
}
if window_attrs.visible {
unsafe {
// XSetInputFocus generates an error if the window is not visible, so we wait
// until we receive Visibi... | code_fim | hard | {
"lang": "rust",
"repo": "Moxinilian/winit",
"path": "/src/platform/linux/x11/window.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: StoriqaTeam/saga-coordinator path: /src/models/roles.rs
use stq_types::{OrderRole, RoleEntryId, RoleId, StoreId, UserId, WarehouseRole};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct NewRole<Role> {
pub id: RoleId,
pub user_id: UserId,
pub name: Role,
pub data: Opti... | code_fim | hard | {
"lang": "rust",
"repo": "StoriqaTeam/saga-coordinator",
"path": "/src/models/roles.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RoleEntry<Payload> {
pub id: RoleEntryId,
pub user_id: UserId,
pub role: Payload,
}
impl<Payload> RoleEntry<Payload> {
pub fn new(id: RoleEntryId, user_id: UserId, role: Payload) -> Self {
Self { id, user_id, role }
}
... | code_fim | medium | {
"lang": "rust",
"repo": "StoriqaTeam/saga-coordinator",
"path": "/src/models/roles.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let a: [u8; unsafe { C.a }];
let b: [u8; unsafe { C.b }];
}<|fim_prefix|>// repo: avr-rust/rust-legacy-fork path: /src/test/ui/union/union-const-eval.rs
// compile-pass
#![feature(const_fn_union)]
<|fim_middle|>union U {
a: usize,
b: usize,
}
const C: U = U { a: 10 };
| code_fim | medium | {
"lang": "rust",
"repo": "avr-rust/rust-legacy-fork",
"path": "/src/test/ui/union/union-const-eval.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: avr-rust/rust-legacy-fork path: /src/test/ui/union/union-const-eval.rs
// compile-pass
#![feature(const_fn_union)]
<|fim_suffix|> let a: [u8; unsafe { C.a }];
let b: [u8; unsafe { C.b }];
}<|fim_middle|>union U {
a: usize,
b: usize,
}
const C: U = U { a: 10 };
fn main() {
| code_fim | medium | {
"lang": "rust",
"repo": "avr-rust/rust-legacy-fork",
"path": "/src/test/ui/union/union-const-eval.rs",
"mode": "psm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|> let thing = Thing(72);
*thing
};
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/span/issue-24356.rs
// Regression test for #24356
fn main() {
{
use std::ops::Deref;
struct Thing(i8);
/*
// Correct impl
impl De... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/span/issue-24356.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/span/issue-24356.rs
// Regression test for #24356
fn main() {
{
use std::ops::Deref;
struct Thing(i8);
/*
// Correct impl
impl Deref for Thing {
type Target = i8;
fn deref(&s... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/span/issue-24356.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kenchan/competitive_programming path: /atcoder/abc284/src/bin/a.rs
use proconio::input;
fn main() {
<|fim_suffix|> for str in s.into_iter().rev() {
println!("{}", str);
}
}<|fim_middle|> input! {
n: usize,
s: [String; n],
}
| code_fim | medium | {
"lang": "rust",
"repo": "kenchan/competitive_programming",
"path": "/atcoder/abc284/src/bin/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for str in s.into_iter().rev() {
println!("{}", str);
}
}<|fim_prefix|>// repo: kenchan/competitive_programming path: /atcoder/abc284/src/bin/a.rs
use proconio::input;
fn main() {
<|fim_middle|> input! {
n: usize,
s: [String; n],
}
| code_fim | medium | {
"lang": "rust",
"repo": "kenchan/competitive_programming",
"path": "/atcoder/abc284/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mason0510/rust-stratum-v2 path: /stratumv2/src/noise/mod.rs
mod certificate_format;
mod noise_session;
mod signature_noise_message;
mod signed_certificate;
mod types;
pub use certificate_format::CertificateFormat;
pub use noise_session::{new_noise_initiator, new_noise_responder, NoiseSession};
... | code_fim | hard | {
"lang": "rust",
"repo": "mason0510/rust-stratum-v2",
"path": "/stratumv2/src/noise/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // -> e - First half of the handshake
client.send_message(&mut read_buf).unwrap();
server.recv_message(&mut read_buf).unwrap();
// <- e... - Second half of the handshake
server.send_message(&mut read_buf).unwrap();
client.recv_message(&mut read_buf).unwrap(... | code_fim | hard | {
"lang": "rust",
"repo": "mason0510/rust-stratum-v2",
"path": "/stratumv2/src/noise/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaneutt/lumen path: /lumen_runtime/src/otp/erlang/node_0/test.rs
use liblumen_alloc::erts::term::prelude::Atom;
use crate::otp::erlang::node_0::native;
<|fim_suffix|> assert_eq!(native(), Atom::str_to_term("nonode@nohost"))
}<|fim_middle|>#[test]
fn returns_nonode_at_nohost() {
| code_fim | easy | {
"lang": "rust",
"repo": "shaneutt/lumen",
"path": "/lumen_runtime/src/otp/erlang/node_0/test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(native(), Atom::str_to_term("nonode@nohost"))
}<|fim_prefix|>// repo: shaneutt/lumen path: /lumen_runtime/src/otp/erlang/node_0/test.rs
use liblumen_alloc::erts::term::prelude::Atom;
<|fim_middle|>use crate::otp::erlang::node_0::native;
#[test]
fn returns_nonode_at_nohost() {
| code_fim | medium | {
"lang": "rust",
"repo": "shaneutt/lumen",
"path": "/lumen_runtime/src/otp/erlang/node_0/test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (i, j) in self.intervals.iter().zip(&rhs.intervals) {
if !(i.lo == j.lo && i.hi == j.hi) {
return false;
}
}
true
}
}<|fim_prefix|>// repo: eseraygun/rust-honestintervals path: /src/intervalset/impl_cmp.rs
use super::def::IntervalSet... | code_fim | medium | {
"lang": "rust",
"repo": "eseraygun/rust-honestintervals",
"path": "/src/intervalset/impl_cmp.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eseraygun/rust-honestintervals path: /src/intervalset/impl_cmp.rs
use super::def::IntervalSet;
use fp::Float;
<|fim_suffix|> for (i, j) in self.intervals.iter().zip(&rhs.intervals) {
if !(i.lo == j.lo && i.hi == j.hi) {
return false;
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "eseraygun/rust-honestintervals",
"path": "/src/intervalset/impl_cmp.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line_result in handle.lines() {
match line_result {
Ok(line) => {
println!("{}", hash_str(&line));
},
Err(err) => {
eprintln!("Could not read line: {}", err);
std::process::exit(1);
},
}... | code_fim | medium | {
"lang": "rust",
"repo": "cnaj/adventofcode",
"path": "/day10/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cnaj/adventofcode path: /day10/src/main.rs
extern crate day10;
use std::io;
use std::io::BufRead;
use day10::*;
fn main() {
<|fim_suffix|> for line_result in handle.lines() {
match line_result {
Ok(line) => {
println!("{}", hash_str(&line));
... | code_fim | medium | {
"lang": "rust",
"repo": "cnaj/adventofcode",
"path": "/day10/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbStavola/alvin path: /src/display.rs
use sdl2::{
self,
pixels::Color,
rect::Point,
render::Canvas,
video::Window,
};
const BG_COLOR: Color = Color { r: 53, g: 59, b: 115, a: 0xFF };
const FG_COLOR: Color = Color { r: 255, g: 255, b: 41, a: 0xFF };
pub struct Display {
... | code_fim | hard | {
"lang": "rust",
"repo": "mbStavola/alvin",
"path": "/src/display.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return collision;
}
pub fn render(&mut self) {
for i in 0..self.working_screen.len() {
for j in 0..self.working_screen[i].len() {
let color = if self.working_screen[i][j] {
FG_COLOR
} else {
BG_COL... | code_fim | hard | {
"lang": "rust",
"repo": "mbStavola/alvin",
"path": "/src/display.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: R1ckyZhang/trust_me path: /chapter2/borrow.rs
fn main(){
let place1 = "hello";
let place2 = "hello".to_string();
<|fim_suffix|>her
* 同理 后续将place2地址 转移给other
*/
let other = place1;
println!("{:?}",other);
let other = place2;
println!("{:?}",place2);
}<|fim_mid... | code_fim | medium | {
"lang": "rust",
"repo": "R1ckyZhang/trust_me",
"path": "/chapter2/borrow.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ln!("{:?}",other);
let other = place2;
println!("{:?}",place2);
}<|fim_prefix|>// repo: R1ckyZhang/trust_me path: /chapter2/borrow.rs
fn main(){
let place1 = "hello";
let place2 = "hello".to_string();
/**
* 这段程序在编译阶段会报错
* 声明了2个绑定 将place1 赋值给other 将place1内存地址 转给ot<|fim_mid... | code_fim | medium | {
"lang": "rust",
"repo": "R1ckyZhang/trust_me",
"path": "/chapter2/borrow.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BBcan177/FreeBSD-ports path: /lang/rust/files/patch-compiler_rustc__llvm_build.rs
--- compiler/rustc_llvm/build.rs
+++ compiler/rustc_llvm/build.rs
@@ -237,18 +237,20 @@
if !is_crossed {
cmd.arg("--system-libs");
- } else if target.contains("windows-gnu") {
- println!("... | code_fim | hard | {
"lang": "rust",
"repo": "BBcan177/FreeBSD-ports",
"path": "/lang/rust/files/patch-compiler_rustc__llvm_build.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>) {
+ println!("cargo:rustc-link-lib=shell32");
+ println!("cargo:rustc-link-lib=uuid");
+ } else if target.contains("netbsd") || target.contains("haiku") || target.contains("darwin") {
+ println!("cargo:rustc-link-lib=z");
}
cmd.args(&components);<|fim_prefix|>// repo: B... | code_fim | hard | {
"lang": "rust",
"repo": "BBcan177/FreeBSD-ports",
"path": "/lang/rust/files/patch-compiler_rustc__llvm_build.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod day17 {
use super::*;
#[test]
fn test_part_1() {
assert_eq!(4, part_1(&[5, 5, 10, 15, 20], 25));
}
#[test]
fn test_part_2() {
assert_eq!(3, part_2(&[5, 5, 10, 15, 20], 25));
}
}<|fim_prefix|>// repo: DoYouEvenCpp/aoc2015 path: /day17/src/main.... | code_fim | hard | {
"lang": "rust",
"repo": "DoYouEvenCpp/aoc2015",
"path": "/day17/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DoYouEvenCpp/aoc2015 path: /day17/src/main.rs
type DataType = std::collections::HashMap<u32, u32>;
fn knapsack(
data: &[u32],
limit: u32,
current_weight: u32,
count: &mut DataType,
containers_used: u32,
) {
for (idx, _) in data.iter().enumerate() {
let new_weight... | code_fim | medium | {
"lang": "rust",
"repo": "DoYouEvenCpp/aoc2015",
"path": "/day17/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = [
33, 14, 18, 20, 45, 35, 16, 35, 1, 13, 18, 13, 50, 44, 48, 6, 24, 41, 30, 42,
];
println!("part_1: {}", part_1(&input, 150));
println!("part_2: {}", part_2(&input, 150));
}
#[cfg(test)]
mod day17 {
use super::*;
#[test]
fn test_part_1() {
assert_e... | code_fim | medium | {
"lang": "rust",
"repo": "DoYouEvenCpp/aoc2015",
"path": "/day17/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smallstepman/fluency-interview-task path: /pow/src/main.rs
use std::{ops::RangeInclusive, str::FromStr};
use sha3::{Digest, Sha3_256};
use structopt::StructOpt;
#[derive(StructOpt)]
#[structopt(name = "simple_pow")]
struct Opt {
input: HexData,
}
struct HexData(Vec<u8>);
impl FromStr for... | code_fim | hard | {
"lang": "rust",
"repo": "smallstepman/fluency-interview-task",
"path": "/pow/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromStr for HexData {
type Err = hex::FromHexError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
hex::decode(s).map(HexData)
}
}
impl HexData {
fn b64decode(self) -> Result<Vec<u8>, base64::DecodeError> {
base64::decode(self.0)
}
}
struct Prefix(RangeInclus... | code_fim | medium | {
"lang": "rust",
"repo": "smallstepman/fluency-interview-task",
"path": "/pow/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c = Circle { x: 0.0, y: 0.0, radius: 2.0 };
println!("{}", c.area());
}<|fim_prefix|>// repo: standardgalactic/ride path: /data/samples/autoindent-test.rs
namespace {
// before struct
pub struct MyStruct {
member : i32 // member line
} // last struct line
<|fim_middle|> // before ... | code_fim | medium | {
"lang": "rust",
"repo": "standardgalactic/ride",
"path": "/data/samples/autoindent-test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: standardgalactic/ride path: /data/samples/autoindent-test.rs
namespace {
// before struct
pub struct MyStruct {
member : i32 // member line
} // last struct line
// before impl MyStruct
impl MyStruct {} // newline between { and }
// some line
<|fim_suffix|>fn main() {
let c... | code_fim | medium | {
"lang": "rust",
"repo": "standardgalactic/ride",
"path": "/data/samples/autoindent-test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // before impl MyStruct
impl MyStruct {} // newline after }
// some line
}
fn main() {
let c = Circle { x: 0.0, y: 0.0, radius: 2.0 };
println!("{}", c.area());
}<|fim_prefix|>// repo: standardgalactic/ride path: /data/samples/autoindent-test.rs
namespace {
// before struct
pub struct ... | code_fim | medium | {
"lang": "rust",
"repo": "standardgalactic/ride",
"path": "/data/samples/autoindent-test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ftvkyo/succotash path: /src/analyze/mod.rs
//! Subcommand 'analyze' lives here.
//!
//! This module contains the 'analyze' subcommand.
//! Analyze allows finding similar images in a directoy.
use async_std::fs;
use async_std::prelude::*;
pub mod img;
pub mod features;
/// Run the analysis on ... | code_fim | hard | {
"lang": "rust",
"repo": "ftvkyo/succotash",
"path": "/src/analyze/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!(
"img '{}' has hue of {}",
entry.file_name().to_string_lossy(),
img.features.hue
);
}
Ok(())
}
/// Run the analysis on the given path, do not propagate errors.
///
/// You can think of it as of `main` of the `analyze` subcommand.
///
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "ftvkyo/succotash",
"path": "/src/analyze/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut bytes: Vec<u64> = Vec::new();
loop {
let tmp = seq.next_element::<String>();
if let Ok(Some(b)) = tmp {
// TODO: error handling for len
let str_tmp= [hex::decode(&b[0..16]).to_ow... | code_fim | hard | {
"lang": "rust",
"repo": "boltlabs-inc/pairing",
"path": "/src/bn256/serde_impl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boltlabs-inc/pairing path: /src/bn256/serde_impl.rs
use std::fmt;
use std::marker::PhantomData;
use hex;
use super::{Fq, FqRepr, Fr, FrRepr, G1Affine, G2Affine, G1, G2};
use {CurveAffine, CurveProjective, EncodedPoint, PrimeField};
use serde::de::{Error as DeserializeError, SeqAccess, Visitor};... | code_fim | hard | {
"lang": "rust",
"repo": "boltlabs-inc/pairing",
"path": "/src/bn256/serde_impl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Serialize for Fr {
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
self.into_repr().serialize(s)
}
}
impl<'de> Deserialize<'de> for Fr {
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
let fr = FrRepr::deserialize(d)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "boltlabs-inc/pairing",
"path": "/src/bn256/serde_impl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yutiansut/rust-numpy path: /src/npyiter.rs
NPY_ITER_DONT_NEGATE_STRIDES, NPY_ITER_GROWINNER, NPY_ITER_RANGED, NPY_ITER_READONLY,
NPY_ITER_READWRITE, NPY_ITER_REDUCE_OK, NPY_ITER_REFS_OK, NPY_ITER_ZEROSIZE_OK,
};
use crate::sealed::Sealed;
/// Flags for constructing an iterator.
///
///... | code_fim | hard | {
"lang": "rust",
"repo": "yutiansut/rust-numpy",
"path": "/src/npyiter.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'py, T: Element> Default for NpyMultiIterBuilder<'py, T, ()> {
fn default() -> Self {
Self::new()
}
}
impl<'py, T: Element> NpyMultiIterBuilder<'py, T, ()> {
/// Creates a new builder.
pub fn new() -> Self {
Self {
flags: 0,
arrays: Vec::new(),... | code_fim | hard | {
"lang": "rust",
"repo": "yutiansut/rust-numpy",
"path": "/src/npyiter.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yutiansut/rust-numpy path: /src/npyiter.rs
d `ReadOnly` are directly represented
/// by the iterators types provided here.
///
/// [iterator]: https://numpy.org/doc/stable/reference/c-api/iterator.html#c.NpyIter_MultiNew
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum NpyIterFlag {
Com... | code_fim | hard | {
"lang": "rust",
"repo": "yutiansut/rust-numpy",
"path": "/src/npyiter.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sugyan/atcoder path: /abc121/src/bin/d.rs
use proconio::{fastout, input};
<|fim_suffix|> input! {
mut a: i64, b: i64,
}
let f = |n: i64| (n + 1) >> 1 & 1 ^ if n & 1 > 0 { 0 } else { n };
println!("{}", f(b) ^ f(a - 1));
}<|fim_middle|>#[fastout]
fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "sugyan/atcoder",
"path": "/abc121/src/bin/d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
mut a: i64, b: i64,
}
let f = |n: i64| (n + 1) >> 1 & 1 ^ if n & 1 > 0 { 0 } else { n };
println!("{}", f(b) ^ f(a - 1));
}<|fim_prefix|>// repo: sugyan/atcoder path: /abc121/src/bin/d.rs
use proconio::{fastout, input};
<|fim_middle|>#[fastout]
fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "sugyan/atcoder",
"path": "/abc121/src/bin/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>1 << 6;
pub const NOTIFYING: usize = 1 << 7;
pub const REFERENCE: usize = 1 << 8;<|fim_prefix|>// repo: nephele-rs/cynthia path: /cynthia/src/runtime/task/state.rs
pub const SCHEDULED: usize = 1 << 0;
pub const RUNNING: usize = 1 << 1;
pub const COMPLETED: usize = 1 << 2;
pub const CLOSED: usize = 1 << 3... | code_fim | medium | {
"lang": "rust",
"repo": "nephele-rs/cynthia",
"path": "/cynthia/src/runtime/task/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>size = 1 << 4;
pub const AWAITER: usize = 1 << 5;
pub const REGISTERING: usize = 1 << 6;
pub const NOTIFYING: usize = 1 << 7;
pub const REFERENCE: usize = 1 << 8;<|fim_prefix|>// repo: nephele-rs/cynthia path: /cynthia/src/runtime/task/state.rs
pub const SCHEDULED: usize = 1 << 0;
pub const RUNNING: usiz... | code_fim | medium | {
"lang": "rust",
"repo": "nephele-rs/cynthia",
"path": "/cynthia/src/runtime/task/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nephele-rs/cynthia path: /cynthia/src/runtime/task/state.rs
pub const SCHEDULED: usize = 1 << 0;
pub const RUNNING: usize = 1 << 1;
pub cons<|fim_suffix|>1 << 6;
pub const NOTIFYING: usize = 1 << 7;
pub const REFERENCE: usize = 1 << 8;<|fim_middle|>t COMPLETED: usize = 1 << 2;
pub const CLOSED: ... | code_fim | medium | {
"lang": "rust",
"repo": "nephele-rs/cynthia",
"path": "/cynthia/src/runtime/task/state.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Geigerkind/decision-tree-based-hand-gesture-recognition path: /lib_feature/src/features/sum_of_slopes.rs
use std::ops::Deref;
use lib_gesture::entities::Gesture;
use crate::features::Feature;
/// Calculates for each pixel the sum of the differences of each frame.
pub struct SumOfSlopes(pub [i... | code_fim | hard | {
"lang": "rust",
"repo": "Geigerkind/decision-tree-based-hand-gesture-recognition",
"path": "/lib_feature/src/features/sum_of_slopes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_marshal() {
// Arrange
let feature = SumOfSlopes([0, 1, 2, 3, 4, 5, 6, 7, 8]);
// Act
let marshaled = feature.marshal();
// Assert
assert_eq!(marshaled, String::from("0,1,2,3,4,5,6,7,8"));
}
}<|fim_prefix|>// repo: Geigerkind/de... | code_fim | hard | {
"lang": "rust",
"repo": "Geigerkind/decision-tree-based-hand-gesture-recognition",
"path": "/lib_feature/src/features/sum_of_slopes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &str:
- inflexible
- allocated on the stack
- sequence of UTF-8 characters
- you index into the bytes, not the char
String:
- flexible, can be modified
- allocated on the heap
- sequence of UTF-8 characters
- you index into the bytes, not the char
*/
let s ... | code_fim | hard | {
"lang": "rust",
"repo": "saidvandeklundert/LearningRust",
"path": "/types/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saidvandeklundert/LearningRust path: /types/src/main.rs
#![allow(unused_variables, dead_code)]
fn main() {
/*
Types:
https://doc.rust-lang.org/reference/types.html
Scalar types:
- booleans
- characters
- integers
- floats
*/
//Scalar types
le... | code_fim | hard | {
"lang": "rust",
"repo": "saidvandeklundert/LearningRust",
"path": "/types/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Union:
union IntOrFloat {
i: i32,
f: f32,
}
let mut iof = IntOrFloat { i: 123 };
iof.i = 234;
println!("iof.i = {}", unsafe { iof.i });
/*
Collections: https://doc.rust-lang.org/std/collections/index.html
- Vector: A contiguous growable array type wi... | code_fim | hard | {
"lang": "rust",
"repo": "saidvandeklundert/LearningRust",
"path": "/types/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn show_task(id: i32) {
let conn = db::establish_connection();
match db::get_task_by_id(&conn, id) {
Some(task) => print_task(&task),
None => println!("Such task doesn't exist"),
}
}
fn complete_task(id: i32) {
let conn = db::establish_connection();
match db::complete_... | code_fim | hard | {
"lang": "rust",
"repo": "Bravo555/mytodo",
"path": "/src/bin/todo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bravo555/mytodo path: /src/bin/todo.rs
use mytodo::db::{self, DbError};
use std::env;
fn main() {
env::set_var("DATABASE_URL", "./testdb.sqlite3");
let mut args = env::args().skip(1);
let subcommand: &str = &args.next().unwrap();
match subcommand {
"new" => {
... | code_fim | hard | {
"lang": "rust",
"repo": "Bravo555/mytodo",
"path": "/src/bin/todo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[doc="Ethernet MMC control register"]
#[derive(Default, Clone, Copy, PartialEq, Eq)]
pub struct Mmccr(pub u32);
impl Mmccr {
#[doc="no description available"]
#[inline] pub fn cr(&self) -> ::bobbin_bits::U1 {
unsafe { ::core::mem::transmute(((self.0 >> 0) & 0x1) as u8) } // [0]
}
... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-stm32/stm32f74x/src/ethernet_mmc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<u32> for Mmctgfsccr {
#[inline]
fn from(other: u32) -> Self {
Mmctgfsccr(other)
}
}
impl ::core::fmt::Display for Mmctgfsccr {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
self.0.fmt(f)
}
}
impl ::core::fmt::Debug for Mmctgfsccr {... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-stm32/stm32f74x/src/ethernet_mmc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu/bobbin-stm32/stm32f74x/src/ethernet_mmc.rs
T_MMC_REF_COUNT, 0x40028100, 0x00, 0x06);
#[doc="Ethernet: MAC management counters"]
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct EthernetMmcPeriph(pub usize);
impl EthernetMmcPeriph {
#[doc="Get the MMCCR Regis... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-stm32/stm32f74x/src/ethernet_mmc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn gen_synchronizer(chain_controller: ChainController, shared: Shared) -> Synchronizer {
let shared = Arc::new(SyncSharedState::new(shared));
Synchronizer::new(chain_controller, shared)
}
fn gen_block(
shared: &Shared,
parent_header: &CoreHeaderView,
ep... | code_fim | hard | {
"lang": "rust",
"repo": "SPERAXIO/ckb",
"path": "/sync/src/synchronizer/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let synchronizer2 = gen_synchronizer(chain_controller2, shared2.clone());
let latest_common = synchronizer2
.shared
.snapshot()
.locate_latest_common_block(&Byte32::zero(), &locator1[..]);
assert_eq!(latest_common, Some(192));
let header... | code_fim | hard | {
"lang": "rust",
"repo": "SPERAXIO/ckb",
"path": "/sync/src/synchronizer/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SPERAXIO/ckb path: /sync/src/synchronizer/mod.rs
chain_controller1, shared1) = start_chain(Some(consensus.clone()));
let (chain_controller2, shared2) = start_chain(Some(consensus.clone()));
let num = 200;
for i in 1..num {
insert_block(&chain_controller1, &sh... | code_fim | hard | {
"lang": "rust",
"repo": "SPERAXIO/ckb",
"path": "/sync/src/synchronizer/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Snektron/mamba path: /src/dtm/interpret.rs
use std::error::Error;
use std::str::FromStr;
use std::fmt;
use regex::Regex;
use dtm::{TuringMachine, TapeSymbol, State, Move};
lazy_static! {
static ref SYMBOL_REGEX: Regex = Regex::new(r"[0-9A-Za-z]+").unwrap();
}
#[derive(Debug)]
pub enum Runt... | code_fim | hard | {
"lang": "rust",
"repo": "Snektron/mamba",
"path": "/src/dtm/interpret.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn has_finished(&self) -> bool {
self.state == &self.dtm.accept || self.state == &self.dtm.reject
}
pub fn outcome(&self) -> Option<Outcome> {
if self.state == &self.dtm.accept {
Some(Outcome::Accept)
} else if self.state == &self.dtm.reject {
... | code_fim | hard | {
"lang": "rust",
"repo": "Snektron/mamba",
"path": "/src/dtm/interpret.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.