text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let routes = health_route.or(ws_route).with(
warp::cors()
.allow_any_origin()
.allow_headers(vec!["Content-Type"])
.allow_methods(vec!["GET", "POST", "DELETE"]),
);
let port: u16 = env::var("PORT")
.unwrap_or_else(|_| String::from("8000"))
... | code_fim | hard | {
"lang": "rust",
"repo": "ndbaker1/BONK",
"path": "/server/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ndbaker1/BONK path: /server/src/main.rs
use std::collections::HashMap;
use std::env;
use std::sync::Arc;
use tokio::sync::RwLock;
use warp::Filter;
mod data_types;
mod game_engine;
mod handler;
mod session_types;
mod shared_types;
mod ws;
#[tokio::main]
async fn main() {
let clients: data_... | code_fim | hard | {
"lang": "rust",
"repo": "ndbaker1/BONK",
"path": "/server/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mashariqk/rustbigram path: /src/main.rs
use bigram::{run, Config};
use std::{env, process};
<|fim_suffix|> let args: Vec<String> = env::args().collect();
let config = Config::new(&args).unwrap_or_else(|err| {
println!("Error parsing: {}", err);
process::exit(9);
});
... | code_fim | easy | {
"lang": "rust",
"repo": "mashariqk/rustbigram",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: montanonic/computour path: /src/lispy/parser.rs
use std::{
fmt::{self, Display},
rc::Rc,
str::{pattern::Pattern, FromStr},
};
pub struct Parser {
tokenizer: Tokenizer,
}
impl Parser {
pub fn new(source: &str) -> Self {
Self {
tokenizer: Tokenizer::new(sou... | code_fim | hard | {
"lang": "rust",
"repo": "montanonic/computour",
"path": "/src/lispy/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use strum_macros::{AsRefStr, EnumString};
#[derive(Debug, PartialEq, Eq, Clone, EnumString, AsRefStr)]
#[strum(serialize_all = "lowercase")]
pub enum Token<'a> {
Word(&'a str),
Int64(i64),
#[strum(serialize = "(")]
LParen,
#[strum(serialize = ")")]
RParen,
// Keywords:
Ad... | code_fim | hard | {
"lang": "rust",
"repo": "montanonic/computour",
"path": "/src/lispy/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jD91mZM2/pseudoterm path: /src/sys/unix/winsize.rs
use ::Winsize;
use super::*;
use std::{
io,
mem,
os::unix::io::RawFd
};
pub struct WinsizeSetter(RawFd);
impl WinsizeSetter {
pub fn new(fd: RawFd) -> io::Result<Self> {
Ok(WinsizeSetter(fd))
}
pub fn get(&mut s... | code_fim | hard | {
"lang": "rust",
"repo": "jD91mZM2/pseudoterm",
"path": "/src/sys/unix/winsize.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bc::winsize {
ws_row: winsize.rows,
ws_col: winsize.cols,
ws_xpixel: 0,
ws_ypixel: 0
};
e(libc::ioctl(self.0, libc::TIOCSWINSZ, &winsize))?;
Ok(())
}
}
}<|fim_prefix|>// repo: jD91mZM2/pseudoter... | code_fim | hard | {
"lang": "rust",
"repo": "jD91mZM2/pseudoterm",
"path": "/src/sys/unix/winsize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ges;
pub mod android_mk;
pub mod config;<|fim_prefix|>// repo: raftario/QuestPackageManager-Rust path: /src/data/mod.rs
pub mod package;
pub mod dependency;
pub mod shared_dependency;
pub mod shared_p<|fim_middle|>ackage;
pub mod mod_json;
pub mod qpacka | code_fim | easy | {
"lang": "rust",
"repo": "raftario/QuestPackageManager-Rust",
"path": "/src/data/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raftario/QuestPackageManager-Rust path: /src/data/mod.rs
pub mod package;
pub mod dependency;
pub<|fim_suffix|>ackage;
pub mod mod_json;
pub mod qpackages;
pub mod android_mk;
pub mod config;<|fim_middle|> mod shared_dependency;
pub mod shared_p | code_fim | easy | {
"lang": "rust",
"repo": "raftario/QuestPackageManager-Rust",
"path": "/src/data/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
///Field `TSS` writer - Timestamp Select
pub struct TSS_W<'a> {
w: &'a mut W,
}
impl<'a> TSS_W<'a> {
///Writes raw bits to the field
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !0x03) | (value as u32 & 0x... | code_fim | hard | {
"lang": "rust",
"repo": "romixlab/stcan",
"path": "/src/pac/h7/fdcan/tscc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: romixlab/stcan path: /src/pac/h7/fdcan/tscc.rs
///Register `TSCC` reader
pub struct R(crate::R<TSCC_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<TSCC_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<TSCC_SPEC>> for... | code_fim | hard | {
"lang": "rust",
"repo": "romixlab/stcan",
"path": "/src/pac/h7/fdcan/tscc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn end_of_ring(ring: u32) -> u32 {
((1 + 2 * ring) as u32).pow(2)
}
fn start_of_ring(ring: u32) -> u32 {
match ring {
0 => 1,
n => end_of_ring(n - 1) + 1,
}
}
fn ring(square: u32) -> u32 {
// highest value in ring 0 is 1 (1^2)
// highest value in ring 1 is 9 (3^2)
... | code_fim | medium | {
"lang": "rust",
"repo": "barometz/adventofcode-2017",
"path": "/day-032-spiralmemory/src/position.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for ring in 0.. {
if square <= end_of_ring(ring) {
return ring;
}
}
panic!("Out of bounds: square {}", square);
}
impl PartialOrd for Position {
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
match self.ring.cmp(&other.ring) {
... | code_fim | medium | {
"lang": "rust",
"repo": "barometz/adventofcode-2017",
"path": "/day-032-spiralmemory/src/position.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: barometz/adventofcode-2017 path: /day-032-spiralmemory/src/position.rs
use std::cmp;
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct Position {
pub ring: u32,
pub offset: u32,
}
impl Position {
pub fn new(ring: u32, offset: u32) -> Self {
Position { ring, offset }
... | code_fim | hard | {
"lang": "rust",
"repo": "barometz/adventofcode-2017",
"path": "/day-032-spiralmemory/src/position.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: csnover/ritual path: /ritual/src/tests/cpp_parser.rs
Magic* x);
bool func2(const Magic&);
",
);
assert_eq!(data.types.len(), 1);
assert_eq!(data.types[0].path, CppPath::from_good_str("Magic"));
assert!(data.types[0].kind.is_class());
assert!(data.bases.is_emp... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/ritual",
"path": "/ritual/src/tests/cpp_parser.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = run_parser(
"
class MyClass {
public:
int func1(int x);
private:
int m_x;
};
",
);
assert_eq!(data.types.len(), 1);
assert_eq!(data.types[0].path, CppPath::from_good_str("MyClass"));
assert!(data.types[0... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/ritual",
"path": "/ritual/src/tests/cpp_parser.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn derived_class_simple_private() {
let data = run_parser("class Base {}; class Derived : Base {};");
assert_eq!(data.types.len(), 2);
assert_eq!(data.types[0].path, CppPath::from_good_str("Base"));
assert_eq!(data.types[1].path, CppPath::from_good_str("Derived"));
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/ritual",
"path": "/ritual/src/tests/cpp_parser.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let server = ApllodbServer::default();
let mut rl = ReadLine::default();
let cmd_processor = CmdProcessor::new(&server);
let mut session = Session::default();
loop {
match rl.readline() {
Ok(cmd) => {
session = match cmd_processor.process(session, ... | code_fim | hard | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-cli/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match rl.readline() {
Ok(cmd) => {
session = match cmd_processor.process(session, &cmd).await {
Ok(sess) => {
let _ = rl.add_history(&cmd);
sess
}
Err(... | code_fim | hard | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-cli/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-cli/src/main.rs
#![deny(missing_debug_implementations)]
//! apllodb's CLI client.
#[macro_use]
extern crate derive_new;
mod cmd_processor;
mod shell;
use apllodb_server::{ApllodbServer, Session};
use cmd_processor::CmdProcessor;
use rustyline::error::ReadlineEr... | code_fim | hard | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-cli/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("a <distance> ln = {}", a.distance(&ln));
println!("a <distance> ln = {}", a.distance(&ln));
println!("a <distance> pt = {}", a.distance(&pt));
println!("pt <distance> ln = {}", pt.distance(&ln));
let mut pts : Vec<&dyn Index<usize, Output=f64>> = vec![];
let (a, b) = ... | code_fim | hard | {
"lang": "rust",
"repo": "intdxdt/geom-2d",
"path": "/example/01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: intdxdt/geom-2d path: /example/01.rs
use geom_2d::{Polygon, Geometry, LineString, Point, PointZ};
use std::ops::Index;
fn main() {
let a: Polygon = "POLYGON (( 450 600, 450 725, 575 725, 575 600, 450 600 ))".into();
let b: Polygon = "POLYGON (( 575 650, 575 775, 650 775, 650 650, 575 65... | code_fim | hard | {
"lang": "rust",
"repo": "intdxdt/geom-2d",
"path": "/example/01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pts : Vec<&dyn Index<usize, Output=f64>> = vec![];
let (a, b) = (Point::new(3., 4.), Point::new(3.2, 4.7));
let (c, d) = (PointZ::new(31., 4., 9.7), PointZ::new(3.2, 4.7, 9.3));
pts.push(&a);
pts.push(&b);
pts.push(&c);
pts.push(&d);
println!("{}", pts.len());
p... | code_fim | hard | {
"lang": "rust",
"repo": "intdxdt/geom-2d",
"path": "/example/01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut final_img: Vec<Vec<u32>> = img[0].clone();
for i in 1..img.len() {
let layer = &img[i];
for (y, row) in layer.iter().enumerate() {
for (x, colour) in row.iter().enumerate() {
if final_img[y][x] == 2 {
final_img[y][x] = *colour... | code_fim | hard | {
"lang": "rust",
"repo": "nesv/advent-of-code",
"path": "/2019/src/bin/08.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nesv/advent-of-code path: /2019/src/bin/08.rs
use aoc::Input;
use std::io::{Error, ErrorKind, Result};
fn main() -> Result<()> {
let in_file: String = match std::env::args().nth(1) {
Some(v) => v,
None => {
return Err(Error::new(
ErrorKind::Invali... | code_fim | hard | {
"lang": "rust",
"repo": "nesv/advent-of-code",
"path": "/2019/src/bin/08.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Decode the image.
//
// 0 = black
// 1 = white
// 2 = transparent
//
// layer[0] is in front, layer[layers.len()-1] is in the back.
let mut img: Vec<Vec<Vec<u32>>> = vec![];
for layer in layers {
let mut rows: Vec<Vec<u32>> = vec![];
for y in 0..6 {
... | code_fim | hard | {
"lang": "rust",
"repo": "nesv/advent-of-code",
"path": "/2019/src/bin/08.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn matrix4_uniform(rc: &mut RenderContext, params: &HashMap<String, UniformParameter>, param: &str, value: [[f32; 4]; 4]) {
if let Some(enm) = params.get(param) {
if let UniformParameter::Matrix4(uniform) = enm {
rc.set_uniform(uniform, value);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "a-ste/vxe",
"path": "/vxe_renderer/src/types/parameter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: a-ste/vxe path: /vxe_renderer/src/types/parameter.rs
use crate::data::shader::Uniform;
use crate::data::{LumTextureBinding, LumDepthBinding};
use crate::context::RenderContext;
use std::collections::HashMap;
pub enum Parameter {
Float(f32),
Matrix4([[f32; 4]; 4]),
}
pub enum UniformPar... | code_fim | hard | {
"lang": "rust",
"repo": "a-ste/vxe",
"path": "/vxe_renderer/src/types/parameter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn vector3_uniform(rc: &mut RenderContext, params: &HashMap<String, UniformParameter>, param: &str, value: [f32; 3]) {
if let Some(enm) = params.get(param) {
if let UniformParameter::Vector3(uniform) = enm {
rc.set_uniform(uniform, value);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "a-ste/vxe",
"path": "/vxe_renderer/src/types/parameter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(backtrace) = e.backtrace() {
eprintln!("backtrace: {:?}", backtrace);
}
}
-1 // should never happen
};
// clone environment
let child_pid = clone(Box::new(callback),
&mut stack,
... | code_fim | hard | {
"lang": "rust",
"repo": "mschorsch/isolate-rs",
"path": "/src/mount.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mschorsch/isolate-rs path: /src/mount.rs
// MIT License
//
// Copyright (c) 2017 Matthias Schorsch
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restri... | code_fim | hard | {
"lang": "rust",
"repo": "mschorsch/isolate-rs",
"path": "/src/mount.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: highstreeto/tracky path: /tracky/src/lib.rs
extern crate serde;
extern crate serde_json;
use serde::{Deserialize, Serialize};
use std::{fs, io::prelude::*, path::Path};
use project::Project;
<|fim_suffix|>#[derive(Serialize, Deserialize, Default)]
pub struct TimeTracker {
projects: Vec<Pro... | code_fim | medium | {
"lang": "rust",
"repo": "highstreeto/tracky",
"path": "/tracky/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn find_project_mut(&mut self, name: &str) -> Option<&mut Project> {
self.projects.iter_mut().find(|proj| proj.name() == name)
}
pub fn save(&self, path: &Path) -> Result<(), String> {
let json = serde_json::to_string(self).map_err(|err| err.to_string())?;
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "highstreeto/tracky",
"path": "/tracky/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vkill/haproxy-spoa-example path: /src/frame_codec.rs
use bytes::{Buf, BufMut, Bytes, BytesMut};
use futures_codec::{Decoder, Encoder};
const U32_LENGTH: usize = std::mem::size_of::<u32>();
<|fim_suffix|> fn encode(&mut self, src: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> {
... | code_fim | medium | {
"lang": "rust",
"repo": "vkill/haproxy-spoa-example",
"path": "/src/frame_codec.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut len_bytes = [0u8; U32_LENGTH];
len_bytes.copy_from_slice(&src[..U32_LENGTH]);
let len = u32::from_be_bytes(len_bytes) as usize;
if src.len() - U32_LENGTH >= len {
// Skip the length header we already read.
src.advance(U32_LENGTH);
... | code_fim | hard | {
"lang": "rust",
"repo": "vkill/haproxy-spoa-example",
"path": "/src/frame_codec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.map
.read()
.unwrap()
.get(name)
.and_then(|table| table.get(key).cloned())
}
fn contains(&self, name: &str, key: &[u8]) -> bool {
self.map
.read()
.unwrap()
.get(name)
.map_or(fal... | code_fim | hard | {
"lang": "rust",
"repo": "KateNegrienko/exonum",
"path": "/exonum/src/storage/memorydb.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KateNegrienko/exonum path: /exonum/src/storage/memorydb.rs
// Copyright 2018 The Exonum Team
//
// 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.apa... | code_fim | hard | {
"lang": "rust",
"repo": "KateNegrienko/exonum",
"path": "/exonum/src/storage/memorydb.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_common/src/pos.rs
use std::{borrow::Cow, rc::Rc, sync::Arc};
pub use crate::syntax_pos::{
hygiene, BytePos, CharPos, FileName, Globals, Loc, LocWithOpt, Mark, MultiSpan, SourceFile,
SourceFileAndBytePos, SourceFileAndLine, Span, SpanLinesError, SyntaxCo... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_common/src/pos.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> <S as Spanned>::span_hi(self)
}
}
impl<'a, S> Spanned for &'a S
where
S: ?Sized + Spanned,
{
fn span(&self) -> Span {
<S as Spanned>::span(self)
}
#[inline]
fn span_lo(&self) -> BytePos {
<S as Spanned>::span_lo(self)
}
#[inline]
fn span_hi(&s... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_common/src/pos.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gigaSproule/circleci-api-cli path: /src/task.rs
use std::str::FromStr;
pub enum Task {
GetAllPipelines,
GetLatestArtifacts,
GetMe,
ListAll,
Trigger,
}
<|fim_suffix|> match s.to_lowercase().as_str() {
"get_all_pipelines" => Ok(Task::GetAllPipelines),
... | code_fim | hard | {
"lang": "rust",
"repo": "gigaSproule/circleci-api-cli",
"path": "/src/task.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (*self.message).to_owned()
}
}
impl FromStr for Task {
type Err = TaskParseStringError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"get_all_pipelines" => Ok(Task::GetAllPipelines),
"get_latest_artifacts" => Ok(T... | code_fim | medium | {
"lang": "rust",
"repo": "gigaSproule/circleci-api-cli",
"path": "/src/task.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match s.to_lowercase().as_str() {
"get_all_pipelines" => Ok(Task::GetAllPipelines),
"get_latest_artifacts" => Ok(Task::GetLatestArtifacts),
"get_me" => Ok(Task::GetMe),
"trigger" => Ok(Task::Trigger),
"list_all" => Ok(Task::ListAll),
... | code_fim | hard | {
"lang": "rust",
"repo": "gigaSproule/circleci-api-cli",
"path": "/src/task.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline]
pub fn compile(line: &str, line_number: usize) -> Vec<BaseToken> {
let tokens = FilteredTokenizer::new(CythanV1 {}, line).collect::<Vec<Token>>();
let mut out = Vec::new();
let mut caret = 0;
for i in tokens {
let t = i.term;
let from = caret;
caret += t.l... | code_fim | hard | {
"lang": "rust",
"repo": "Cythan-Project/cythan-compiler",
"path": "/src/parser/basetoken.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cythan-Project/cythan-compiler path: /src/parser/basetoken.rs
use crate::compiler::position::Position;
use std::borrow::Cow;
use tokesies::*;
pub struct CythanV1;
impl filters::Filter for CythanV1 {
fn on_char(&self, c: &char) -> (bool, bool) {
match *c {
'(' | ')' | '{... | code_fim | hard | {
"lang": "rust",
"repo": "Cythan-Project/cythan-compiler",
"path": "/src/parser/basetoken.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Metaswitch/vault-client path: /src/cache.rs
//! A cache is stored on disk. This allows us to persist secrets over restart of the process, which
//! allows the client library to provide service without contacting Vault for a limited period of
//! time.
use std::collections::HashMap;
use std::fs:... | code_fim | hard | {
"lang": "rust",
"repo": "Metaswitch/vault-client",
"path": "/src/cache.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cache_file = NamedTempFile::new().unwrap();
let certificate = new_certificate("foo");
// Write the cache
Cache::update(cache_file.path(), |cache| certificate.update_cache(cache)).unwrap();
// Read and verify that it gives the same certificate.
assert_e... | code_fim | hard | {
"lang": "rust",
"repo": "Metaswitch/vault-client",
"path": "/src/cache.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn new_certificate<S: Into<String>>(common_name: S) -> X509 {
X509 {
common_name: common_name.into(),
certificate: "certificate".to_string(),
issuing_ca: "issuing_ca".to_string(),
ca_chain: None,
private_key: "private_key".to_string()... | code_fim | hard | {
"lang": "rust",
"repo": "Metaswitch/vault-client",
"path": "/src/cache.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oconnor663/clap_unicode_test path: /src/main.rs
use clap::{App, Arg};
fn main() {
let matches = App::new("test")
.arg(Arg::with_name("ARG").mul<|fim_suffix|>n args {
if arg.to_str().is_some() {
println!("{:?} (valid Unicode)", arg);
} else {
... | code_fim | medium | {
"lang": "rust",
"repo": "oconnor663/clap_unicode_test",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> } else {
println!("{:?} (INVALID Unicode!!!)", arg);
}
}
}
}<|fim_prefix|>// repo: oconnor663/clap_unicode_test path: /src/main.rs
use clap::{App, Arg};
fn main() {
let matches = App::new("test")
.arg(Arg::with_name("ARG").multiple(true))
... | code_fim | medium | {
"lang": "rust",
"repo": "oconnor663/clap_unicode_test",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SachinMaharana/sandbox-rust path: /acts/actors/diemysql/src/bin/show_snippets.rs
extern crate diemysql;
extern crate diesel;
use self::diemysql::*;
use self::diesel::prelude::*;
use self::models::*;
fn main() {
use diemysql::schema::snippets::dsl::*;
<|fim_suffix|> println!("Displaying... | code_fim | medium | {
"lang": "rust",
"repo": "SachinMaharana/sandbox-rust",
"path": "/acts/actors/diemysql/src/bin/show_snippets.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let conn = establish_connection();
let result = snippets
.load::<Snippet>(&conn)
.expect("Error Loading Posts");
println!("Displaying {} posts", result.len());
for post in result {
println!("{}", post.title);
println!("----------\n");
println!("{}",... | code_fim | medium | {
"lang": "rust",
"repo": "SachinMaharana/sandbox-rust",
"path": "/acts/actors/diemysql/src/bin/show_snippets.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/spi/cmd.rs
#[doc = "Reader of register CMD"]
pub type R = crate::R<u32, super::CMD>;
#[doc = "Writer for register CMD"]
pub type W = crate::W<u32, super::CMD>;
#[doc = "Register CMD `reset()`'s with value 0"]
impl crate::ResetValue for super::CMD {
type... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/spi/cmd.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ngi-nix/nixos-search path: /flake-info/src/data/source.rs
use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
use std::{
fs::{self, File},
io::Read,
path::Path,
ffi::OsStr,
};
pub type Hash = String;
pub type FlakeRef = String;
/// Information about the flake or... | code_fim | hard | {
"lang": "rust",
"repo": "ngi-nix/nixos-search",
"path": "/flake-info/src/data/source.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn nixpkgs(channel: String) -> Result<Nixpkgs> {
#[derive(Deserialize, Debug)]
struct ApiResult {
commit: Commit,
}
#[derive(Deserialize, Debug)]
struct Commit {
sha: String,
}
let git_ref = reqwest::Client::bu... | code_fim | hard | {
"lang": "rust",
"repo": "ngi-nix/nixos-search",
"path": "/flake-info/src/data/source.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scurest/apicula path: /src/util/tree.rs
use std;
/// A tree (or forest). Each node stores a T.
/// Nodes are stored in a flat array and referenced by indices.
pub struct Tree<T> {
nodes: Vec<Node<T>>,
}
pub type NodeIdx = u16;
static NONE: NodeIdx = !0; // marks no children/siblings
struc... | code_fim | hard | {
"lang": "rust",
"repo": "scurest/apicula",
"path": "/src/util/tree.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> std::ops::IndexMut<NodeIdx> for Tree<T> {
fn index_mut(&mut self, node: NodeIdx) -> &mut T {
&mut self.nodes[node as usize].val
}
}
pub struct Children<'a, T> {
tree: &'a Tree<T>,
next_child: NodeIdx,
}
impl<T> std::iter::Iterator for Children<'_, T> {
type Item = Nod... | code_fim | hard | {
"lang": "rust",
"repo": "scurest/apicula",
"path": "/src/util/tree.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> for token in cwd_parent_iter {
tokens.push(token);
size += token.len() + 1;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/path-absolutize",
"path": "/src/windows.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/path-absolutize path: /src/windows.rs
use std::borrow::Cow;
use std::ffi::OsString;
use std::io::{self, ErrorKind};
use std::path::{Component, Path, PathBuf};
use crate::path_dedot::{ParseDot, ParsePrefix, MAIN_SEPARATOR};
use crate::Absolutize;
impl Absolutize for Path {
fn absolu... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/path-absolutize",
"path": "/src/windows.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dvc94ch/crepe path: /tests/ui/capital_letter_var.rs
// This test checks behavior that identifiers starting with 'A'..'Z' are not
// treated as Datalog variables.
<|fim_suffix|>crepe! {
struct Ok(i32);
Ok(Not_a_variable) <- Ok(Not_a_variable);
}
fn main() {}<|fim_middle|>use crepe::crep... | code_fim | easy | {
"lang": "rust",
"repo": "dvc94ch/crepe",
"path": "/tests/ui/capital_letter_var.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>crepe! {
struct Ok(i32);
Ok(Not_a_variable) <- Ok(Not_a_variable);
}
fn main() {}<|fim_prefix|>// repo: dvc94ch/crepe path: /tests/ui/capital_letter_var.rs
// This test checks behavior that identifiers starting with 'A'..'Z' are not
// treated as Datalog variables.
<|fim_middle|>use crepe::crep... | code_fim | easy | {
"lang": "rust",
"repo": "dvc94ch/crepe",
"path": "/tests/ui/capital_letter_var.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> DotVoxData {
version: 150,
models: vec![model],
palette: Vec::new(),
materials: Vec::new(),
}
}<|fim_prefix|>// repo: rezural/building-blocks path: /crates/building_blocks_storage/src/dot_vox_conversions.rs
use crate::prelude::*;
pub use dot_vox;
use building_blo... | code_fim | hard | {
"lang": "rust",
"repo": "rezural/building-blocks",
"path": "/crates/building_blocks_storage/src/dot_vox_conversions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rezural/building-blocks path: /crates/building_blocks_storage/src/dot_vox_conversions.rs
use crate::prelude::*;
pub use dot_vox;
use building_blocks_core::prelude::*;
use dot_vox::*;
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum VoxColor {
Color(u8),
Empty,
}
impl IsEmpty for VoxCo... | code_fim | medium | {
"lang": "rust",
"repo": "rezural/building-blocks",
"path": "/crates/building_blocks_storage/src/dot_vox_conversions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let model = dot_vox::Model { size, voxels };
DotVoxData {
version: 150,
models: vec![model],
palette: Vec::new(),
materials: Vec::new(),
}
}<|fim_prefix|>// repo: rezural/building-blocks path: /crates/building_blocks_storage/src/dot_vox_conversions.rs
use crat... | code_fim | hard | {
"lang": "rust",
"repo": "rezural/building-blocks",
"path": "/crates/building_blocks_storage/src/dot_vox_conversions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Compose for Numeric {
fn compose(&self, session: &mut dyn BufMut) -> usize {
if !self.noreply {
let response = format!("{}\r\n", self.value).into_bytes();
session.put_slice(&response);
response.len()
} else {
0
}
}
}
#[c... | code_fim | hard | {
"lang": "rust",
"repo": "twitter/pelikan",
"path": "/src/protocol/memcache/src/response/numeric.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twitter/pelikan path: /src/protocol/memcache/src/response/numeric.rs
// Copyright 2022 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use super::*;
#[derive(Debug, PartialEq, Eq)]
pub struct Numeric {
value: u64,
noreply: b... | code_fim | hard | {
"lang": "rust",
"repo": "twitter/pelikan",
"path": "/src/protocol/memcache/src/response/numeric.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rafalmiel/rust-x86 path: /src/controlregs.rs
//! Functions to read and write control registers.
pub unsafe fn cr0() -> u64 {
let ret: u64;
asm!("mov %cr0, $0" : "=r" (ret));
ret
}
<|fim_suffix|>/// Switch page-table PML4 pointer.
pub unsafe fn cr3_write(val: u64) {
asm!("mov $0... | code_fim | hard | {
"lang": "rust",
"repo": "rafalmiel/rust-x86",
"path": "/src/controlregs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Write cr4.
pub unsafe fn cr4_write(val: u64) {
asm!("mov $0, %cr4" :: "r" (val) : "memory");
}<|fim_prefix|>// repo: rafalmiel/rust-x86 path: /src/controlregs.rs
//! Functions to read and write control registers.
pub unsafe fn cr0() -> u64 {
let ret: u64;
asm!("mov %cr0, $0" : "=r" (ret)... | code_fim | hard | {
"lang": "rust",
"repo": "rafalmiel/rust-x86",
"path": "/src/controlregs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>,
}
impl WheezyMirror {
pub fn get_mirror(&self) -> &'static str {
match self {
WheezyMirror::Aliyun => include_str!("wheezy/aliyun.txt"),
}
}
}<|fim_prefix|>// repo: QiYuTechDev/mirror path: /src/debian/wheezy.rs
use structopt::StructOpt;
#[derive(StructOpt, Debug)]... | code_fim | medium | {
"lang": "rust",
"repo": "QiYuTechDev/mirror",
"path": "/src/debian/wheezy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: QiYuTechDev/mirror path: /src/debian/wheezy.rs
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
/// debian wheezy 镜像
pub enum WheezyMirror {
/// 阿里云镜像
/// doc: https://developer.aliyun.com/mirror/debian
Aliyun<|fim_suffix|> {
WheezyMirror::Aliyun => include_str!("wh... | code_fim | medium | {
"lang": "rust",
"repo": "QiYuTechDev/mirror",
"path": "/src/debian/wheezy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.rt.block_on(async { self.traverser.next().await })
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.traverser.size_hint()
}
}
fn build_runtime() -> Result<Runtime, Error> {
let mut builder = tokio::runtime::Builder::new_multi_thread();
builder.worker_thread... | code_fim | hard | {
"lang": "rust",
"repo": "dlr-eoc/ukis-h3cellstore",
"path": "/crates/ukis_h3cellstore/src/clickhouse/sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dlr-eoc/ukis-h3cellstore path: /crates/ukis_h3cellstore/src/clickhouse/sync.rs
use crate::clickhouse::compacted_tables::traversal::{
traverse, TraversalArea, TraversalOptions, TraversedCell, Traverser,
};
use crate::clickhouse::H3CellStore;
use crate::Error;
use futures::StreamExt;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "dlr-eoc/ukis-h3cellstore",
"path": "/crates/ukis_h3cellstore/src/clickhouse/sync.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct TraverseIterator {
rt: Arc<Runtime>,
traverser: Traverser,
}
impl Iterator for TraverseIterator {
type Item = Result<TraversedCell, Error>;
fn next(&mut self) -> Option<Self::Item> {
self.rt.block_on(async { self.traverser.next().await })
}
fn size_hint(&self)... | code_fim | hard | {
"lang": "rust",
"repo": "dlr-eoc/ukis-h3cellstore",
"path": "/crates/ukis_h3cellstore/src/clickhouse/sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 4ge32/rddsv path: /examples/m_inc2.rs
use rddsv::lts::*;
use rddsv::process::*;
use std::fmt;
#[derive(Default, std::fmt::Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SharedVars {
pub x: i32, // shared variables between P and Q.
pub t1: i32, // P's local variables.
pub t2: ... | code_fim | hard | {
"lang": "rust",
"repo": "4ge32/rddsv",
"path": "/examples/m_inc2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> std::fs::remove_file("res/test_m_inc2_P.dot").unwrap_or_else(|why| {
println!("! {:?}", why.kind());
});
}
#[test]
fn vis_lts() {
let process = m_inc2_def();
let r: SharedVars = Default::default();
let s = State::new(r);
let lts = co... | code_fim | hard | {
"lang": "rust",
"repo": "4ge32/rddsv",
"path": "/examples/m_inc2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xCodex-ctrl/msp432-newio path: /src/main.rs
#![feature(used)]
#![no_std]
extern crate cortex_m;
extern crate cortex_m_rt;
extern crate msp432p401r;
use cortex_m::asm;
fn main() {
let p = msp432p401r::Peripherals::take().unwrap();
// The Digital I/O module
let dio = p.DIO;
<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "xCodex-ctrl/msp432-newio",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // PORTA consists of two ports P1 and P2. Red LED of the
// MSP432P401R launchpad is on P2.0. Green and Blue LED's
// on P2.1 and P2.2. Simply set the direction register bit
// to 1 and write a 1 to the output register to put ON the LED.
dio.padir.modify(|r, w| unsafe { w.p2dir().bits... | code_fim | medium | {
"lang": "rust",
"repo": "xCodex-ctrl/msp432-newio",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/pds/pds_ctl2.rs
impl<'a> CR_PDS_FORCE_NP_MEM_STBY_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/pds/pds_ctl2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/pds/pds_ctl2.rs
inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 1... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/pds/pds_ctl2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `cr_pds_force_bz_iso_en` writer - "]
pub struct CR_PDS_FORCE_BZ_ISO_EN_W<'a> {
w: &'a mut W,
}
impl<'a> CR_PDS_FORCE_BZ_ISO_EN_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/pds/pds_ctl2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snpefk/raytracer path: /src/utility.rs
use crate::vec3::Vec3;
pub type Point3 = Vec3;
pub type Color = Vec3;
<|fim_suffix|>pub fn clamp(x: f64, min: f64, max: f64) -> f64 {
if x < min {
min
} else if x > max {
max
} else {
x
}
}<|fim_middle|>pub fn deg... | code_fim | medium | {
"lang": "rust",
"repo": "snpefk/raytracer",
"path": "/src/utility.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn clamp(x: f64, min: f64, max: f64) -> f64 {
if x < min {
min
} else if x > max {
max
} else {
x
}
}<|fim_prefix|>// repo: snpefk/raytracer path: /src/utility.rs
use crate::vec3::Vec3;
pub type Point3 = Vec3;
pub type Color = Vec3;
<|fim_middle|>pub fn deg... | code_fim | medium | {
"lang": "rust",
"repo": "snpefk/raytracer",
"path": "/src/utility.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, sender: mpsc::Sender<PlayerCmd>, _terminate: Arc<AtomicBool>) {
let stdin = io::stdin();
let mut lines = stdin.lock().lines();
loop {
eprint!("cmd> ");
let line = if let Some(line) = lines.next() {
line
} els... | code_fim | medium | {
"lang": "rust",
"repo": "kawamuray/phoseum",
"path": "/src/console_control.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kawamuray/phoseum path: /src/console_control.rs
use crate::control::{Commander, PlayerCmd};
use log::{debug, info, warn};
use std::io;
use std::io::BufRead;
use std::sync::atomic::AtomicBool;
use std::sync::mpsc;
use std::sync::Arc;
<|fim_suffix|>impl Commander<PlayerCmd> for ConsoleCommander {... | code_fim | medium | {
"lang": "rust",
"repo": "kawamuray/phoseum",
"path": "/src/console_control.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> true
}
fn run(&mut self, sender: mpsc::Sender<PlayerCmd>, _terminate: Arc<AtomicBool>) {
let stdin = io::stdin();
let mut lines = stdin.lock().lines();
loop {
eprint!("cmd> ");
let line = if let Some(line) = lines.next() {
li... | code_fim | medium | {
"lang": "rust",
"repo": "kawamuray/phoseum",
"path": "/src/console_control.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erikiva/advent-of-code path: /2021-rust/src/day05.rs
use std::collections::HashMap;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Point {
x: i32,
y: i32,
}
pub struct Line {
start: Point,
end: Point,
}
impl Line {
fn is_horizontal(&self) -> bool {
self.start.y == self.... | code_fim | hard | {
"lang": "rust",
"repo": "erikiva/advent-of-code",
"path": "/2021-rust/src/day05.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day5, part2)]
pub fn solve_part2(vent_lines: &Vec<Line>) -> i32 {
println!("Lines: {}", vent_lines.len());
let mut high_crossings = 0i32;
let mut crosings: HashMap<Point, i32> = HashMap::new();
for line in vent_lines {
if line.is_horizontal() {
let range = if line.start.x > line.en... | code_fim | hard | {
"lang": "rust",
"repo": "erikiva/advent-of-code",
"path": "/2021-rust/src/day05.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nisarhassan12/materialize path: /src/sql-parser/src/ast/defs/value.rs
// Copyright 2018 sqlparser-rs contributors. All rights reserved.
// Copyright Materialize, Inc. and contributors. All rights reserved.
//
// This file is derived from the sqlparser-rs project, available at
// https://github.c... | code_fim | hard | {
"lang": "rust",
"repo": "nisarhassan12/materialize",
"path": "/src/sql-parser/src/ast/defs/value.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromStr for DateTimeField {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
match s.to_uppercase().as_ref() {
"MILLENNIUM" | "MILLENNIA" | "MIL" | "MILS" => Ok(Self::Millennium),
"CENTURY" | "CENTURIES" | "CENT" | "C" => Ok(Se... | code_fim | hard | {
"lang": "rust",
"repo": "nisarhassan12/materialize",
"path": "/src/sql-parser/src/ast/defs/value.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ons.iter() {
println!("{} v{}", krate, version)
}
Ok(())
}<|fim_prefix|>// repo: Shnatsel/rustsec path: /quitters/examples/from_file.rs
fn main() -> Result<(), Box<dyn std::error::Error>> {
let path = std::<|fim_middle|>env::args_os().nth(1).unwrap();
let file = std::fs::read(path... | code_fim | medium | {
"lang": "rust",
"repo": "Shnatsel/rustsec",
"path": "/quitters/examples/from_file.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shnatsel/rustsec path: /quitters/examples/from_file.rs
fn main() -> Result<(), Box<dyn std::error::Error>> {
let path = std::<|fim_suffix|>et versions = quitters::versions(&file);
for (krate, version) in versions.iter() {
println!("{} v{}", krate, version)
}
Ok(())
}<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "Shnatsel/rustsec",
"path": "/quitters/examples/from_file.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coreos/fedora-coreos-cincinnati path: /fcos-graph-builder/src/scraper.rs
use actix::prelude::*;
use actix_web::web::Bytes;
use commons::{graph, metadata};
use failure::{Error, Fallible};
use reqwest::Method;
use std::num::NonZeroU64;
use std::time::Duration;
/// Default timeout for HTTP request... | code_fim | hard | {
"lang": "rust",
"repo": "coreos/fedora-coreos-cincinnati",
"path": "/fcos-graph-builder/src/scraper.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn handle(&mut self, msg: GetCachedGraph, _ctx: &mut Self::Context) -> Self::Result {
use failure::format_err;
if msg.scope.basearch != self.scope.basearch {
return Box::new(actix::fut::err(format_err!(
"unexpected basearch '{}'",
msg.scope.... | code_fim | hard | {
"lang": "rust",
"repo": "coreos/fedora-coreos-cincinnati",
"path": "/fcos-graph-builder/src/scraper.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azdavis/advent-of-code path: /years/y2019/src/d09.rs
use crate::intcode::Intcode;
pub fn p1(s: &str) -> i64 {
go(s, 1)
}
pub fn p2(s: &str) -> i64 {
go(s, 2)
}
fn go(s: &str, inp: i64) -> i64 {
<|fim_suffix|> let s = include_str!("input/d09.txt");
assert_eq!(p1(s), 2_204_990_589);
as... | code_fim | hard | {
"lang": "rust",
"repo": "azdavis/advent-of-code",
"path": "/years/y2019/src/d09.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn t() {
let s = include_str!("input/d09.txt");
assert_eq!(p1(s), 2_204_990_589);
assert_eq!(p2(s), 50008);
}<|fim_prefix|>// repo: azdavis/advent-of-code path: /years/y2019/src/d09.rs
use crate::intcode::Intcode;
pub fn p1(s: &str) -> i64 {
go(s, 1)
}
pub fn p2(s: &str) -> i64 {
go(s... | code_fim | hard | {
"lang": "rust",
"repo": "azdavis/advent-of-code",
"path": "/years/y2019/src/d09.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DelayUs<u32> for Delay {
fn delay_us(&mut self, us: u32) {
delay_us(us, &self.clocks);
}
}
impl DelayUs<u16> for Delay {
fn delay_us(&mut self, us: u16) {
self.delay_us(us as u32)
}
}
impl DelayUs<u8> for Delay {
fn delay_us(&mut self, us: u8) {
self.dela... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/rpi3-rust-workspace",
"path": "/bcm2837-hal/src/delay.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonlamb-gh/rpi3-rust-workspace path: /bcm2837-hal/src/delay.rs
//! Delays
use crate::clocks::Clocks;
use crate::hal::blocking::delay::{DelayMs, DelayUs};
use core::cmp;
use cortex_a::asm;
/// NOP used as a delay provider
/// NOTE: this is not accurate, for accurate timing and delays consider
/... | code_fim | medium | {
"lang": "rust",
"repo": "jonlamb-gh/rpi3-rust-workspace",
"path": "/bcm2837-hal/src/delay.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for Ray {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({} |\n v{})", self.pos, self.dir.as_ref())
}
}<|fim_prefix|>// repo: KevinMackenzie/ferric-falcon path: /src/math/ray.rs
use nalgebra::base::{Unit, Vector3};
use std::fmt;
pub struct ... | code_fim | hard | {
"lang": "rust",
"repo": "KevinMackenzie/ferric-falcon",
"path": "/src/math/ray.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KevinMackenzie/ferric-falcon path: /src/math/ray.rs
use nalgebra::base::{Unit, Vector3};
use std::fmt;
pub struct Ray {
pub pos: Vector3<f64>,
pub dir: Unit<Vector3<f64>>,
}
<|fim_suffix|> write!(f, "({} |\n v{})", self.pos, self.dir.as_ref())
}
}<|fim_middle|>impl Ray... | code_fim | hard | {
"lang": "rust",
"repo": "KevinMackenzie/ferric-falcon",
"path": "/src/math/ray.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slazicoicr/maestro_ngs_rust path: /maestro_ngs_emulator/src/lib.rs
mod machine;
use machine::{Execute, Machine, MachineError, ScicloneG3};
use maestro_ngs_application::{
Command, InstructionValue, Layout, LoadEjectTipsHead, PositionHead, SavedApplication, Variable,
VariableValue,
};
use... | code_fim | hard | {
"lang": "rust",
"repo": "slazicoicr/maestro_ngs_rust",
"path": "/maestro_ngs_emulator/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.machine.execute(&action.execute)?;
Ok(())
}
fn get_current_instruction(&self) -> Result<usize> {
self.stack_instructions
.last()
.cloned()
.ok_or(EmulatorError::EmptyStack)
}
fn get_current_layout(&self) -> Result<Uuid> {
... | code_fim | hard | {
"lang": "rust",
"repo": "slazicoicr/maestro_ngs_rust",
"path": "/maestro_ngs_emulator/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.