text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let a = Some(3);
let b = Some(4);
let out = combine_inner::<_, _, IntMulSemigroup>(a, b);
assert_eq!(Some(12), out);
}
#[test]
fn test_monoid() {
let out: Option<u32> = empty();
assert_eq!(None, out);
}
#[test]
fn test_applicative(... | code_fim | hard | {
"lang": "rust",
"repo": "twicepipes/rust-effects",
"path": "/src/option.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FlowerSamda/Rust path: /learning/smart_pointer/memory_leak/src/main.rs
// 순환 참조
// 말 그대로 순환하며 서로를 참조 -> 메모리 누수로 인해 프로그램 정지 가능
// Rc<T>값을 가지고 있는 RefCell<T> 혹은 내부 가변성 및 참조 카운팅 기능이 있는 타입을 사용할 때 순환을 만들지 않도록 주의!
use std::rc::Rc;
use std::cell::RefCell;
use List::{Cons, Nil};
#[derive(Debug)]
enum... | code_fim | hard | {
"lang": "rust",
"repo": "FlowerSamda/Rust",
"path": "/learning/smart_pointer/memory_leak/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let leaf = Rc::new(Node {
value: 3,
children: RefCell::new(vec![]),
});
// branch.children을 통해 leaf로 접근할 수 있지만, leaf는 branch로 접근할 수 있는 방법이 없음
let branch = Rc::new(Node {
value: 5,
children: RefCell::new(vec![Rc::clone(&leaf)]),
});
*/
// 메모리 누수... | code_fim | hard | {
"lang": "rust",
"repo": "FlowerSamda/Rust",
"path": "/learning/smart_pointer/memory_leak/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"branch strong = {}, weak = {}", // 1, 1 (branch의 Rc::new(Node), downgrade(&branch))
Rc::strong_count(&branch),
Rc::weak_count(&branch),
);
println!(
"leaf strong = {}, weak = {}", // 2, 0 (let leaf = Rc::new(), clone(&... | code_fim | hard | {
"lang": "rust",
"repo": "FlowerSamda/Rust",
"path": "/learning/smart_pointer/memory_leak/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>IMEOUT_CTL_SPEC>`"]
pub type TIMEOUT_CTL = crate::Reg<timeout_ctl::TIMEOUT_CTL_SPEC>;
#[doc = "Timeout control"]
pub mod timeout_ctl;<|fim_prefix|>// repo: psoc-rs/psoc6-pac path: /src/peri/gr.rs
#[doc = "CLOCK_CTL register accessor: an alias for `Reg<CLOCK_CTL_SPEC>`"]
pub type CLOCK_CTL = crate::Re... | code_fim | hard | {
"lang": "rust",
"repo": "psoc-rs/psoc6-pac",
"path": "/src/peri/gr.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: psoc-rs/psoc6-pac path: /src/peri/gr.rs
#[doc = "CLOCK_CTL register accessor: an alias for `Reg<CLOCK_CTL_SPEC>`"]
pub type CLOCK_CTL = crate::Reg<clock_ctl::CLOCK_CTL_SPEC>;<|fim_suffix|>IMEOUT_CTL_SPEC>`"]
pub type TIMEOUT_CTL = crate::Reg<timeout_ctl::TIMEOUT_CTL_SPEC>;
#[doc = "Timeout co... | code_fim | hard | {
"lang": "rust",
"repo": "psoc-rs/psoc6-pac",
"path": "/src/peri/gr.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(r.int_u, 1262698832);
assert_eq!(r.int_s, -52947);
assert_eq!(r.div_pos_const, 756);
assert_eq!(r.div_neg_const, -757);
assert_eq!(r.div_pos_seq, 97130679);
assert_eq!(r.div_neg_seq, -4073);
}
}<|fim_prefix|>// repo: kaitai-io/kaitai_struct_te... | code_fim | medium | {
"lang": "rust",
"repo": "kaitai-io/kaitai_struct_tests",
"path": "/spec/rust/test_expr_int_div.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaitai-io/kaitai_struct_tests path: /spec/rust/test_expr_int_div.rs
// Autogenerated from KST: please remove this line if doing any edits by hand!
extern crate kaitai_struct;
extern crate rust;
use kaitai_struct::KaitaiStruct;
use rust::ExprIntDiv;
#[test]
fn test_expr_int_div() {
<|fim_suffi... | code_fim | medium | {
"lang": "rust",
"repo": "kaitai-io/kaitai_struct_tests",
"path": "/spec/rust/test_expr_int_div.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(r) = ExprIntDiv::from_file("src/fixed_struct.bin") {
assert_eq!(r.int_u, 1262698832);
assert_eq!(r.int_s, -52947);
assert_eq!(r.div_pos_const, 756);
assert_eq!(r.div_neg_const, -757);
assert_eq!(r.div_pos_seq, 97130679);
assert_eq!(r.div_neg_s... | code_fim | medium | {
"lang": "rust",
"repo": "kaitai-io/kaitai_struct_tests",
"path": "/spec/rust/test_expr_int_div.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pjam76/snypeyou path: /src/main.rs
extern crate piston_window;
extern crate find_folder;
extern crate rand;
use piston_window::*;
use rand::Rng;
struct Folk {
pub x: f64,
pub y: f64,
pub w: f64,
pub h: f64,
pub active: bool,
ltr: bool,
speed: f64,
blue: [f32; 4]... | code_fim | hard | {
"lang": "rust",
"repo": "pjam76/snypeyou",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> text::Text::new_color(black, 30)
.draw(
&"<w><a><s><d> to move",
&mut glyphs,
&c.draw_state,
c.transfo... | code_fim | hard | {
"lang": "rust",
"repo": "pjam76/snypeyou",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn load(
file_path: String,
event_loop_proxy: EventLoopProxy<UserEvent>,
layers: sync::Arc<sync::RwLock<Layers>>,
) {
log::info!("Spawning a new thread for loading: {}", file_path);
rayon::spawn(move || {
let count = geojson::load(file_path, layers);
if count > 0 {
... | code_fim | medium | {
"lang": "rust",
"repo": "dtolnay-contrib/rgis",
"path": "/src/file_loader/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtolnay-contrib/rgis path: /src/file_loader/mod.rs
use crate::layer::Layers;
use crate::window::UserEvent;
use glutin::event_loop::EventLoopProxy;
use std::sync;
<|fim_suffix|>pub fn load(
file_path: String,
event_loop_proxy: EventLoopProxy<UserEvent>,
layers: sync::Arc<sync::RwLock... | code_fim | medium | {
"lang": "rust",
"repo": "dtolnay-contrib/rgis",
"path": "/src/file_loader/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeffmay/rust_membership_api path: /src/db/models.rs
use db::schema::*;
/// The standard ID type for the database
pub type ID = i32;
/// A user from the `users` table. Can either be a guest or a member.
#[derive(Debug, Serialize, Insertable, Queryable)]
#[table_name="users"]
pub struct User {
... | code_fim | medium | {
"lang": "rust",
"repo": "jeffmay/rust_membership_api",
"path": "/src/db/models.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The name of the role. Must be unique per committee.
pub role: String,
}
pub enum ElectionStatus {
Draft,
Published,
Final,
}<|fim_prefix|>// repo: jeffmay/rust_membership_api path: /src/db/models.rs
use db::schema::*;
/// The standard ID type for the database
pub type ID = i32;
... | code_fim | medium | {
"lang": "rust",
"repo": "jeffmay/rust_membership_api",
"path": "/src/db/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ltabis/accounts-cli path: /src/lib.rs
#[macro_use] extern crate prettytable;
pub mod new;
pub mod args;
pub mod list;
pub mod u<|fim_suffix|> balance;
pub mod currency;
pub mod accounts;<|fim_middle|>tils;
pub mod remove;
pub mod rename;
pub mod | code_fim | easy | {
"lang": "rust",
"repo": "ltabis/accounts-cli",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tils;
pub mod remove;
pub mod rename;
pub mod balance;
pub mod currency;
pub mod accounts;<|fim_prefix|>// repo: ltabis/accounts-cli path: /src/lib.rs
#[macro_use] extern crate prettytable;
pub m<|fim_middle|>od new;
pub mod args;
pub mod list;
pub mod u | code_fim | easy | {
"lang": "rust",
"repo": "ltabis/accounts-cli",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filter = self.filter_builder.build()?;
Ok(
LookAheadComposeFilter::<W, F1, F2, B1, B2, M1, M2, CFB::CF, SMT> {
lookahead_type: self.lookahead_type,
flags: self.flags,
lookahead_tr: false,
selector: self.select... | code_fim | hard | {
"lang": "rust",
"repo": "Garvys/rustfst",
"path": "/rustfst/src/algorithms/compose/lookahead_filters/lookahead_compose_filter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Garvys/rustfst path: /rustfst/src/algorithms/compose/lookahead_filters/lookahead_compose_filter.rs
use std::borrow::Borrow;
use std::fmt::Debug;
use std::marker::PhantomData;
use std::sync::Arc;
use anyhow::Result;
use crate::algorithms::compose::compose_filters::{ComposeFilter, ComposeFilterB... | code_fim | hard | {
"lang": "rust",
"repo": "Garvys/rustfst",
"path": "/rustfst/src/algorithms/compose/lookahead_filters/lookahead_compose_filter.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn matcher1(&self) -> &M1 {
self.filter.matcher1()
}
fn matcher2(&self) -> &M2 {
self.filter.matcher2()
}
fn matcher1_shared(&self) -> &Arc<M1> {
self.filter.matcher1_shared()
}
fn matcher2_shared(&self) -> &Arc<M2> {
self.filter.matcher2_shar... | code_fim | hard | {
"lang": "rust",
"repo": "Garvys/rustfst",
"path": "/rustfst/src/algorithms/compose/lookahead_filters/lookahead_compose_filter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use std::str::FromStr;
use common_types::header::Header;
use super::*;
use spec;
fn get_default_ethash_extensions() -> EthashExtensions {
EthashExtensions {
homestead_transition: 1150000,
dao_hardfork_transition: u64::max_value(),
dao_hardfork_beneficiary: Address... | code_fim | hard | {
"lang": "rust",
"repo": "yijie37/DaQiao",
"path": "/bridge/parity-ethereum/ethcore/machine/src/machine.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yijie37/DaQiao path: /bridge/parity-ethereum/ethcore/machine/src/machine.rs
Parity Ethereum.
// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of t... | code_fim | hard | {
"lang": "rust",
"repo": "yijie37/DaQiao",
"path": "/bridge/parity-ethereum/ethcore/machine/src/machine.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Builtin-contracts for the chain..
pub fn builtins(&self) -> &BTreeMap<Address, Builtin> {
&*self.builtins
}
/// Attempt to get a handle to a built-in contract.
/// Only returns references to activated built-ins.
// TODO: builtin contract routing - to do this properly, it will require removing... | code_fim | hard | {
"lang": "rust",
"repo": "yijie37/DaQiao",
"path": "/bridge/parity-ethereum/ethcore/machine/src/machine.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Spatial source builder allows you to construct new spatial sound source with desired parameters.
pub struct SpatialSourceBuilder {
generic: GenericSource,
radius: f32,
position: Vector3<f32>,
max_distance: f32,
rolloff_factor: f32,
}
impl SpatialSourceBuilder {
/// Creates new... | code_fim | hard | {
"lang": "rust",
"repo": "sierra-zero/rg3d",
"path": "/rg3d-sound/src/source/spatial.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// See `set_position` of SpatialSource.
pub fn with_position(mut self, position: Vector3<f32>) -> Self {
self.position = position;
self
}
/// See `set_radius` of SpatialSource.
pub fn with_radius(mut self, radius: f32) -> Self {
self.radius = radius;
s... | code_fim | hard | {
"lang": "rust",
"repo": "sierra-zero/rg3d",
"path": "/rg3d-sound/src/source/spatial.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sierra-zero/rg3d path: /rg3d-sound/src/source/spatial.rs
//! Spatial sound source module.
//!
//! # Overview
//!
//! Spatial sound source are most interesting source in the engine. They can have additional effects such as positioning,
//! distance attenuation, can be processed via HRTF, etc.
//!... | code_fim | hard | {
"lang": "rust",
"repo": "sierra-zero/rg3d",
"path": "/rg3d-sound/src/source/spatial.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gKevinK/LeetCode path: /1466_Reorder_Routes_to_Make_All_Paths_Lead_to_the_City_Zero.rs
impl Solution {
pub fn min_reorder(n: i32, mut connections: Vec<Vec<i32>>) -> i32 {
let mut c2e = vec![vec![]; n as usize];
for i in 0..connections.len() {
c2e[connections[i][0]... | code_fim | hard | {
"lang": "rust",
"repo": "gKevinK/LeetCode",
"path": "/1466_Reorder_Routes_to_Make_All_Paths_Lead_to_the_City_Zero.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
if connections[*e][0] == connections[i][0] {
r += 1;
connections[*e].swap(0, 1);
}
q.push_back(*e);
}
}
r
}
}<|fim_prefix|>// repo: gKevinK/LeetCode path: /1466_Reorder_Rou... | code_fim | hard | {
"lang": "rust",
"repo": "gKevinK/LeetCode",
"path": "/1466_Reorder_Routes_to_Make_All_Paths_Lead_to_the_City_Zero.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
them
"
]
pub
struct
Instrumented
<
T
>
{
#
[
pin
]
inner
:
T
span
:
Span
}
}
/
/
=
=
=
impl
Instrumented
=
=
=
impl
<
T
:
Future
>
Future
for
Instrumented
<
T
>
{
type
Output
=
T
:
:
Output
;
fn
poll
(
self
:
Pin
<
&
mut
Self
>
cx
:
&
mut
Context
<
'
_
>
)
-
>
Poll
<
Self
:
:
Output
>
{
let
this
=
self
.... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tracing/src/instrument.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tracing/src/instrument.rs
use
crate
:
:
stdlib
:
:
pin
:
:
Pin
;
use
crate
:
:
stdlib
:
:
task
:
:
{
Context
Poll
}
;
use
crate
:
:
stdlib
:
:
{
future
:
:
Future
marker
:
:
Sized
}
;
use
crate
:
:
{
dispatcher
:
:
{
self
Dispatch
}
span
:
:
Sp... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tracing/src/instrument.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ctxt.opengl_es {
if ctxt.version < &GlVersion(3, 0) {
result.push("OpenGL ES version inferior to 3.0");
}
} else {
if ctxt.version < &GlVersion(2, 0) {
result.push("OpenGL version inferior to 2.0 is not supported");
}
if !ctxt.ex... | code_fim | hard | {
"lang": "rust",
"repo": "yurivish/glium",
"path": "/src/context.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yurivish/glium path: /src/context.rs
er_read: None,
renderbuffer: 0,
depth_func: gl::LESS,
depth_range: (0.0, 1.0),
blend_func: (0, 0), // no default specified
viewport: viewport,
scissor: viewport,
line_widt... | code_fim | hard | {
"lang": "rust",
"repo": "yurivish/glium",
"path": "/src/context.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Maximum number of textures that can be bind to a program.
///
/// `glActiveTexture` must be between `GL_TEXTURE0` and `GL_TEXTURE0` + this value - 1.
pub max_combined_texture_image_units: gl::types::GLint,
/// Maximum value for `GL_TEXTURE_MAX_ANISOTROPY_EXT`.
///
/// `No... | code_fim | hard | {
"lang": "rust",
"repo": "yurivish/glium",
"path": "/src/context.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match id {
name_id::COPYRIGHT_NOTICE => String::from("Copyright notice"),
name_id::FAMILY => String::from("Family name"),
name_id::SUBFAMILY => String::from("Sub family name"),
name_id::UNIQUE_ID => String::from("Unique id"),
name_id::FULL_NAME => String::from("... | code_fim | medium | {
"lang": "rust",
"repo": "ssssota/font-cli-test",
"path": "/src/load.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ssssota/font-cli-test path: /src/load.rs
use std::{
fs::File,
io::{Error, Read},
path::Path,
};
use ttf_parser::{fonts_in_collection, name_id, Face};
pub fn load_font<P: AsRef<Path>>(path: P) {
let data = load_file(path).unwrap();
let fonts_count = fonts_in_collection(&data... | code_fim | medium | {
"lang": "rust",
"repo": "ssssota/font-cli-test",
"path": "/src/load.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simonsan/OxidizeBot path: /bot/src/api/nightbot.rs
//! nightbot.tv API helpers.
use crate::{api::base::RequestBuilder, oauth2};
use failure::Error;
use reqwest::{header, Client, Method, Url};
static NIGHTBOT_URL_V1: &'static str = "https://api.nightbot.tv/1";
pub enum RequestError {
TooMa... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/OxidizeBot",
"path": "/bot/src/api/nightbot.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> RequestBuilder::new(self.client.clone(), method, url).token(self.token.clone())
}
/// Update the channel information.
pub async fn channel_send(&self, message: String) -> Result<(), RequestError> {
let message = Message { message };
let message = serde_json::to_string... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/OxidizeBot",
"path": "/bot/src/api/nightbot.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Handler<Message> for WsChatSession {
type Result = ();
fn handle(&mut self, msg: Message, ctx: &mut Self::Context) -> Self::Result {
ctx.text(WsMessage {
ty: MessageType::Msg,
data: json!(msg),
});
}
}
impl StreamHandler<Result<ws::Message, ws::Pr... | code_fim | hard | {
"lang": "rust",
"repo": "JasterV/chat-rooms-actix",
"path": "/src/actors/chat_session.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn join(&self, room_id: Uuid, ctx: &mut WebsocketContext<Self>) {
let join_room = self.addr.send(JoinRoom {
room: room_id,
session: self.id.clone(),
});
let join_room = join_room.into_actor(self);
join_room
.then(move |response, act, ... | code_fim | hard | {
"lang": "rust",
"repo": "JasterV/chat-rooms-actix",
"path": "/src/actors/chat_session.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JasterV/chat-rooms-actix path: /src/actors/chat_session.rs
use crate::{
actors::chat_server::ChatServer,
constants::CLIENT_TIMEOUT,
models::{RoomId, SessionId, UserInfo},
};
use crate::{
constants::HEARTBEAT_INTERVAL,
messages::{
server::{ClientMessage, Connect, Creat... | code_fim | hard | {
"lang": "rust",
"repo": "JasterV/chat-rooms-actix",
"path": "/src/actors/chat_session.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pslk12/learn-rust path: /rectangles/src/main.rs
#![allow(dead_code)]
#[derive(Debug)]
struct Rectangle {
width: i32,
height: i32
}
enum Foo {
Bar,
Baz,
Qux(u32)
}
impl Rectangle {
fn area (&self) -> i32 {
self.width * self.height
}
fn can_hold(&self,... | code_fim | hard | {
"lang": "rust",
"repo": "pslk12/learn-rust",
"path": "/rectangles/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Variable a matches Foo::Bar
if let Foo::Bar = a {
println!("a is foobar");
}
// Variable b does not match Foo::Bar
// So this will print nothing
if let Foo::Baz = b {
println!("b is foobar");
}
// Variable c matches Foo::Qux which has a value
// Sim... | code_fim | hard | {
"lang": "rust",
"repo": "pslk12/learn-rust",
"path": "/rectangles/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Airtnp/utils-rs path: /delegate_derive/src/register.rs
use quote::quote;
// potential macro design
// macro_rules! add_modifier {
// ($([$($tail:tt)+]),+) => {
// fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
// match *self {
// $(add_modifie... | code_fim | hard | {
"lang": "rust",
"repo": "Airtnp/utils-rs",
"path": "/delegate_derive/src/register.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn build_const(cst: ConstItem, trait_name: &syn::Ident) -> proc_macro2::TokenStream {
let const_attrs = cst.attrs.iter().map(quote::ToTokens::to_token_stream);
let const_ident = &cst.ident;
let const_type = &cst.ty;
quote! {
#(#const_attrs)*
const #const_ident: #const_type ... | code_fim | hard | {
"lang": "rust",
"repo": "Airtnp/utils-rs",
"path": "/delegate_derive/src/register.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sportshark/bcnode path: /rust/bcrust-core/src/protos/rover.rs
::Option::Some(RoverMessage_oneof_payload::resync(v))
}
// Mutable pointer to the field.
pub fn mut_resync(&mut self) -> &mut RoverMessage_Resync {
if let ::std::option::Option::Some(RoverMessage_oneof_payload::re... | code_fim | hard | {
"lang": "rust",
"repo": "sportshark/bcnode",
"path": "/rust/bcrust-core/src/protos/rover.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut my_size = 0;
if let Some(ref v) = self.from_block.as_ref() {
let len = v.compute_size();
my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len;
}
if let Some(ref v) = self.to_block.as_ref() {
let len = v.compute_size... | code_fim | hard | {
"lang": "rust",
"repo": "sportshark/bcnode",
"path": "/rust/bcrust-core/src/protos/rover.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_from_block(&self) -> u64 {
self.from_block
}
// uint64 to_block = 2;
pub fn clear_to_block(&mut self) {
self.to_block = 0;
}
// Param is passed by value, moved
pub fn set_to_block(&mut self, v: u64) {
self.to_block = v;
}
pub fn ge... | code_fim | hard | {
"lang": "rust",
"repo": "sportshark/bcnode",
"path": "/rust/bcrust-core/src/protos/rover.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YangKian/MyPractice path: /rs/linklist/src/third.rs
use std::rc::Rc;
// 构造一个不可变链表
// 使用不可变链表的原因:实现在多线程之间共享数据
// Arc 和 Rc 的区别:Arc 对引用计数的修改是原子性的,即 Arc 是线程安全的
// Rust models thread-safety in a first-class way with two traits: Send and Sync.
// A type is Send if it's safe to move to another thread... | code_fim | hard | {
"lang": "rust",
"repo": "YangKian/MyPractice",
"path": "/rs/linklist/src/third.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let list = List::new();
assert_eq!(list.head(), None);
let list = list.append(1).append(2).append(3);
assert_eq!(list.head(), Some(&3));
let list = list.tail();
assert_eq!(list.head(), Some(&2));
let list = list.tail();
assert_eq!(list.hea... | code_fim | hard | {
"lang": "rust",
"repo": "YangKian/MyPractice",
"path": "/rs/linklist/src/third.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AuthForbidden/HZ256 path: /src/gen.rs
// Copyright 2021 AuthForbidden
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICE... | code_fim | hard | {
"lang": "rust",
"repo": "AuthForbidden/HZ256",
"path": "/src/gen.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn generate_dict() {
let mut poem_stat: HashMap<char, u32> = HashMap::new();
if let Ok(poem_lines) = read("poems.txt") {
for poem_rline in poem_lines {
if let Ok(poem_line) = poem_rline {
if poem_line.starts_with('(') || poem_line.contains('【') {
... | code_fim | medium | {
"lang": "rust",
"repo": "AuthForbidden/HZ256",
"path": "/src/gen.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P : AsRef<Path> {
let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines())
}<|fim_prefix|>// repo: AuthForbidden/HZ256 path: /src/gen.rs
// Copyright 2021 AuthForbidden
//
// Licensed under the Apache Licens... | code_fim | hard | {
"lang": "rust",
"repo": "AuthForbidden/HZ256",
"path": "/src/gen.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bklooste/leaf path: /tests/network_specs.rs
// not sure why needed ....
extern crate anne;
use anne::blocks::{LogisticBlock ,LogisticBBlock , BlockData , LinearByteBlock,LogisticBlockwLifetime};
use anne::core::{Block , BlockBehaviour };
use anne::util::to_floats;
// , BlockData};
// block ... | code_fim | hard | {
"lang": "rust",
"repo": "bklooste/leaf",
"path": "/tests/network_specs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn fullmesh_bias_integration_w05 ()
{
unsafe
{
static INPUT_BUF: &'static [f32] = &[1f32, 2f32, 3f32, 4f32, 5f32];
static mut OUTPUT_BUF: & 'static mut [f32] = & mut [1f32, 2f32, 3f32, 4f32, 5f32];
static WEIGHTS: & 'static [f32] = & [ 0.5f32 ; 30];
let ... | code_fim | hard | {
"lang": "rust",
"repo": "bklooste/leaf",
"path": "/tests/network_specs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn get_icon_with_color() {
let icon = Icon::new("bluetooth-b").color("red").build();
assert!(icon.is_some());
assert_eq!(icon.unwrap().color, "rgb(255, 0, 0)".to_string());
}
}<|fim_prefix|>// repo: brianjd/merit path: /src/icons.rs
use super::get_color;
use maud::{html, PreEsca... | code_fim | hard | {
"lang": "rust",
"repo": "brianjd/merit",
"path": "/src/icons.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brianjd/merit path: /src/icons.rs
use super::get_color;
use maud::{html, PreEscaped, Render};
use std::{convert, str};
include!(concat!(env!("OUT_DIR"), "/icons_map.rs"));
static DEFAULT_COLOUR: &str = "#fff";
<|fim_suffix|>impl<'a> Render for Icon<'a> {
fn render(&self) -> maud::Markup {
... | code_fim | hard | {
"lang": "rust",
"repo": "brianjd/merit",
"path": "/src/icons.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> llg::lgw_conf_board_s {
lorawan_public: other.lorawan_public,
clksrc: other.clksrc as u8,
#[cfg(feature = "sx1302")]
full_duplex: false,
#[cfg(feature = "sx1302")]
spidev_path: {
let mut path = [0; 64];
... | code_fim | hard | {
"lang": "rust",
"repo": "helium/concentrate",
"path": "/loragw/src/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Specifies when to send a `TxPacket`
#[derive(Debug, Clone, Copy)]
pub enum TxMode {
/// Do not delay.
///
/// There are still delays incurred from SPI communication and
/// analog circuitry settling.
Immediate,
/// Send when concentrator's internal counter equals the time speci... | code_fim | hard | {
"lang": "rust",
"repo": "helium/concentrate",
"path": "/loragw/src/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: helium/concentrate path: /loragw/src/types.rs
::SF7,
8 => Spreading::SF8,
9 => Spreading::SF9,
10 => Spreading::SF10,
11 => Spreading::SF11,
12 => Spreading::SF12,
0x7E => Spreading::Multi,
invalid => {
... | code_fim | hard | {
"lang": "rust",
"repo": "helium/concentrate",
"path": "/loragw/src/types.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PIAIC-IOT/Quarter-1_6.45-9.45 path: /27th-Oct/Hash-maps/src/main.rs
fn main() {
use std::collections::HashMap;
let mut Fav_dish = HashMap::new();
<|fim_suffix|>for (key, value) in &Fav_dish {
println!("{}: {}", key, value);
}
}<|fim_middle|>Fav_dish.insert("Ali", "Biryani");
Fav_dish.ins... | code_fim | medium | {
"lang": "rust",
"repo": "PIAIC-IOT/Quarter-1_6.45-9.45",
"path": "/27th-Oct/Hash-maps/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for (key, value) in &Fav_dish {
println!("{}: {}", key, value);
}
}<|fim_prefix|>// repo: PIAIC-IOT/Quarter-1_6.45-9.45 path: /27th-Oct/Hash-maps/src/main.rs
fn main() {
use std::collections::HashMap;
<|fim_middle|>let mut Fav_dish = HashMap::new();
Fav_dish.insert("Ali", "Biryani");
Fav_dish.ins... | code_fim | medium | {
"lang": "rust",
"repo": "PIAIC-IOT/Quarter-1_6.45-9.45",
"path": "/27th-Oct/Hash-maps/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Frando/colmeia path: /legacy/colmeia-dat1-proto/src/lib.rs
bleStream>> {
&mut self.writer
}
pub async fn have(&mut self, channel: u64, message: &proto::Have) -> anyhow::Result<()> {
self.writer()
.send(ChannelMessage::new(
channel,
... | code_fim | hard | {
"lang": "rust",
"repo": "Frando/colmeia",
"path": "/legacy/colmeia-dat1-proto/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> log::debug!("Preparing to read feed nonce");
let received_feed =
async_std::future::timeout(Duration::from_secs(1), init.bare_reader.next()).await?;
let received_feed = match received_feed {
Some(received_feed) => received_feed,
_ => return Err(anyhow::anyhow!("Timed ou... | code_fim | hard | {
"lang": "rust",
"repo": "Frando/colmeia",
"path": "/legacy/colmeia-dat1-proto/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Frando/colmeia path: /legacy/colmeia-dat1-proto/src/lib.rs
channel,
3,
message.write_to_bytes().context("not a valid have")?,
))
.await
.context("could not write have")
}
pub async fn want(&mut self, channel: ... | code_fim | hard | {
"lang": "rust",
"repo": "Frando/colmeia",
"path": "/legacy/colmeia-dat1-proto/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *TYPE_MAP
.iter()
.find(|entry| src == entry.type_id)
.expect("Unimplemented type map")
}
pub struct VertexAttrib {
pub name: &'static str,
pub count: i32,
pub kind: u32,
pub size: u32,
pub normalized: bool,
}
impl VertexAttrib {
pub fn new(name: &'stat... | code_fim | hard | {
"lang": "rust",
"repo": "jaynus/balls",
"path": "/game/render_glow/src/vertex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jaynus/balls path: /game/render_glow/src/vertex.rs
use glow::HasContext;
use rl_render_pod::std140::*;
use std::any::TypeId;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
struct VertexTypeMapEntry {
pub type_id: TypeId,
pub kind: u32,
pub width: usize,
}
impl VertexTypeMapE... | code_fim | hard | {
"lang": "rust",
"repo": "jaynus/balls",
"path": "/game/render_glow/src/vertex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait VertexAttribList {
fn submit(&self, gl: &glow::Context);
}
impl<'a> VertexAttribList for &'a [VertexAttrib] {
#[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)]
fn submit(&self, gl: &glow::Context) {
unsafe {
let stride = self.iter().map(|e| e... | code_fim | hard | {
"lang": "rust",
"repo": "jaynus/balls",
"path": "/game/render_glow/src/vertex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jocull/rust-measurements path: /src/energy.rs
//! Types and constants for handling energy.
use super::measurement::*;
/// The `Energy` struct can be used to deal with energies in a common way.
/// Common metric and imperial units are supported.
///
/// # Example
///
/// ```
/// use measurement... | code_fim | hard | {
"lang": "rust",
"repo": "jocull/rust-measurements",
"path": "/src/energy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_almost_eq(r1, 360000000.0);
assert_almost_eq(r2, 2.777777777777777777777777777778e-5);
}
// Traits
#[test]
fn add() {
let a = Energy::from_joules(2.0);
let b = Energy::from_joules(4.0);
let c = a + b;
let d = b + a;
assert_alm... | code_fim | hard | {
"lang": "rust",
"repo": "jocull/rust-measurements",
"path": "/src/energy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RyanMeulenkamp/solplan-rust path: /src/widget/roofwidget.rs
use druid::{Widget, WidgetExt, EventCtx, Event, Env, LifeCycleCtx, LifeCycle, UpdateCtx, BoxConstraints, LayoutCtx, Size, PaintCtx, Color, RenderContext, Affine};
use crate::model::roof::Roof;
use druid::widget::{Flex, MainAxisAlignment... | code_fim | hard | {
"lang": "rust",
"repo": "RyanMeulenkamp/solplan-rust",
"path": "/src/widget/roofwidget.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Flex::column()
.cross_axis_alignment(druid::widget::CrossAxisAlignment::End)
.with_child(create_form_element("Ridge", SiFormatter::MILLIMETERS, Roof::ridge))
.with_child(create_form_element("Eaves", SiFormatter::MILLIMETERS, Roof::eaves))
.with_child(create_form_element... | code_fim | hard | {
"lang": "rust",
"repo": "RyanMeulenkamp/solplan-rust",
"path": "/src/widget/roofwidget.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ctx.fill(path, &Color::grey8(100));
}
}
fn create_roof_forms_widget() -> impl Widget<Roof> {
Flex::column()
.cross_axis_alignment(druid::widget::CrossAxisAlignment::End)
.with_child(create_form_element("Ridge", SiFormatter::MILLIMETERS, Roof::ridge))
.with_child(cr... | code_fim | hard | {
"lang": "rust",
"repo": "RyanMeulenkamp/solplan-rust",
"path": "/src/widget/roofwidget.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let new_voter_votes = VoterVotes {
is_initialized: true,
positive_votes: 2,
negative_votes: 1,
voter_pubkey: *voter_pubkey,
voting_state_pubkey: *voting_state_account.key,
};
new_voter_votes.serialize(&mut *voter_votes_account.try_borrow_mut_data()?)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "calsaviour/voting-anchor-moonzoon",
"path": "/program_/src/processor/add_voter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: calsaviour/voting-anchor-moonzoon path: /program_/src/processor/add_voter.rs
use crate::{
error::VotingError,
state::{VoterVotes, VotingState},
};
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::Prog... | code_fim | hard | {
"lang": "rust",
"repo": "calsaviour/voting-anchor-moonzoon",
"path": "/program_/src/processor/add_voter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> proptest! {
#[test]
#[ignore]
fn check_block(
values in prop::collection::vec(u32::arbitrary(), BitPacker4x::BLOCK_LEN),
) {
let bit_packer = BitPacker4x::new();
let bit_width = bit_packer.num_bits(&*values);
let mut bloc... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/bitpacking",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Decompress the`compress`array to the `decompressed` array.
/// The `compressed` array is assumed to have been delta-encoded and compressed.
///
/// `initial` must be the value that was passed as the `initial` argument compressing
/// the block.
///
/// Returns the amount of... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/bitpacking",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PSeitz/bitpacking path: /src/lib.rs
/*! # Fast Bitpacking algorithms
This crate is a **Rust port of [Daniel Lemire's simdcomp C library](https://github.com/lemire/simdcomp)**.
It contains different flavor of integers compression via bitpacking : `BitPacker1x`, `BitPacker4x`, and `BitPacker8x`... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/bitpacking",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phytolizer/minsk-rs path: /minsk-language/src/code_analysis/syntax/assignment_expression_syntax.rs
use std::fmt::Display;
use crate::code_analysis::text::text_span::TextSpan;
use super::{expression_syntax::ExpressionSyntax, syntax_token::SyntaxToken};
<|fim_suffix|> writeln!(f, "Assign... | code_fim | hard | {
"lang": "rust",
"repo": "Phytolizer/minsk-rs",
"path": "/minsk-language/src/code_analysis/syntax/assignment_expression_syntax.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> writeln!(f, "AssignmentExpressionSyntax")?;
writeln!(f, " {}", self.identifier_token)?;
writeln!(f, " {}", self.equals_token)?;
writeln!(f, " {}", self.expression)?;
Ok(())
}
}<|fim_prefix|>// repo: Phytolizer/minsk-rs path: /minsk-language/src/code_an... | code_fim | medium | {
"lang": "rust",
"repo": "Phytolizer/minsk-rs",
"path": "/minsk-language/src/code_analysis/syntax/assignment_expression_syntax.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Zireael-N/bw-locale-generator path: /localize_npc_names/src/utils.rs
use once_cell::sync::Lazy;
use onig::{Regex, Replacer};
use crate::Map;
use std::{
borrow::Cow,
fs::{self, File},
io::{self, BufRead, BufReader, BufWriter, ErrorKind, Read, Write},
path::{Path, PathBuf},
ti... | code_fim | hard | {
"lang": "rust",
"repo": "Zireael-N/bw-locale-generator",
"path": "/localize_npc_names/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn write_to_dir(
output_dir: &Path,
tmp_dir: &Path,
language_code: &str,
header: &str,
values: Map<String, (String, bool)>,
) -> Result<(), (PathBuf, io::Error)> {
let to_path = output_dir.join(format!("{language_code}.lua"));
match File::open(&to_path) {
// ... | code_fim | hard | {
"lang": "rust",
"repo": "Zireael-N/bw-locale-generator",
"path": "/localize_npc_names/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some((translation, is_valid)) = values.remove(name) {
let is_comment = caps.at(1).is_some();
let leftover = caps.at(4).unwrap();
if is_valid && (is_comment || caps.at(3).unwrap() != translation) {
... | code_fim | hard | {
"lang": "rust",
"repo": "Zireael-N/bw-locale-generator",
"path": "/localize_npc_names/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl<T> Future for SpawnedFuture<T> {
type Error = SupError;
type Item = T;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match self {
SpawnedFuture(Ok(r)) => r.poll().map_err(Into::into),
SpawnedFuture(Err(e)) => {
Err(e.take()
... | code_fim | hard | {
"lang": "rust",
"repo": "tyler-ball/habitat",
"path": "/components/sup/src/manager/service/spawned_future.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tyler-ball/habitat path: /components/sup/src/manager/service/spawned_future.rs
// Copyright (c) 2019 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You ... | code_fim | hard | {
"lang": "rust",
"repo": "tyler-ball/habitat",
"path": "/components/sup/src/manager/service/spawned_future.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: junelife/rust-anywhere path: /crates/lvgl/lvgl-sys/build.rs
use std::env;
use std::error::Error;
use std::fs;
use std::path::PathBuf;
use std::process::Command;
fn main() -> Result<(), Box<Error>> {
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
fs::remove_dir_all(&out_dir)?;
fs... | code_fim | hard | {
"lang": "rust",
"repo": "junelife/rust-anywhere",
"path": "/crates/lvgl/lvgl-sys/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Make sure these options are synchronized with lv_conf.h.
println!("cargo:lv_color_depth=16");
println!("cargo:use_lv_gauge=enabled");
println!("cargo:use_lv_img=enabled");
println!("cargo:use_lv_label=enabled");
println!("cargo:use_lv_lmeter=enabled");
Ok(())
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "junelife/rust-anywhere",
"path": "/crates/lvgl/lvgl-sys/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct MarkdownFormatter;
impl Abstract for MarkdownFormatter {
fn format_header(&self) -> String
{
"# TODO\n".to_string()
}
fn format_content(&self, content: String) -> String
{
content
}
fn format_footer(&self) -> String
{
"".to_string()
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "mopp/CodeGarage",
"path": "/rust/design_patterns/template_method.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mopp/CodeGarage path: /rust/design_patterns/template_method.rs
trait Abstract {
fn format_header(&self) -> String;
fn format_content(&self, String) -> String;
fn format_footer(&self) -> String;
fn build(&self, msg: String) -> String
{
self.format_header() + &self.form... | code_fim | hard | {
"lang": "rust",
"repo": "mopp/CodeGarage",
"path": "/rust/design_patterns/template_method.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
"".to_string()
}
}
fn main()
{
let f1 = HtmlFormatter;
let f2 = MarkdownFormatter;
println!("{}\n", f1.build("this is content.".to_string()));
println!("{}", f2.build("this is content.".to_string()));
}<|fim_prefix|>// repo: mopp/CodeGarage path: /rust/design_patterns... | code_fim | hard | {
"lang": "rust",
"repo": "mopp/CodeGarage",
"path": "/rust/design_patterns/template_method.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: denoland/deno path: /cli/util/fs.rs
nd https are left intact.
/// Note: This ignores all .git and node_modules folders.
pub fn collect_specifiers(
files: &FilesConfig,
predicate: impl Fn(&Path) -> bool,
) -> Result<Vec<ModuleSpecifier>, AnyError> {
let mut prepared = vec![];
let file_col... | code_fim | hard | {
"lang": "rust",
"repo": "denoland/deno",
"path": "/cli/util/fs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: denoland/deno path: /cli/util/fs.rs
let err_mapper = |err: Error| {
Error::new(
err.kind(),
format!(
"{}, symlink '{}' -> '{}'",
err,
oldpath.display(),
newpath.display()
),
)
};
#[cfg(unix)]
{
use std::os::unix::fs::symlink;
... | code_fim | hard | {
"lang": "rust",
"repo": "denoland/deno",
"path": "/cli/util/fs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ignore_dir_path = root_dir_path.join("ignore");
let ignore_dir_files = ["g.d.ts", ".gitignore"];
create_files(&ignore_dir_path, &ignore_dir_files);
let file_collector = FileCollector::new(|path| {
// exclude dotfiles
path
.file_name()
.and_then(|f| f.to_str... | code_fim | hard | {
"lang": "rust",
"repo": "denoland/deno",
"path": "/cli/util/fs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> do_test!("aba", "a" => vec![((0, 1), true), ((1, 2), false), ((2, 3), true)]);
do_test!("bbbba", "a" => vec![((0, 4), false), ((4, 5), true)]);
do_test!("aabbb", "a" => vec![((0, 1), true), ((1, 2), true), ((2, 5), false)]);
do_test!("aabbb", "ab" => vec![((0, 1), false), (... | code_fim | hard | {
"lang": "rust",
"repo": "huggingface/tokenizers",
"path": "/tokenizers/src/tokenizer/pattern.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: huggingface/tokenizers path: /tokenizers/src/tokenizer/pattern.rs
use crate::utils::SysRegex;
use crate::{Offsets, Result};
use regex::Regex;
/// Pattern used to split a NormalizedString
pub trait Pattern {
/// Slice the given string in a list of pattern match positions, with
/// a bool... | code_fim | hard | {
"lang": "rust",
"repo": "huggingface/tokenizers",
"path": "/tokenizers/src/tokenizer/pattern.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if let Some(connection) = clicked {
// connection.wire = Some(wire_entity);
// std::mem::drop(connections);
// {
// let mut wires = world.write_storage::<Wire>();
// let wire = wires.get_mut(wire_entity).unwrap();
// ... | code_fim | hard | {
"lang": "rust",
"repo": "tawawhite/SIMple-Electronics",
"path": "/src/ui/mouse_click.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tawawhite/SIMple-Electronics path: /src/ui/mouse_click.rs
use crate::components::Connection;
use crate::components::Pos;
use crate::resources::MousePos;
use crate::resources::UIState;
use crate::systems::place_node_sys::PlaceNodeSys;
use specs::prelude::*;
use crate::nodes;
pub fn handle_mouse_... | code_fim | hard | {
"lang": "rust",
"repo": "tawawhite/SIMple-Electronics",
"path": "/src/ui/mouse_click.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn handle_mouse_right_click(world: &mut World) {
// let ui_state = *world.fetch::<UIState>();
crate::systems::place_wire_sys::WirePlaceSys.run_now(world);
// match ui_state {
// UIState::AddingWire {
// connection_entity,
// wire_entity,
// x_pos: None,
// ... | code_fim | hard | {
"lang": "rust",
"repo": "tawawhite/SIMple-Electronics",
"path": "/src/ui/mouse_click.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saromanov/textse path: /src/core/tokenizer.rs
trait BasicTokenizer {
fn process();
}
struct TokenizerPunkt {
text: &'a str,
chars: Vec<'a>,
}
<|fim_suffix|> // splitting of text by pinctuation and defined punctuation
pub fn process(&mut self) -> TokenizerPunkt {
sel... | code_fim | medium | {
"lang": "rust",
"repo": "saromanov/textse",
"path": "/src/core/tokenizer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // splitting of text by pinctuation and defined punctuation
pub fn process(&mut self) -> TokenizerPunkt {
self.text.splitn(2, |x| x == ','||x == '.'||x == ':'||x == ' ').collect()
}
}<|fim_prefix|>// repo: saromanov/textse path: /src/core/tokenizer.rs
trait BasicTokenizer {
fn pr... | code_fim | medium | {
"lang": "rust",
"repo": "saromanov/textse",
"path": "/src/core/tokenizer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: y-ich/A9.rs path: /rust_pyaq/src/lib.rs
#![feature(box_syntax)]
extern crate itertools;
#[cfg(feature = "ponder")]
<|fim_suffix|>;
pub mod coord_convert;
pub mod stone_group;
pub mod board;
pub mod search;<|fim_middle|>#[warn(unused_imports)]
#[macro_use]
extern crate lazy_static;
extern crate ... | code_fim | medium | {
"lang": "rust",
"repo": "y-ich/A9.rs",
"path": "/rust_pyaq/src/lib.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.