text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let data: serde_json::Value = serde_json::from_str(&postmark_template).unwrap();
let (response, response_value): (hyper::Response<hyper::Body>, serde_json::Value) =
match postmark::notify(&data).await {
Ok(value) => value,
Err(error) => panic!("Error: {:#?}", error)... | code_fim | hard | {
"lang": "rust",
"repo": "bsodmike/sentinel-rust",
"path": "/src/monitor/notify.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bsodmike/sentinel-rust path: /src/monitor/notify.rs
use crate::errors::Error;
use crate::services::postmark;
use crate::services::slack;
use hyper::{Body, Response};
pub async fn notify_slack(template: &str) {
let data: serde_json::Value = serde_json::from_str(&template).unwrap();
let (... | code_fim | hard | {
"lang": "rust",
"repo": "bsodmike/sentinel-rust",
"path": "/src/monitor/notify.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn stino_from_nix(ino: libc::ino_t) -> Result<wasi::__wasi_inode_t> {
wasi::__wasi_device_t::try_from(ino).map_err(Into::into)
}
}<|fim_prefix|>// repo: cedric-h/wasmtime path: /crates/wasi-common/src/old/snapshot_0/sys/unix/bsd/mod.rs
pub(crate) mod filetime;
pub(crate) mod ho... | code_fim | hard | {
"lang": "rust",
"repo": "cedric-h/wasmtime",
"path": "/crates/wasi-common/src/old/snapshot_0/sys/unix/bsd/mod.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cedric-h/wasmtime path: /crates/wasi-common/src/old/snapshot_0/sys/unix/bsd/mod.rs
pub(crate) mod filetime;
pub(crate) mod hostcalls_impl;
pub(crate) mod oshandle;
pub(crate) mod host_impl {
use crate::old::snapshot_0::{wasi, Result};
use std::convert::TryFrom;
pub(crate) const O_R... | code_fim | medium | {
"lang": "rust",
"repo": "cedric-h/wasmtime",
"path": "/crates/wasi-common/src/old/snapshot_0/sys/unix/bsd/mod.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn create_ident_expr(&self, column: &str, ty: DatabaseType) -> Expr {
Expr::Ident(self.create_ident(column, ty))
}
}
impl Display for Ident {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
write!(f, "{}", self.seg.join("."))
}
}<|fim_prefix|>// repo: SASUKE40/yuki... | code_fim | medium | {
"lang": "rust",
"repo": "SASUKE40/yukino-dev",
"path": "/query-builder/src/ident.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug)]
pub struct Alias {
pub name: String,
}
impl Alias {
pub fn create_ident(&self, column: &str, ty: DatabaseType) -> Ident {
Ident {
seg: vec![self.name.clone(), column.to_string()],
ty,
}
}
pub fn create_ident_expr(&self, colu... | code_fim | medium | {
"lang": "rust",
"repo": "SASUKE40/yukino-dev",
"path": "/query-builder/src/ident.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SASUKE40/yukino-dev path: /query-builder/src/ident.rs
use crate::{DatabaseType, Expr};
use std::fmt::{Display, Formatter, Result as FmtResult};
<|fim_suffix|>impl Display for Ident {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
write!(f, "{}", self.seg.join("."))
}
}<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "SASUKE40/yukino-dev",
"path": "/query-builder/src/ident.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kosslab-kr/rust path: /src/librustc_trans/cabi_x86.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http... | code_fim | hard | {
"lang": "rust",
"repo": "kosslab-kr/rust",
"path": "/src/librustc_trans/cabi_x86.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for arg in &mut fty.args {
if arg.is_ignore() { continue; }
if arg.ty.kind() == Struct {
arg.make_indirect(ccx);
arg.attrs.set(Attribute::ByVal);
} else {
arg.extend_integer_width_to(32);
}
}
}<|fim_prefix|>// repo: kosslab-kr/rus... | code_fim | hard | {
"lang": "rust",
"repo": "kosslab-kr/rust",
"path": "/src/librustc_trans/cabi_x86.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use glow::*;
pub trait Bindable {
fn bind(&self, gl: &glow::Context);
fn unbind(&self, gl: &glow::Context);
}
pub struct ScopedBind<'a, T: Bindable> {
pub gl: &'a glow::Context,
pub object: &'a T,
}
impl<'a, T: Bindable> ScopedBind<'a, T> {
pub fn new(gl: &'a glow::Cont... | code_fim | medium | {
"lang": "rust",
"repo": "Hperigo/Pira",
"path": "/src/gl_helper/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T: Bindable> ScopedBind<'a, T> {
pub fn new(gl: &'a glow::Context, object: &'a T) -> Self {
object.bind(gl);
Self { gl, object }
}
}
impl<'a, T: Bindable> Drop for ScopedBind<'a, T> {
fn drop(&mut self) {
self.object.unbind(self.gl);
}
}
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "Hperigo/Pira",
"path": "/src/gl_helper/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hperigo/Pira path: /src/gl_helper/mod.rs
pub mod vbo;
pub use self::vbo::Vbo;
pub mod vao;
pub use self::vao::Vao;
pub use self::vao::VertexAttrib;
pub mod stock_shader;
pub use self::stock_shader::StockShader;
pub mod glsl_prog;
pub use self::glsl_prog::GlslProg;
<|fim_suffix|>... | code_fim | hard | {
"lang": "rust",
"repo": "Hperigo/Pira",
"path": "/src/gl_helper/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> type Output = Self;
fn meet(self, other: Self) -> Self {
match (self, other) {
(None, _) => None,
(_, None) => None,
(Some(a), Some(b)) => a.meet(b)
}
}
}
impl<A> Join for Option<A>
where A: Join<Output = Option<A>> {
type Output =... | code_fim | medium | {
"lang": "rust",
"repo": "Foelsgaard/poset.rs",
"path": "/src/lattice.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Foelsgaard/poset.rs path: /src/lattice.rs
pub trait Join<Other = Self>
where Self: PartialOrd<Other> {
type Output;
fn join(self, other: Other) -> Self::Output;
}
pub trait Meet<Other = Self>
where Self: PartialOrd<Other> {
type Output;
<|fim_suffix|> type Output = Se... | code_fim | medium | {
"lang": "rust",
"repo": "Foelsgaard/poset.rs",
"path": "/src/lattice.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aptend/leetcode-rua path: /Rust/src/n0387_first_unique_character_in_a_string.rs
pub fn first_uniq_char(s: String) -> i32 {
let ch_usizes: Vec<_> = s.chars().map(|ch| ch as usize - 97).collect();
let mut i = 0;
let mut counter = [0; 26];
for ch in &ch_usizes {
counter[*ch]... | code_fim | medium | {
"lang": "rust",
"repo": "aptend/leetcode-rua",
"path": "/Rust/src/n0387_first_unique_character_in_a_string.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(0, first_uniq_char("leetcode".to_owned()));
assert_eq!(2, first_uniq_char("loveleetcode".to_owned()));
}<|fim_prefix|>// repo: aptend/leetcode-rua path: /Rust/src/n0387_first_unique_character_in_a_string.rs
pub fn first_uniq_char(s: String) -> i32 {
let ch_usizes: Vec<_> = s.chars(... | code_fim | medium | {
"lang": "rust",
"repo": "aptend/leetcode-rua",
"path": "/Rust/src/n0387_first_unique_character_in_a_string.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn handler(rec: Arc<Mutex<Receiver<String>>>, i: usize){
loop {
{
let val = rec.lock().unwrap().recv_timeout(Duration::from_millis(5000));
match val {
Ok(value) => println!("Argument Received {} by {}", value, i),
_ => {
println!("Timeout Reached {}", i);
break;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "siddharths067/ConcurrentRustScratch",
"path": "/single_channel_mpmc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: siddharths067/ConcurrentRustScratch path: /single_channel_mpmc.rs
use std::sync::mpsc::{Sender, Receiver};
use std::sync::{mpsc, Arc, Mutex};
use std::env;
use std::thread;
use std::time::Duration;
fn main(){
let (tx, rx): (Sender<String>, Receiver<String>) = mpsc::channel();
for arg in env::... | code_fim | medium | {
"lang": "rust",
"repo": "siddharths067/ConcurrentRustScratch",
"path": "/single_channel_mpmc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dimkar3000/exercism path: /rust/minesweeper/src/lib.rs
pub fn annotate(minefield: &[&str]) -> Vec<String> {
if minefield.is_empty() {
return Vec::new();
}
let mut result: Vec<Vec<char>> = minefield.iter().map(|x| x.chars().collect()).collect();
let col_len = result.len();... | code_fim | hard | {
"lang": "rust",
"repo": "Dimkar3000/exercism",
"path": "/rust/minesweeper/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>i][j - 1] == '*' {
count += 1;
}
if j < row_len - 1 && result[i][j + 1] == '*' {
count += 1;
}
if i < col_len - 1 && j > 0 && result[i + 1][j - 1] == '*' {
count += 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "Dimkar3000/exercism",
"path": "/rust/minesweeper/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awski/rust-exercism path: /rust/proverb/src/lib.rs
pub fn build_proverb(list: &[&str]) -> String {
<|fim_suffix|> if !list.is_empty() {
(0..list.len() - 1).for_each(|x| output += format!("For want of a {} the {} was lost.\n", list[x], list[x+1]).as_str());
output += format!("... | code_fim | easy | {
"lang": "rust",
"repo": "awski/rust-exercism",
"path": "/rust/proverb/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !list.is_empty() {
(0..list.len() - 1).for_each(|x| output += format!("For want of a {} the {} was lost.\n", list[x], list[x+1]).as_str());
output += format!("And all for the want of a {}.", list[0]).as_str();
}
output
}<|fim_prefix|>// repo: awski/rust-exercism path: /rust... | code_fim | easy | {
"lang": "rust",
"repo": "awski/rust-exercism",
"path": "/rust/proverb/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
unsafe fn write_reserved_indent(
&mut self,
len: usize,
) -> std::result::Result<(), std::io::Error> {
let _ = len;
Ok(())
}
}
impl WriteExt for &mut BytesWriter {
#[inline(always)]
fn as_mut_buffer_ptr(&mut self) -> *mut u8 {
self... | code_fim | hard | {
"lang": "rust",
"repo": "ijl/orjson",
"path": "/src/serialize/writer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
unsafe fn write_reserved_punctuation(
&mut self,
val: u8,
) -> std::result::Result<(), std::io::Error> {
let _ = val;
Ok(())
}
#[inline]
unsafe fn write_reserved_indent(
&mut self,
len: usize,
) -> std::result::Result<(... | code_fim | hard | {
"lang": "rust",
"repo": "ijl/orjson",
"path": "/src/serialize/writer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ijl/orjson path: /src/serialize/writer.rs
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
use pyo3_ffi::{
PyBytesObject, PyBytes_FromStringAndSize, PyObject, PyVarObject, Py_ssize_t, _PyBytes_Resize,
};
use std::os::raw::c_char;
use std::ptr::NonNull;
const BUFFER_LENGTH: usize = 1024;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "ijl/orjson",
"path": "/src/serialize/writer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Notify the associated task that a future is ready to get polled.
///
/// Futures should use this method to ensure that when a future can make
/// progress as `Task` is notified that it should continue to `poll` the
/// future at a later date.
///
/// Currently it's guarante... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/futures/src/task.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/futures/src/task.rs
// One critical piece of this module's contents are the `TaskData<A>` handles.
// The purpose of this is to conceptually be able to store data in a task,
// allowing it to be accessed within multiple futures at once. F... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/futures/src/task.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
SifVal::Num(numval) => write!(f, "{}", numval),
SifVal::Str(strval) => write!(f, "{}", strval),
SifVal::Bl(blval) => write!(f, "{}", blval),
SifVal::Arr(valvec) => {
let mut contents = String::from("[");
f... | code_fim | hard | {
"lang": "rust",
"repo": "cjkenn/sif",
"path": "/sifc_bytecode/src/sifv.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cjkenn/sif path: /sifc_bytecode/src/sifv.rs
use std::{collections::HashMap, fmt};
#[derive(Debug, Clone, PartialEq)]
pub enum SifVal {
Num(f64),
Str(String),
Bl(bool),
Arr(Vec<SifVal>),
Tab(HashMap<String, SifVal>),
Null,
}
impl SifVal {
pub fn extract_num(&self) ->... | code_fim | hard | {
"lang": "rust",
"repo": "cjkenn/sif",
"path": "/sifc_bytecode/src/sifv.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let g = traversal().with_remote(client);
chapters::all().iter().for_each(|f| {
f(&g).unwrap();
});
Ok(())
}<|fim_prefix|>// repo: wolf4ood/gremlin-rs path: /gremlin-tutorial/src/main.rs
use gremlin_client::{process::traversal::traversal, GremlinClient};
mod chapters;
fn main()... | code_fim | easy | {
"lang": "rust",
"repo": "wolf4ood/gremlin-rs",
"path": "/gremlin-tutorial/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wolf4ood/gremlin-rs path: /gremlin-tutorial/src/main.rs
use gremlin_client::{process::traversal::traversal, GremlinClient};
mod chapters;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = GremlinClient::connect("localhost")?;
<|fim_suffix|> chapters::all().iter().for_e... | code_fim | easy | {
"lang": "rust",
"repo": "wolf4ood/gremlin-rs",
"path": "/gremlin-tutorial/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Fill scope with parameter names:
self.scan_parameters(&args.posonlyargs)?;
self.scan_parameters(&args.args)?;
self.scan_parameters(&args.kwonlyargs)?;
if let Some(name) = &args.vararg {
self.scan_parameter(name)?;
}
if let Some(name) =... | code_fim | hard | {
"lang": "rust",
"repo": "RustPython/RustPython",
"path": "/compiler/codegen/src/symboltable.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustPython/RustPython path: /compiler/codegen/src/symboltable.rs
omprehension,
}
impl fmt::Display for SymbolTableType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
SymbolTableType::Module => write!(f, "module"),
SymbolTableType::Class... | code_fim | hard | {
"lang": "rust",
"repo": "RustPython/RustPython",
"path": "/compiler/codegen/src/symboltable.rs",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Analyze symbols:
for symbol in symbol_table.symbols.values_mut() {
self.analyze_symbol(symbol, symbol_table.typ, sub_tables)?;
}
Ok(())
}
fn analyze_symbol(
&mut self,
symbol: &mut Symbol,
st_typ: SymbolTableType,
sub_... | code_fim | hard | {
"lang": "rust",
"repo": "RustPython/RustPython",
"path": "/compiler/codegen/src/symboltable.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xjump/wyrm path: /src/optim/adam.rs
use super::barrier::{SynchronizationBarrier, SynchronizationBarrierGuard};
use super::Optimizer;
use {numerics, Arr, ParameterNode, Variable};
use ndarray::Axis;
struct AdamParameters<'params> {
value: &'params mut Arr,
m: &'params mut Arr,
v: &'... | code_fim | hard | {
"lang": "rust",
"repo": "xjump/wyrm",
"path": "/src/optim/adam.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sink = parameter.node.gradient.borrow_mut();
if let Some((min, max)) = self.clamp {
sink.clamp(min, max);
}
let param = self.param_fields(parameter);
// Increment number of updates
*param.t = param.t.saturating_add(1);
if sink... | code_fim | hard | {
"lang": "rust",
"repo": "xjump/wyrm",
"path": "/src/optim/adam.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day6, part2)]
pub fn part2(groups: &[Vec<Vec<char>>]) -> usize {
let group_counts = groups.iter().map(|group| {
let answers = group
.iter()
.map(|person| person.iter().cloned().collect::<HashSet<char>>())
.fold(None, |left: Option<HashSet<char>>, right... | code_fim | hard | {
"lang": "rust",
"repo": "MattiasBuelens/advent-of-code-2020",
"path": "/src/day6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MattiasBuelens/advent-of-code-2020 path: /src/day6.rs
use std::collections::HashSet;
#[aoc_generator(day6)]
pub fn input_generator(input: &str) -> Vec<Vec<Vec<char>>> {
input
.split("\n\n")
.map(|group| {
group
.lines()
.map(|perso... | code_fim | hard | {
"lang": "rust",
"repo": "MattiasBuelens/advent-of-code-2020",
"path": "/src/day6.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> LinkedListIter { node: &self.head }
}
}
impl<T> FromIterator<T> for SimpleLinkedList<T> {
fn from_iter<I>(iter: I) -> Self
where
I: IntoIterator<Item = T>,
{
iter.into_iter()
.fold(SimpleLinkedList::new(), |mut list, i| {
list.push(i);
... | code_fim | hard | {
"lang": "rust",
"repo": "attilahorvath/exercism-rust",
"path": "/simple-linked-list/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> FromIterator<T> for SimpleLinkedList<T> {
fn from_iter<I>(iter: I) -> Self
where
I: IntoIterator<Item = T>,
{
iter.into_iter()
.fold(SimpleLinkedList::new(), |mut list, i| {
list.push(i);
list
})
}
}
impl<T> I... | code_fim | hard | {
"lang": "rust",
"repo": "attilahorvath/exercism-rust",
"path": "/simple-linked-list/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: attilahorvath/exercism-rust path: /simple-linked-list/src/lib.rs
use std::iter::FromIterator;
struct Node<T> {
data: T,
next: Option<Box<Node<T>>>,
}
impl<T> Node<T> {
fn new(data: T, next: Option<Box<Node<T>>>) -> Self {
Node { data, next }
}
}
pub struct LinkedListIt... | code_fim | hard | {
"lang": "rust",
"repo": "attilahorvath/exercism-rust",
"path": "/simple-linked-list/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkiefel/fooskill-backend path: /src/true_skill.rs
use std::f64;
use crate::message::Message;
pub enum GameResult {
Won,
Draw,
Lost,
}
/// Implements the TrueSkill ranking algorithm.
pub struct TrueSkill {
beta: f64,
eps: f64,
}
impl TrueSkill {
/// Makes a new TrueSki... | code_fim | hard | {
"lang": "rust",
"repo": "mkiefel/fooskill-backend",
"path": "/src/true_skill.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let left_performance = TrueSkill::pass_from_performance(&left_performances);
let right_performance = TrueSkill::pass_from_performance(&right_performances);
let to_difference_message =
TrueSkill::pass_to_difference(left_performance, right_performance);
let margi... | code_fim | hard | {
"lang": "rust",
"repo": "mkiefel/fooskill-backend",
"path": "/src/true_skill.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> std::mem::forget(d);
}
println!("left:");
for i in ori.iter() {
println!("{:?}", i);
}
let mut ori = vec!["0".to_string(), String::from("1"), String::from("2"), String::from("3"), String::from("4")];
ori.drain(1..3);
for i in ori {
println!("{}", i);
... | code_fim | medium | {
"lang": "rust",
"repo": "jamesmarva/Head-First-Rust",
"path": "/ch20/s6/s6d3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamesmarva/Head-First-Rust path: /ch20/s6/s6d3/src/main.rs
fn main() {
let mut ori = vec!["0".to_string(), String::from("1"), String::from("2"), String::from("3"), String::from("4")];
{
let mut d = ori.drain(1..3);
let s : Option<String> = d.next();
println!("{:?... | code_fim | medium | {
"lang": "rust",
"repo": "jamesmarva/Head-First-Rust",
"path": "/ch20/s6/s6d3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const MUT_COUNT_ERR_02 :&str = r#"#![allow(unused_mut)]
#![allow(unused_variables)]
pub fn main() {
let mut instance = vec![33, 42u8];
let first_immut_ref = &instance; // immutable reference
let second_mut_ref = &mut instance; // mutable reference
println!("{:?}", first_immut_ref);
}
"... | code_fim | hard | {
"lang": "rust",
"repo": "cnruby/learn-rust-by-crates",
"path": "/hello-borrowing/bin-hello/src/features/rs_files/mut_base_mut_count.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cnruby/learn-rust-by-crates path: /hello-borrowing/bin-hello/src/features/rs_files/mut_base_mut_count.rs
pub const MUT_COUNT_OK :&str = r#"#![allow(unused_mut)]
#![allow(unused_variables)]
pub fn main() {
let instance = vec![33u8, 42];
let first_ref = &instance; // immutable reference
... | code_fim | hard | {
"lang": "rust",
"repo": "cnruby/learn-rust-by-crates",
"path": "/hello-borrowing/bin-hello/src/features/rs_files/mut_base_mut_count.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/tests/winrt/simple/tests/test.rs
use test_winrt_simple::*;
use windows::core::*;
use Component::*;
<|fim_suffix|> Ok(())
}
}
#[test]
fn test() -> Result<()> {
let class = Simple::Class::new()?;
class.Method()?;
let interface: Si... | code_fim | medium | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/tests/winrt/simple/tests/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let class = Simple::Class::new()?;
class.Method()?;
let interface: Simple::IInterface = Interface().into();
interface.Method()?;
let delegate = Simple::Delegate::new(|| Ok(()));
delegate.Invoke()?;
let _struct = Simple::Struct { First: 1, Second: 2 };
let _enum = Simple... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/tests/winrt/simple/tests/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Zengor/adventofcode2020 path: /rust/src/day02.rs
struct Policy {
min: usize,
max: usize,
c: char,
}
impl Policy {
fn validate_p1(&self, pass: &str) -> bool {
let count = pass.chars().filter(|c| *c == self.c).count();
count >= self.min && count <= self.max
}
... | code_fim | medium | {
"lang": "rust",
"repo": "Zengor/adventofcode2020",
"path": "/rust/src/day02.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn part1(input: &str) -> usize {
input
.lines()
.map(parse_policy_pass)
.filter(|(pol, pass)| pol.validate_p1(pass))
.count()
}
pub fn part2(input: &str) -> usize {
input
.lines()
.map(parse_policy_pass)
.filter(|(pol, pass)| pol.validate... | code_fim | hard | {
"lang": "rust",
"repo": "Zengor/adventofcode2020",
"path": "/rust/src/day02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: livinlefevreloca/chat path: /src/errors.rs
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub struct ChatError {
kind: ChatErrorKind
}
impl ChatError {
pub fn new(kind: ChatErrorKind) -> Self {
Self { kind }
}
}
<|fim_suffix|> write!(f,"{}", self.kind.get_mes... | code_fim | medium | {
"lang": "rust",
"repo": "livinlefevreloca/chat",
"path": "/src/errors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f,"{}", self.kind.get_message())
}
}
impl Error for ChatError {
fn description(&self) -> &str {
&self.kind.get_message()
}
}
#[derive(Debug)]
pub enum ChatErrorKind {
RemoveClientError(&'static str),
}
impl ChatErrorKind {
fn get_message(&self) -> &'static st... | code_fim | medium | {
"lang": "rust",
"repo": "livinlefevreloca/chat",
"path": "/src/errors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The prompt suggests that I might be able to do better by myself. So, a wild guess:
//
// What if the elephant just opens up the best valves I wouldn't have time for?
let elegraph = {
let mut g = self.clone();
for action in best.path.0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "jdkaplan/advent-of-code",
"path": "/2022/src/bin/day16.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> best.flow + elebest.flow
}
}
#[derive(Debug, Clone)]
struct ShortestPath<V> {
nodes: Vec<V>,
}
fn all_pairs_shortest_paths<V>(
nodes: Vec<V>,
edges: HashMap<(V, V), u64>,
) -> HashMap<(V, V), Option<ShortestPath<V>>>
where
V: Eq + std::hash::Hash + Copy + core::fmt::Debug,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "jdkaplan/advent-of-code",
"path": "/2022/src/bin/day16.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jdkaplan/advent-of-code path: /2022/src/bin/day16.rs
use std::{
collections::{BinaryHeap, HashMap, HashSet},
str::FromStr,
};
use regex::Regex;
const INPUT: &str = include_str!("../../input/day16.txt");
fn main() {
let graph = Graph::parse(INPUT);
println!("{}", graph.max_flo... | code_fim | hard | {
"lang": "rust",
"repo": "jdkaplan/advent-of-code",
"path": "/2022/src/bin/day16.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: decentriq/rustlearn path: /src/multiclass/mod.rs
//! Utilities for mutliclass classifiers.
use std::cmp::{Ordering, PartialOrd};
use std::f32;
use std::iter::Iterator;
use array::dense::*;
use array::sparse::*;
use array::traits::*;
use traits::*;
use crossbeam;
pub struct OneVsRest<'a> {
... | code_fim | hard | {
"lang": "rust",
"repo": "decentriq/rustlearn",
"path": "/src/multiclass/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut model_idx = None;
for (idx, label) in self.class_labels.iter().enumerate() {
if let Some(Ordering::Equal) = class_label.partial_cmp(label) {
model_idx = Some(idx);
}
}
if let Some(idx) = model_idx {
self.class_la... | code_fim | hard | {
"lang": "rust",
"repo": "decentriq/rustlearn",
"path": "/src/multiclass/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(debug_assertions))]
#[cfg(unix)]
const PLUGINS_PATH: &str = "./target/release";
fn main() -> Result<(), Box<dyn Error>> {
let libraries = scan_all_libraries(PLUGINS_PATH)?;
for library in libraries {
let plugin = library?;
let demo_plugin = plugin.library.to_demo_plugin... | code_fim | medium | {
"lang": "rust",
"repo": "Nejat/rust-dylib-sandbox",
"path": "/app/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nejat/rust-dylib-sandbox path: /app/src/main.rs
extern crate libloading as lib;
use std::{
error::Error,
result::Result,
};
use plugin_model::ConvertToPlugin;
use plugin_system::scan_all_libraries;
<|fim_suffix|> for library in libraries {
let plugin = library?;
let... | code_fim | hard | {
"lang": "rust",
"repo": "Nejat/rust-dylib-sandbox",
"path": "/app/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use resource::Resource;
pub use unreleasable_vector::UnreleasableVector;<|fim_prefix|>// repo: g2xpf/ecs-rs path: /src/lib/data_types.rs
pub mod cached_vec;
pub mod error;
pub mod lazy_vector;
pub mod resource;
pub mod stack;
pub mod unreleasable_vector;
pub use cached_vec::Cache<|fim_middle|>dVec;
pub... | code_fim | medium | {
"lang": "rust",
"repo": "g2xpf/ecs-rs",
"path": "/src/lib/data_types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: g2xpf/ecs-rs path: /src/lib/data_types.rs
pub mod cached_vec;
pub mod error;
pub mod lazy_vector;
pub mod resource;
pub mod stack;
pub mod unreleasable_vector;
pub use cached_vec::Cache<|fim_suffix|> use resource::Resource;
pub use unreleasable_vector::UnreleasableVector;<|fim_middle|>dVec;
pub... | code_fim | medium | {
"lang": "rust",
"repo": "g2xpf/ecs-rs",
"path": "/src/lib/data_types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug,Copy,Clone,Eq,PartialEq)]
pub enum ThreadSource{
Supervisor=0,
Render=1,
Process=2,
Controller=3
}
impl std::fmt::Display for ThreadSource{
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self{
ThreadSource::Supervisor => writ... | code_fim | medium | {
"lang": "rust",
"repo": "TrionProg/client",
"path": "/src/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TrionProg/client path: /src/types.rs
use std;
pub use std::time::SystemTime as Time;
pub use std::time::Duration;
pub use image::{GrayImage, GrayAlphaImage, RgbImage, RgbaImage};
pub type BinaryData=Vec<u8>;
#[derive(Debug,Copy,Clone,Eq,PartialEq)]
pub enum ThreadSource{
Supervisor=0,
... | code_fim | medium | {
"lang": "rust",
"repo": "TrionProg/client",
"path": "/src/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn accent(team: u8) -> [f32; 4] {
match team % 8 {
0 => RED,
1 => BLUE,
2 => RED,
3 => BLUE,
4 => RED,
5 => GRAY,
6 => BLUE,
7 => GRAY,
_ => panic!("wtf remainder 8??"),
}
}
pub fn soft(color: [f32; 4]) -> [f32; 4] {
... | code_fim | hard | {
"lang": "rust",
"repo": "qfeys/LD41",
"path": "/src/color.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qfeys/LD41 path: /src/color.rs
const BLUE: [f32; 4] = [0.0, 0.0, 1.0, 1.0];
const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0];
const GREEN: [f32; 4] = [0.0, 1.0, 0.0, 1.0];
const YELLOW: [f32; 4] = [1.0, 1.0, 0.0, 1.0];
const CYAN: [f32; 4] = [0.0, 1.0, 1.0, 1.0];
const MAGENTA: [f32; 4] = [1.0, 0.0, 1... | code_fim | hard | {
"lang": "rust",
"repo": "qfeys/LD41",
"path": "/src/color.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: engwarrior/ckb-cli path: /src/subcommands/mod.rs
pub mod account;
pub mod api_server;
pub mod dao;
pub mod mock_tx;
pub mod molecule;
pub mod rpc;
#[cfg(unix)]
pub mod tui;
pub mod tx;
pub mod util;
pub mod wallet;
<|fim_suffix|>pub use account::AccountSubCommand;
pub use api_server::ApiServerS... | code_fim | medium | {
"lang": "rust",
"repo": "engwarrior/ckb-cli",
"path": "/src/subcommands/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
matches: &ArgMatches,
format: OutputFormat,
color: bool,
debug: bool,
) -> Result<String, String>;
}<|fim_prefix|>// repo: engwarrior/ckb-cli path: /src/subcommands/mod.rs
pub mod account;
pub mod api_server;
pub mod dao;
pub mod mock_tx;
pub mod mol... | code_fim | medium | {
"lang": "rust",
"repo": "engwarrior/ckb-cli",
"path": "/src/subcommands/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ht32-rs/ht32-rs-nightlies path: /ht32f5xxxx/src/ht32f59741/sci0.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - SCI_CR"]
pub sci_cr: SCI_CR,
#[doc = "0x04 - SCI_SR"]
pub sci_sr: SCI_SR,
#[doc = "0x08 - SCI_CCR"]
pub sci_ccr: SCI_CCR,
... | code_fim | hard | {
"lang": "rust",
"repo": "ht32-rs/ht32-rs-nightlies",
"path": "/ht32f5xxxx/src/ht32f59741/sci0.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> alias for `Reg<SCI_IPR_SPEC>`"]
pub type SCI_IPR = crate::Reg<sci_ipr::SCI_IPR_SPEC>;
#[doc = "SCI_IPR"]
pub mod sci_ipr;
#[doc = "SCI_TXB (rw) register accessor: an alias for `Reg<SCI_TXB_SPEC>`"]
pub type SCI_TXB = crate::Reg<sci_txb::SCI_TXB_SPEC>;
#[doc = "SCI_TXB"]
pub mod sci_txb;
#[doc = "SCI_RXB ... | code_fim | hard | {
"lang": "rust",
"repo": "ht32-rs/ht32-rs-nightlies",
"path": "/ht32f5xxxx/src/ht32f59741/sci0.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rucoder/leptonica-sys path: /build.rs
extern crate bindgen;
use std::env;
use std::path::PathBuf;
#[cfg(windows)]
use vcpkg;
#[cfg(windows)]
fn find_leptonica_system_lib() -> Option<String> {
let lib = vcpkg::Config::new().find_package("leptonica").unwrap();
let include = lib
... | code_fim | medium | {
"lang": "rust",
"repo": "rucoder/leptonica-sys",
"path": "/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let clang_extra_include = find_leptonica_system_lib();
let mut bindings = bindgen::Builder::default().header("wrapper.h");
if let Some(include_path) = clang_extra_include {
bindings = bindings.clang_arg(format!("-I{}", include_path));
}
let bindings = bindings
.parse... | code_fim | hard | {
"lang": "rust",
"repo": "rucoder/leptonica-sys",
"path": "/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(e) = client.start().await {
warn!("Failed to login, is the token correct?\n{}", e);
}
}<|fim_prefix|>// repo: Jirubizu/rust-discord-bot-template path: /src/bot.rs
use crate::services::{config::Config, database};
use events::Handler;
use log::warn;
use serenity::{framework::stan... | code_fim | hard | {
"lang": "rust",
"repo": "Jirubizu/rust-discord-bot-template",
"path": "/src/bot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jirubizu/rust-discord-bot-template path: /src/bot.rs
use crate::services::{config::Config, database};
use events::Handler;
use log::warn;
use serenity::{framework::standard::StandardFramework, prelude::TypeMapKey, Client};
mod commands;
mod events;
mod utils;
<|fim_suffix|> let db_client = ... | code_fim | hard | {
"lang": "rust",
"repo": "Jirubizu/rust-discord-bot-template",
"path": "/src/bot.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let mut data = client.data.write().await;
data.insert::<Config>(config);
data.insert::<database::DataBase>(db_client);
}
if let Err(e) = client.start().await {
warn!("Failed to login, is the token correct?\n{}", e);
}
}<|fim_prefix|>// repo: Jirubizu/rust... | code_fim | hard | {
"lang": "rust",
"repo": "Jirubizu/rust-discord-bot-template",
"path": "/src/bot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mod movies;
pub mod ratings;
pub mod users;<|fim_prefix|>// repo: white-leaf-devs/recommendation-system path: /controllers/movie-lens/src/models.rs
// Copyright (c) 2020 White Leaf
//
// This<|fim_middle|> software is released under the MIT License.
// https://opensource.org/licenses/MIT
pub | code_fim | medium | {
"lang": "rust",
"repo": "white-leaf-devs/recommendation-system",
"path": "/controllers/movie-lens/src/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: white-leaf-devs/recommendation-system path: /controllers/movie-lens/src/models.rs
// Copyright (c) 2020 White Leaf
//
// This<|fim_suffix|>
// https://opensource.org/licenses/MIT
pub mod movies;
pub mod ratings;
pub mod users;<|fim_middle|> software is released under the MIT License. | code_fim | easy | {
"lang": "rust",
"repo": "white-leaf-devs/recommendation-system",
"path": "/controllers/movie-lens/src/models.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let code = easy.response_code().unwrap();
if code != 200 {
return Err(MWError::ProcessError {
name: "Generic".into(),
error: format!("Error fetching URL with curl: {}", url),
});
}
let body = easy.get_ref();
Ok(String::from_utf8_lossy(&body.0).i... | code_fim | hard | {
"lang": "rust",
"repo": "hexjelly/haze",
"path": "/src/helpers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hexjelly/haze path: /src/helpers.rs
use curl::easy::{Easy2, Handler, WriteError};
use haze::middleware::MWError;
struct Collector(Vec<u8>);
<|fim_suffix|> let code = easy.response_code().unwrap();
if code != 200 {
return Err(MWError::ProcessError {
name: "Generic".in... | code_fim | hard | {
"lang": "rust",
"repo": "hexjelly/haze",
"path": "/src/helpers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 4nickel/flink path: /server/src/util/download.rs
use rocket::{
response::{self, NamedFile, Responder, Response},
Request,
};
<|fim_suffix|> Response::build()
.merge(self.0.respond_to(req)?)
.raw_header(
"Content-Disposition",
... | code_fim | medium | {
"lang": "rust",
"repo": "4nickel/flink",
"path": "/server/src/util/download.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Response::build()
.merge(self.0.respond_to(req)?)
.raw_header(
"Content-Disposition",
format!("attachment; filename=\"{}\"", self.1),
)
.ok()
}
}<|fim_prefix|>// repo: 4nickel/flink path: /server/src/util/download... | code_fim | medium | {
"lang": "rust",
"repo": "4nickel/flink",
"path": "/server/src/util/download.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/neptune path: /src/lib.rs
#![allow(dead_code)]
pub use crate::poseidon::Poseidon;
use crate::round_constants::generate_constants;
pub use error::Error;
use ff::{Field, PrimeField, ScalarEngine};
pub use paired::bls12_381::Fr as Scalar;
use paired::bls12_381::FrRepr;
/// Poseidon circui... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/neptune",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>const SBOX: u8 = 1; // x^5
const FIELD: u8 = 1; // Gf(p)
fn round_constants<E: ScalarEngine>(arity: usize) -> Vec<E::Fr> {
let t = arity + 1;
let (full_rounds, partial_rounds) = round_numbers(arity);
let r_f = full_rounds as u16;
let r_p = partial_rounds as u16;
let fr_num_bits = E... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/neptune",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bieganski/distributed path: /dsassignment01/public-tests/tests/smoke_system_setup.rs
use assignment_1_solution::{setup_system, Configuration, System, SystemMessageContent};
use crossbeam_channel::unbounded;
use ntest::timeout;
use std::collections::HashSet;
use std::iter::FromIterator;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "bieganski/distributed",
"path": "/dsassignment01/public-tests/tests/smoke_system_setup.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // then
rx.recv().unwrap();
let first_send = Instant::now();
rx.recv().unwrap();
let duration_millis = Instant::now().duration_since(first_send).as_millis();
assert!(duration_millis >= 400 && duration_millis <= 600)
}<|fim_prefix|>// repo: bieganski/distributed path: /dsassignment... | code_fim | hard | {
"lang": "rust",
"repo": "bieganski/distributed",
"path": "/dsassignment01/public-tests/tests/smoke_system_setup.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.into_iter()
.perimeter()
.map(|(a, b)| Edge::new(a, b))
.collect()
}
}
impl<T> IntoTrigons for Trigon<T> {
type Output = ArrayVec<Trigon<Self::Vertex>, 1>;
fn into_trigons(self) -> Self::Output {
ArrayVec::from([self])
}
}
impl<T>... | code_fim | hard | {
"lang": "rust",
"repo": "olson-sean-k/plexus",
"path": "/plexus/src/primitive/decompose.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: olson-sean-k/plexus path: /plexus/src/primitive/decompose.rs
//! Decomposition and tessellation.
//!
//! The [`Decompose`] iterator uses various traits to decompose and tessellate
//! iterators of topological structures.
//!
//! This module provides two kinds of decomposition traits: conversions... | code_fim | hard | {
"lang": "rust",
"repo": "olson-sean-k/plexus",
"path": "/plexus/src/primitive/decompose.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ArrayVec::from([self])
}
}
impl<T> IntoTrigons for Tetragon<T>
where
T: Clone,
{
type Output = ArrayVec<Trigon<Self::Vertex>, 2>;
fn into_trigons(self) -> Self::Output {
let [a, b, c, d] = self.into_array();
ArrayVec::from([Trigon::new(a.clone(), b, c.clone()), Tr... | code_fim | hard | {
"lang": "rust",
"repo": "olson-sean-k/plexus",
"path": "/plexus/src/primitive/decompose.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let m = p.start();
method_sig(p);
m.complete(p, INTERFACE_ITEM);
}<|fim_prefix|>// repo: DerDrodt/abs-rust path: /crates/parser/src/grammar/items/interfaces.rs
use crate::{grammar::ty_path, grammar::Parser, parser::Marker, SyntaxKind::*, T};
use super::method_sig;
pub(crate) fn interface(p:... | code_fim | medium | {
"lang": "rust",
"repo": "DerDrodt/abs-rust",
"path": "/crates/parser/src/grammar/items/interfaces.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn interface_item(p: &mut Parser) {
let m = p.start();
method_sig(p);
m.complete(p, INTERFACE_ITEM);
}<|fim_prefix|>// repo: DerDrodt/abs-rust path: /crates/parser/src/grammar/items/interfaces.rs
use crate::{grammar::ty_path, grammar::Parser, parser::Marker, SyntaxKind::*, T};
use super::met... | code_fim | hard | {
"lang": "rust",
"repo": "DerDrodt/abs-rust",
"path": "/crates/parser/src/grammar/items/interfaces.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DerDrodt/abs-rust path: /crates/parser/src/grammar/items/interfaces.rs
use crate::{grammar::ty_path, grammar::Parser, parser::Marker, SyntaxKind::*, T};
<|fim_suffix|>fn extends_list(p: &mut Parser) {
let m = p.start();
p.bump(T![extends]);
ty_path(p);
while p.eat(T![,]) {
... | code_fim | hard | {
"lang": "rust",
"repo": "DerDrodt/abs-rust",
"path": "/crates/parser/src/grammar/items/interfaces.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jesskfullwood/frunk path: /derives/src/common.rs
use proc_macro::TokenStream;
use quote::ToTokens;
use quote::__rt::Span;
use syn;
use syn::{DeriveInput, Ident};
/// Parses a TokenStream (usually received as input into a
/// custom derive function), into a syn MacroInput AST,
/// which is nice.... | code_fim | medium | {
"lang": "rust",
"repo": "jesskfullwood/frunk",
"path": "/derives/src/common.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Given a identifiers, creates an AST for building an HList (HCons)
/// using those identifiers as accessors.
///
/// Subsequently, this same function can be used for pattern matching too!
pub fn build_hcons_constr(accessors: &Vec<Ident>) -> impl ToTokens {
match accessors.len() {
0 => quote... | code_fim | medium | {
"lang": "rust",
"repo": "jesskfullwood/frunk",
"path": "/derives/src/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
static ref $name: ::regex::Regex = ::regex::Regex::new($re).unwrap();
}
};
}<|fim_prefix|>// repo: irbis-labs/rsmorphy path: /src/macros.rs
#[macro_export]
macro_rules! regex {
($name:ide<|fim_middle|>nt, $re:expr) => {
lazy_static::lazy_static! | code_fim | easy | {
"lang": "rust",
"repo": "irbis-labs/rsmorphy",
"path": "/src/macros.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:regex::Regex::new($re).unwrap();
}
};
}<|fim_prefix|>// repo: irbis-labs/rsmorphy path: /src/macros.rs
#[macro_export]
macro_rules! regex {
($name:ide<|fim_middle|>nt, $re:expr) => {
lazy_static::lazy_static! {
static ref $name: ::regex::Regex = : | code_fim | medium | {
"lang": "rust",
"repo": "irbis-labs/rsmorphy",
"path": "/src/macros.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: irbis-labs/rsmorphy path: /src/macros.rs
#[macro_export]
macro_rules! regex {
($name:ide<|fim_suffix|>:regex::Regex::new($re).unwrap();
}
};
}<|fim_middle|>nt, $re:expr) => {
lazy_static::lazy_static! {
static ref $name: ::regex::Regex = : | code_fim | medium | {
"lang": "rust",
"repo": "irbis-labs/rsmorphy",
"path": "/src/macros.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: c0ldch0c0l8/iced_practice path: /src/slider.rs
use iced::{Sandbox, Column, Slider, slider, Text};
#[derive(Default)]
pub struct SliderApp {
value: i32,
state: slider::State
}
#[derive(Debug, Clone)]
pub enum Message {
SliderValueChanged(i32)
}
impl Sandbox for SliderApp {
... | code_fim | medium | {
"lang": "rust",
"repo": "c0ldch0c0l8/iced_practice",
"path": "/src/slider.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Column::new()
.padding([20, 300])
.push(
Text::new("How old are you?")
.size(70)
)
.push(
Slider::new(
&mut self.state,
0..=100,
self.value,
Message::SliderValueChang... | code_fim | medium | {
"lang": "rust",
"repo": "c0ldch0c0l8/iced_practice",
"path": "/src/slider.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some(x) = a.pop() {
println!("x: {}", x);
}
println!("vector a length: {}", a.len());
}
pub fn run() {
println!("Running vectors");
vectors();
}<|fim_prefix|>// repo: mishaszu/RUST-INTRO path: /src/ex1/arrays_vectors_strings/src/vectors.rs
fn vectors() {
println... | code_fim | hard | {
"lang": "rust",
"repo": "mishaszu/RUST-INTRO",
"path": "/src/ex1/arrays_vectors_strings/src/vectors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(z) = a.get(2) {
println!("if let a at 5 position = {}", z)
} else {
println!("nothing here");
}
for i in &a {
println!("value: {}", i);
}
println!("vector a length: {}", a.len());
let last_element = a.pop();
println!("last elemenet: {:?... | code_fim | medium | {
"lang": "rust",
"repo": "mishaszu/RUST-INTRO",
"path": "/src/ex1/arrays_vectors_strings/src/vectors.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.