text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> pub(super) fn mark_filled(&mut self, key: Vec<DataType>) {
let mut key = key.into_iter();
let replaced = match self.state {
KeyedState::Single(ref mut map) => map.insert(key.next().unwrap(), Rows::default()),
KeyedState::Double(ref mut map) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "aDotInTheVoid/noria",
"path": "/server/dataflow/src/state/single_state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chloekek/neptune path: /np_graphics/src/linalg/matrix.rs
use crate::Vector;
use std::ops;
/// Affine transformation matrix.
///
/// Affine transformation matrices are used for
/// rotating, scaling, skewing, and translating points.
/// The final column of the matrix is not stored in memory
///... | code_fim | hard | {
"lang": "rust",
"repo": "chloekek/neptune",
"path": "/np_graphics/src/linalg/matrix.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// A matrix which translates the shape
/// a given distance in each direction.
///
/// \\(
/// \begin{bmatrix}
/// 1 & 0 & 0 \\\\
/// 0 & 1 & 0 \\\\
/// t_x & t_y & 1
/// \end{bmatrix}
/// \\)
pub fn from_translate(tx: f64, ty: f64) -> Self
{
... | code_fim | hard | {
"lang": "rust",
"repo": "chloekek/neptune",
"path": "/np_graphics/src/linalg/matrix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liamom/c_game path: /tmx_parser/src/types.rs
use std::str::FromStr;
#[derive(Debug, PartialEq)]
pub enum Orientation {
Orthogonal,
Isometric,
Staggered,
Hexagonal
}
impl FromStr for Orientation {
type Err = ();
fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Er... | code_fim | hard | {
"lang": "rust",
"repo": "liamom/c_game",
"path": "/tmx_parser/src/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match color_string.len() {
6 | 8 => {
let value:i64 = i64::from_str_radix(color_string.as_ref(), 16).unwrap();
let color = Color {
r: ((value >> 16) & 0xff) as u8,
g: ((value >> 8) & 0xff) as u8,
... | code_fim | hard | {
"lang": "rust",
"repo": "liamom/c_game",
"path": "/tmx_parser/src/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hermitmotel/async-httpd path: /src/main.rs
use async_std::prelude::*;
use async_std::fs;
use async_std::net::TcpListener;
use async_std::net::TcpStream;
use async_std::task::{self, block_on, spawn};
use futures::stream::StreamExt;
use std::time::Duration;
async fn handle_connection(mut stream:... | code_fim | hard | {
"lang": "rust",
"repo": "hermitmotel/async-httpd",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Respond with greetings or a 404,
// depending on the data in the request
let (status_line, filename) = if buffer.starts_with(get) {
("HTTP/1.1 200 OK\r\n\r\n", "hello.html")
} else if buffer.starts_with(sleep) {
task::sleep(Duration::from_secs(5)).await;
("HTTP/1.1 200 OK\r\n\r\n", "hello.htm... | code_fim | hard | {
"lang": "rust",
"repo": "hermitmotel/async-httpd",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn http_listen() {
// Listen for incoming TCP connections on localhost port 7878
let listener = TcpListener::bind("127.0.0.1:7878").await.unwrap();
let mut incoming = listener.incoming();
while let Some(tcpstream) = incoming.next().await {
handle_connection(tcpstream.unwrap()).await;
//spaw... | code_fim | hard | {
"lang": "rust",
"repo": "hermitmotel/async-httpd",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(unquote("''hey jude'"), String::from("'hey jude"));
assert_eq!(unquote("'hey jude"), String::from("'hey jude"));
assert_eq!(unquote("\"hey jude"), String::from("\"hey jude"));
assert_eq!(unquote("hey jude'"), String::from("hey jude'"));
assert_eq!(unquote("hey jude\""), Str... | code_fim | hard | {
"lang": "rust",
"repo": "adam-mcdaniel/rusty-ci",
"path": "/tests/string.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adam-mcdaniel/rusty-ci path: /tests/string.rs
extern crate rusty_ci;
use rusty_ci::unquote;
#[test]
fn unquote_string() {
assert_eq!(unquote("\"\"hey jude\""), String::from("\"hey jude"));
assert_eq!(unquote("\"\"hey jude\"\""), String::from("\"hey jude\""));
<|fim_suffix|> assert_... | code_fim | medium | {
"lang": "rust",
"repo": "adam-mcdaniel/rusty-ci",
"path": "/tests/string.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(unquote("'hey jude'"), String::from("hey jude"));
assert_eq!(unquote("''hey jude'"), String::from("'hey jude"));
assert_eq!(unquote("'hey jude"), String::from("'hey jude"));
assert_eq!(unquote("\"hey jude"), String::from("\"hey jude"));
assert_eq!(unquote("hey jude'"), Str... | code_fim | medium | {
"lang": "rust",
"repo": "adam-mcdaniel/rusty-ci",
"path": "/tests/string.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let orig_len = orig_body.len();
if to > (orig_len as u64) {
response.headers.set(ContentRange(ContentRangeSpec::Bytes {
range: Some((0, (orig_len as u64) - 1)),
instance_length: Some(orig_len as u64),
}));
response.set_mut(orig_body);
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "ahwatts/filament",
"path": "/server/src/range.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ahwatts/filament path: /server/src/range.rs
//! Iron middleware and modifier for handling HTTP Range headers.
use iron::headers::{Range, ByteRangeSpec, ContentRange, ContentRangeSpec, ContentLength};
use iron::modifier::{Modifier, Set};
use iron::response::ResponseBody;
use iron::status::Status... | code_fim | hard | {
"lang": "rust",
"repo": "ahwatts/filament",
"path": "/server/src/range.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/time-macros/src/helpers/string.rs
use
std
:
:
ops
:
:
{
Index
RangeFrom
}
;
use
proc_macro
:
:
Span
;
use
crate
:
:
Error
;
pub
(
crate
)
fn
parse
(
token
:
&
proc_macro
:
:
Literal
)
-
>
Result
<
(
Span
Vec
<
u8
>
)
Error
>
{
let
span
=
token
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/time-macros/src/helpers/string.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
<
RangeFrom
<
usize
>
Output
=
S
>
+
AsRef
<
[
u8
]
>
+
?
Sized
{
let
mut
ch
=
0
;
let
b0
=
byte
(
s
0
)
;
let
b1
=
byte
(
s
1
)
;
ch
+
=
0x10
*
(
b0
-
b
'
0
'
)
;
ch
+
=
match
b1
{
b
'
0
'
.
.
=
b
'
9
'
=
>
b1
-
b
'
0
'
b
'
a
'
.
.
=
b
'
f
'
=
>
10
+
(
b1
-
b
'
a
'
)
b
'
A
'
.
.
=
b
'
F
'
=
>
10
+
(
b1
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/time-macros/src/helpers/string.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>), 1.) };
let ctt2 = 1. - s.sq() * (1. - cti.sq());
if ctt2 <= 0. {
return (1., 0., 1.)
}
let cti = F::abs(cti);
let ctt = F::sqrt(ctt2);
let r = A2((cti - s * ctt) / (cti + s * ctt),
(s * cti - ctt) / (s * cti + ctt));
(r.map(F::sq).mean(), ctt * f, s)
}... | code_fim | medium | {
"lang": "rust",
"repo": "johannesvollmer/fission",
"path": "/src/bsdf/fresnel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johannesvollmer/fission path: /src/bsdf/fresnel.rs
use std::ops::Div;
use crate::core::*;
pub fn eta(ior: Option<F2>) -> F {
ior.unwrap_or(A2(1.000_277, 1.5046)).reduce(Div::div)
}
// (fresnel coef<|fim_suffix|>:sqrt(ctt2);
let r = A2((cti - s * ctt) / (cti + s * ctt),
... | code_fim | hard | {
"lang": "rust",
"repo": "johannesvollmer/fission",
"path": "/src/bsdf/fresnel.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: L3-S6-Projet/test_server path: /filters/src/authed.rs
use crate::with_db;
use db::Database;
use db::{models::UserKind, Db};
use warp::{Filter, Rejection};
/// Filter that checks if the user is authenticated or not, and rejects the request if he/she isn't
pub fn authed(db: &Db) -> impl Filter<E... | code_fim | hard | {
"lang": "rust",
"repo": "L3-S6-Projet/test_server",
"path": "/filters/src/authed.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if auth_type.to_ascii_lowercase() == "bearer" {
let db = db.lock().await;
match db.auth_get_user(&token) {
Some(user) => Ok(user.username.clone()), // TODO: remove extra allocation + remove extra DB lock
None => Err(warp::reject::custom(Forbidden {})), // TODO:... | code_fim | hard | {
"lang": "rust",
"repo": "L3-S6-Projet/test_server",
"path": "/filters/src/authed.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl CjsEsmCodeAnalyzer for CliCjsEsmCodeAnalyzer {
fn analyze_cjs(
&self,
specifier: &ModuleSpecifier,
source: &str,
) -> Result<ExtNodeCjsAnalysis, AnyError> {
let analysis = self.inner_cjs_analysis(specifier, source)?;
Ok(ExtNodeCjsAnalysis {
exports: analysis.exports,
... | code_fim | hard | {
"lang": "rust",
"repo": "tribe-health/deno",
"path": "/cli/node.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tribe-health/deno path: /cli/node.rs
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::collections::HashSet;
use deno_ast::swc::common::SyntaxContext;
use deno_ast::view::Node;
use deno_ast::view::NodeTrait;
use deno_ast::CjsAnalysis;
use deno_ast::MediaType;
... | code_fim | hard | {
"lang": "rust",
"repo": "tribe-health/deno",
"path": "/cli/node.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rick68/rust-trace path: /libcore/cell/struct_UnsafeCell/get.rs
#![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::cell::UnsafeCell;
// pub struct UnsafeCell<T: ?Sized> {
// /// Wrapped value
// ///
// /// This field should not be accessed di... | code_fim | hard | {
"lang": "rust",
"repo": "rick68/rust-trace",
"path": "/libcore/cell/struct_UnsafeCell/get.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // impl<T: ?Sized> UnsafeCell<T> {
// /// Gets a mutable pointer to the wrapped value.
// ///
// /// # Examples
// ///
// /// ```
// /// use std::cell::UnsafeCell;
// ///
// /// let uc = UnsafeCell::new(5);
// ///
// /// l... | code_fim | hard | {
"lang": "rust",
"repo": "rick68/rust-trace",
"path": "/libcore/cell/struct_UnsafeCell/get.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: corka149/jarvis path: /jarvis-backend/src/security.rs
use crate::configuration;
use crate::model::User;
use axum_sessions::async_session::MemoryStore;
use axum_sessions::SessionLayer;
use mongodb::bson;
use serde::{Deserialize, Serialize};
<|fim_suffix|>pub fn new_session_layer(security: &confi... | code_fim | hard | {
"lang": "rust",
"repo": "corka149/jarvis",
"path": "/jarvis-backend/src/security.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn new_session_layer(security: &configuration::Security) -> SessionLayer<MemoryStore> {
let store = MemoryStore::new();
let secret_key = security.secret_key.clone();
let secret = secret_key.as_ref();
SessionLayer::new(store, secret).with_secure(false)
}<|fim_prefix|>// repo: corka149/j... | code_fim | medium | {
"lang": "rust",
"repo": "corka149/jarvis",
"path": "/jarvis-backend/src/security.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: perfectmak/pinata-sdk path: /src/utils.rs
use crate::errors::{ApiError, Error};
static BASE_URL: &'static str = "https://api.pinata.cloud";
/// Checks to ensure keys are not empty
pub(crate) fn validate_keys(api_key: &str, secret_api_key: &str) -> Result<(), Error> {
if api_key.is_empty() {
... | code_fim | medium | {
"lang": "rust",
"repo": "perfectmak/pinata-sdk",
"path": "/src/utils.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
pub(crate) fn api_url(path: &str) -> String {
format!("{}{}", BASE_URL, path)
}<|fim_prefix|>// repo: perfectmak/pinata-sdk path: /src/utils.rs
use crate::errors::{ApiError, Error};
static BASE_URL: &'static str = "https://api.pinata.cloud";
/// Checks to ensure keys are not empty
pub(cra... | code_fim | medium | {
"lang": "rust",
"repo": "perfectmak/pinata-sdk",
"path": "/src/utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: passcod/constellationd path: /src/shine/glow.rs
use errors::IgnoredIoError;
use futures::{Sink, Stream};
use futures::sink::SinkFromErr;
use futures::stream::{FilterMap, Forward, ForEach, SplitSink, SplitStream};
use futures::sync::mpsc::{channel, Sender, Receiver};
use message::Message;
use std... | code_fim | hard | {
"lang": "rust",
"repo": "passcod/constellationd",
"path": "/src/shine/glow.rs",
"mode": "psm",
"license": "Artistic-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Glow<'a> {
pub fn init() -> io::Result<Self> {
let (writer, reader) = Caster::new()?.split();
let (tx, rx) = channel(100);
Ok(Self {
server: reader.filter_map(&filter as &FilterFn).for_each(&server as &ServerFn),
writer: rx.forward(writer.sink_... | code_fim | hard | {
"lang": "rust",
"repo": "passcod/constellationd",
"path": "/src/shine/glow.rs",
"mode": "spm",
"license": "Artistic-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Self {
server: reader.filter_map(&filter as &FilterFn).for_each(&server as &ServerFn),
writer: rx.forward(writer.sink_from_err::<IgnoredIoError>()),
sender: tx,
})
}
}<|fim_prefix|>// repo: passcod/constellationd path: /src/shine/glow.rs
use erro... | code_fim | hard | {
"lang": "rust",
"repo": "passcod/constellationd",
"path": "/src/shine/glow.rs",
"mode": "spm",
"license": "Artistic-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmurfin87/rust-gui path: /src/window_manager.rs
use super::rectarea::*;
use super::theme::*;
use super::elements::*;
use sdl2::pixels::Color;
use sdl2::rect::Rect;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::mouse::MouseButton;
pub struct WindowManager<'wm>
{
pub quit: bool,... | code_fim | hard | {
"lang": "rust",
"repo": "mmurfin87/rust-gui",
"path": "/src/window_manager.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn draw(&mut self)
{
self.draw_context.canvas.set_draw_color(self.theme.backgroundColor);
self.draw_context.canvas.clear();
for wi in (0..self.windows.len()).rev()
{
// This is just to help visually identify window-drawing bugs. Red should not be visible
self.draw_context.canvas.set_d... | code_fim | hard | {
"lang": "rust",
"repo": "mmurfin87/rust-gui",
"path": "/src/window_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cauebs/gomoku path: /src/players.rs
use rand::{thread_rng, Rng};
use std::io::{stdin, stdout, Write};
pub use ai::SmartBot;
use board::Board;
use coordinates::coordinates_from_hex_str;
pub trait Player {
fn decide(&mut self, board: &Board, last_move: Option<(usize, usize)>) -> (usize, usi... | code_fim | hard | {
"lang": "rust",
"repo": "cauebs/gomoku",
"path": "/src/players.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Invalid input.\n");
}
}
}
pub struct RandomBot;
impl Player for RandomBot {
fn decide(&mut self, _board: &Board, _last_move: Option<(usize, usize)>) -> (usize, usize) {
let mut rng = thread_rng();
(rng.gen_range(0, 15), rng.gen_range(0, 15))
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "cauebs/gomoku",
"path": "/src/players.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn flush(&mut self) -> ();
}
*/<|fim_prefix|>// repo: voidException/timely-dataflow path: /src/example/ports.rs
/*
use progress::timestamp::Timestamp;
<|fim_middle|>// a port into which data can be sent
pub trait TargetPort<T: Timestamp, D: Copy> : 'static
{
fn deliver_data(&mut self, time: &T, ... | code_fim | medium | {
"lang": "rust",
"repo": "voidException/timely-dataflow",
"path": "/src/example/ports.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: voidException/timely-dataflow path: /src/example/ports.rs
/*
use progress::timestamp::Timestamp;
<|fim_suffix|> fn flush(&mut self) -> ();
}
*/<|fim_middle|>// a port into which data can be sent
pub trait TargetPort<T: Timestamp, D: Copy> : 'static
{
fn deliver_data(&mut self, time: &T, ... | code_fim | medium | {
"lang": "rust",
"repo": "voidException/timely-dataflow",
"path": "/src/example/ports.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: psFried/l-system-prototype path: /src/render/collection.rs
use super::Renderer;
use std::mem;
pub fn batch<'a>(renderers: Vec<&'a mut dyn Renderer>) -> Collection<'a> {
Collection::new(renderers)
}
pub struct Collection<'a> {
renderers: Vec<&'a mut dyn Renderer>
}
impl<'a> Collection<... | code_fim | hard | {
"lang": "rust",
"repo": "psFried/l-system-prototype",
"path": "/src/render/collection.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut renderers = mem::replace(&mut self.renderers, vec![]);
for ref mut renderer in &mut renderers {
renderer.left();
}
self.renderers = renderers;
}
fn right(&mut self) {
let mut renderers = mem::replace(&mut self.renderers, vec![]);
... | code_fim | hard | {
"lang": "rust",
"repo": "psFried/l-system-prototype",
"path": "/src/render/collection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// rust_model_parser::my_macro!{
// model_tag: vsat_antenna
//
// description: "A VSAT antenna provides physical connectivity between VSAT modems and satellite networks."
//
// fields:
// name:
// type: text
// max_length: 30
//
// serial_number:
// type: text
// nullable: Yes
//
/... | code_fim | hard | {
"lang": "rust",
"repo": "IllicLanthresh/rust-first-contact",
"path": "/src/main2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IllicLanthresh/rust-first-contact path: /src/main2.rs
macro_rules! enum_str {
(enum $enum_name:ident {$($variant:ident),*$(,)?}) => {
enum $enum_name {
$($variant),*
}
impl $enum_name {
fn to_string(&self) -> &'static str {
mat... | code_fim | hard | {
"lang": "rust",
"repo": "IllicLanthresh/rust-first-contact",
"path": "/src/main2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn with_vstr(self, vstr: Option<String>) -> Self {
Sample { vstr, ..self }
}
pub fn with_vbool(self, vbool: Option<bool>) -> Self {
Sample { vbool, ..self }
}
}<|fim_prefix|>// repo: doc-ai/json-eater-1 path: /src/sample.rs
use serde::{Deserialize, Serialize};
use se... | code_fim | hard | {
"lang": "rust",
"repo": "doc-ai/json-eater-1",
"path": "/src/sample.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doc-ai/json-eater-1 path: /src/sample.rs
use serde::{Deserialize, Serialize};
use serde_json::{Value};
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
pub struct Sample {
path: String,
vuint: Option<u64>,
vint: Option<i64>,
vfloat: Option<f64>,
vstr: Option<St... | code_fim | medium | {
"lang": "rust",
"repo": "doc-ai/json-eater-1",
"path": "/src/sample.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn with_vint(self, vint: Option<i64>) -> Self {
Sample { vint, ..self }
}
pub fn with_vfloat(self, vfloat: Option<f64>) -> Self {
Sample { vfloat, ..self }
}
pub fn with_vstr(self, vstr: Option<String>) -> Self {
Sample { vstr, ..self }
}
pub fn w... | code_fim | hard | {
"lang": "rust",
"repo": "doc-ai/json-eater-1",
"path": "/src/sample.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rs().collect::<Vec<char>>()[i * 3 % row.len()] == '#' {
count += 1;
}
}
print!("{}\n", count);
}<|fim_prefix|>// repo: txya900619/AdventOfCode2020 path: /day03_toboggan_trajectory_part1/src/main.rs
use std::io::{stdin, BufRead};
fn main() {
let mut map: Vec<String> = Vec... | code_fim | hard | {
"lang": "rust",
"repo": "txya900619/AdventOfCode2020",
"path": "/day03_toboggan_trajectory_part1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: txya900619/AdventOfCode2020 path: /day03_toboggan_trajectory_part1/src/main.rs
use std::io::{stdin, BufRead};
fn main() {
let mut map: Vec<String> = Vec::new();
let mut count = 0;
for s in stdin().lock().lines() {
let s = s.unwrap();
if s == "stop" {
brea... | code_fim | medium | {
"lang": "rust",
"repo": "txya900619/AdventOfCode2020",
"path": "/day03_toboggan_trajectory_part1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luckypoem/fakio path: /src/lib.rs
extern crate ansi_term;
extern crate env_logger;
#[macro_use]
extern crate futures;
extern crate futures_cpupool;
#[macro_use]
extern crate log;
extern crate rand;
extern crate ring;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate time;
... | code_fim | medium | {
"lang": "rust",
"repo": "luckypoem/fakio",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod v3 {
use ring::digest::{Algorithm, SHA256, SHA256_OUTPUT_LEN};
use crypto::Cipher;
pub const VERSION: u8 = 0x03;
pub const MAX_BUFFER_SIZE: usize = 32 * 1024;
pub const DATA_LEN_LEN: usize = 2;
pub const MAX_PADDING_LEN: usize = 255;
pub static DEFAULT_DIGEST: &'static... | code_fim | medium | {
"lang": "rust",
"repo": "luckypoem/fakio",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akiradeveloper/rust-comp-snippets path: /src/rename.rs
use cargo_snippet::snippet;
#[snippet("Rename")]
struct Rename {
F: Vec<usize>,
R: Vec<usize>,
n: usize,
cur: usize,
}
#[snippet("Rename")]
impl Rename {
pub fn new(n: usize) -> Self {
NodeRename {
F:... | code_fim | medium | {
"lang": "rust",
"repo": "akiradeveloper/rust-comp-snippets",
"path": "/src/rename.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rn = Rename::new(3);
rn.insert(1);
assert_eq!(rn.get(1),0);
assert_eq!(rn.rev(0),1);
rn.insert(1);
assert_eq!(rn.get(1),0);
assert_eq!(rn.rev(0),1);
}<|fim_prefix|>// repo: akiradeveloper/rust-comp-snippets path: /src/rename.rs
use cargo_snippet::snippet;
#[snippet("R... | code_fim | medium | {
"lang": "rust",
"repo": "akiradeveloper/rust-comp-snippets",
"path": "/src/rename.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // not all user txns can be included
assert_eq!(txn_infos.len() as u64, max_txn_num + 1);
let block_gas_used = txn_infos.iter().fold(0u64, |acc, i| acc + i.gas_used());
assert!(
block_gas_used <= max_block_gas_limit,
"block_gas_used is bigger than bl... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/executor/tests/executor_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: starcoinorg/starcoin path: /executor/tests/executor_test.rs
uence_number(account_config::association_address(), &chain_state);
let account1 = Account::new();
{
let miner = Account::new();
let block_meta = BlockMetadata::new(
starcoin_crypto::HashValue::random(... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/executor/tests/executor_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: starcoinorg/starcoin path: /executor/tests/executor_test.rs
ionPayload::ScriptFunction(script_function),
)?;
}
// verify package txn
{
let module = compile_modules_with_address(*alice.address(), TEST_MODULE)
.pop()
.unwrap();
let packa... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/executor/tests/executor_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let status = self.0.status();
if likely(status == ibv_wc_status::IBV_WC_SUCCESS)
{
Ok(ExtendedValidWorkCompletion(self))
}
else
{
Err(WorkRequestError
{
status: status,
vendorErrorCode: self.0.ibv_wc_read_vendor_err(),
})
}
}
}<|fim_prefix|>// repo: jisuanjidaqiang... | code_fim | hard | {
"lang": "rust",
"repo": "jisuanjidaqiang/rdma-core",
"path": "/workspace/rdma-core/src/verbs/completionQueueContexts/workCompletions/ExtendedWorkCompletion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Not present if the extended completion queue was not created with IBV_WC_EX_WITH_QP_NUM
#[inline(always)]
fn receiveWorkRequestLocalQueuePairNumberForSharedReceiveQueue(&self) -> QueuePairNumber
{
self.0.ibv_wc_read_qp_num()
}
#[inline(always)]
fn workRequestError(self) -> Result<Self::Vali... | code_fim | hard | {
"lang": "rust",
"repo": "jisuanjidaqiang/rdma-core",
"path": "/workspace/rdma-core/src/verbs/completionQueueContexts/workCompletions/ExtendedWorkCompletion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/ink path: /crates/ink/tests/ui/storage_item/pass/complex_non_packed_enum.rs
use ink_prelude::vec::Vec;
use ink_primitives::KeyComposer;
use ink_storage::{
traits::{
AutoKey,
StorageKey,
},
Lazy,
Mapping,
};
#[derive(Default, scale::Encode, scale::Decod... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/ink",
"path": "/crates/ink/tests/ui/storage_item/pass/complex_non_packed_enum.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> contract.a.set(&NonPacked::<_>::F {
a: Default::default(),
});
let variant = if let Some(NonPacked::<_>::F { a }) = contract.a.get() {
a
} else {
panic!("Wrong variant")
};
assert_eq!(
variant.key(),
... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/ink",
"path": "/crates/ink/tests/ui/storage_item/pass/complex_non_packed_enum.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Canop/country-slice path: /src/utils.rs
use crate::curve::Curve;
use bevy::{prelude::*, render::mesh::VertexAttributeValues};
pub fn bevy_mesh_from_trimesh(
tri_mesh: tri_mesh::mesh::Mesh,
uvs: Vec<[f32; 2]>,
curve_length: f32,
bevy_mesh: &mut Mesh,
) {
let vert_count = tri_... | code_fim | hard | {
"lang": "rust",
"repo": "Canop/country-slice",
"path": "/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(vertex_attribute) = reader
.read_normals()
.map(|v| VertexAttributeValues::Float3(v.collect()))
{
bevy_mesh.set_attribute(Mesh::ATTRIBUTE_NORMAL, vertex_attribute);
}
if let Some(vertex_attribute) ... | code_fim | hard | {
"lang": "rust",
"repo": "Canop/country-slice",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mineichen/aoc2020 path: /day12/src/lib.rs
pub fn load(path: &str) -> impl Iterator<Item=Cmd> {
utils::LineReaderIterator::from_file(
path,
move |line| {
let mut it = line.char_indices();
let (_, code) = it.next().ok_or(utils::Error::Fo... | code_fim | hard | {
"lang": "rust",
"repo": "mineichen/aoc2020",
"path": "/day12/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use {super::*};
#[test]
fn calc_waypoint_test() {
let cmd = [
Cmd::Forward(10.),
Cmd::North(3.),
Cmd::Forward(7.),
Cmd::Right(90.),
Cmd::Forward(11.)
];
let (x, y) = calc_waypoint(cmd.i... | code_fim | hard | {
"lang": "rust",
"repo": "mineichen/aoc2020",
"path": "/day12/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Copy, Clone)]
pub enum Cmd {
North(f64),
South(f64),
West(f64),
East(f64),
Forward(f64),
Right(f64),
Left(f64)
}
#[cfg(test)]
mod tests {
use {super::*};
#[test]
fn calc_waypoint_test() {
let cmd = [
Cmd::Forward(10.),
... | code_fim | hard | {
"lang": "rust",
"repo": "mineichen/aoc2020",
"path": "/day12/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lealemK2/Lemaj path: /src/database/db.rs
use dotenv::dotenv;
use rocket::fairing::{self, AdHoc};
use rocket::{Build, Rocket};
use serde::Deserialize;
use tokio_postgres::NoTls;
pub type Db = deadpool_postgres::Pool;
<|fim_suffix|>impl Config {
pub fn from_env() -> Result<Self, ::config::Co... | code_fim | medium | {
"lang": "rust",
"repo": "lealemK2/Lemaj",
"path": "/src/database/db.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn stage() -> AdHoc {
AdHoc::on_ignite("Database Stage", |rocket| async {
rocket.attach(AdHoc::try_on_ignite("Database", init_db))
})
}<|fim_prefix|>// repo: lealemK2/Lemaj path: /src/database/db.rs
use dotenv::dotenv;
use rocket::fairing::{self, AdHoc};
use rocket::{Build, Rocket};
u... | code_fim | medium | {
"lang": "rust",
"repo": "lealemK2/Lemaj",
"path": "/src/database/db.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn init_db(rocket: Rocket<Build>) -> fairing::Result {
dotenv().ok();
let cfg = Config::from_env().unwrap();
let pool = match cfg.pg.create_pool(NoTls) {
Ok(db) => db,
Err(e) => {
error!("Failed to connect to database: {}", e);
return Err(rocket);
... | code_fim | hard | {
"lang": "rust",
"repo": "lealemK2/Lemaj",
"path": "/src/database/db.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eissen/fuchsia path: /src/connectivity/overnet/lib/core/src/socket_link.rs
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Controls one link to another node over a zx socket.
... | code_fim | hard | {
"lang": "rust",
"repo": "Eissen/fuchsia",
"path": "/src/connectivity/overnet/lib/core/src/socket_link.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Send first frame
let (mut rx_bytes, mut tx_bytes) = futures::io::AsyncReadExt::split(
fidl::AsyncSocket::from_socket(socket).context("asyncify socket")?,
);
let make_format = || -> Box<dyn Format> {
if let Some(d) = duration_per_byte {
Box::new(LossyBinary::n... | code_fim | hard | {
"lang": "rust",
"repo": "Eissen/fuchsia",
"path": "/src/connectivity/overnet/lib/core/src/socket_link.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cstorey/fringe-futures path: /examples/trivial.rs
extern crate fringe;
extern crate futures;
extern crate fringe_futures;
use futures::{Future };
use fringe_futures::FringeFut;
<|fim_suffix|> println!("Before:{:?}", f);
let res = f.wait();
println!("res:{:?}", res);
}<|fim_middle|>f... | code_fim | hard | {
"lang": "rust",
"repo": "cstorey/fringe-futures",
"path": "/examples/trivial.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Before:{:?}", f);
let res = f.wait();
println!("res:{:?}", res);
}<|fim_prefix|>// repo: cstorey/fringe-futures path: /examples/trivial.rs
extern crate fringe;
extern crate futures;
extern crate fringe_futures;
use futures::{Future };
use fringe_futures::FringeFut;
fn main() {
<|f... | code_fim | hard | {
"lang": "rust",
"repo": "cstorey/fringe-futures",
"path": "/examples/trivial.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let f = FringeFut::<usize, ()>::new(|yielder| {
for n in 0..10 {
let r = yielder.await(futures::finished::<u32, ()>(n)).expect("await");
println!("n:{:?}", r);
}
Ok(42usize)
});
println!("Before:{:?}", f);
let res = f.wait();
println!("r... | code_fim | medium | {
"lang": "rust",
"repo": "cstorey/fringe-futures",
"path": "/examples/trivial.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stephanelpaul/swc path: /bundler/src/bundler/chunk/mod.rs
use super::{load::TransformedModule, Bundler};
use crate::{
bundler::chunk::merge::Ctx, id::ModuleId, load::Load, resolve::Resolve,
util::IntoParallelIterator, Bundle,
};
use ahash::AHashMap;
use anyhow::{Context, Error};
use fxha... | code_fim | hard | {
"lang": "rust",
"repo": "stephanelpaul/swc",
"path": "/bundler/src/bundler/chunk/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use crate::bundler::tests::suite;
use swc_common::FileName;
#[test]
fn cjs_chunk() {
suite()
.file(
"main.js",
"
require('./a');
require('./b');
"... | code_fim | hard | {
"lang": "rust",
"repo": "stephanelpaul/swc",
"path": "/bundler/src/bundler/chunk/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<L, R> Bundler<'_, L, R>
where
L: Load,
R: Resolve,
{
/// `entries` - Entry modules (provided by user) by it's basename.
///
/// # How it works
///
/// For first, we load all dependencies and determine all entries.
pub(super) fn chunk(
&self,
entries: AH... | code_fim | hard | {
"lang": "rust",
"repo": "stephanelpaul/swc",
"path": "/bundler/src/bundler/chunk/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-sql-parser/src/apllodb_sql_parser/apllodb_ast.rs
//! apllodb-SQL's AST.
//!
//! This module provides the root node ([ApllodbAst](struct.ApllodbAst.html)) and other intermediate nodes.
//!
//! Intermediate nodes have 1-to-1 relationship with terms defined in [apllod... | code_fim | hard | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-sql-parser/src/apllodb_sql_parser/apllodb_ast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Eq, PartialEq, Hash, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct SelectCommand {
pub select_fields: NonEmptyVec<SelectField>,
pub from_item: Option<FromItem>,
pub where_condition: Option<Condition>,
pub grouping_elements: Option<NonEmpt... | code_fim | hard | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-sql-parser/src/apllodb_sql_parser/apllodb_ast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nathanj/rustboy path: /src/joypad.rs
use sdl2::keyboard::Keycode;
use mem;
use interrupt;
#[derive(Debug)]
pub struct Joypad {
pub flags : u8,
up : bool,
down : bool,
left : bool,
right : bool,
b : bool,
a : bool,
select : bool,
start : bool,
}
const JOYPAD... | code_fim | hard | {
"lang": "rust",
"repo": "nathanj/rustboy",
"path": "/src/joypad.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn handle_input(&mut self, mm: &mut mem::MemoryMap, keycode: Keycode, pressed: bool) {
//println!("keycode={} pressed={}", keycode, pressed);
match keycode {
Keycode::Up => { self.up = pressed; }
Keycode::Down => { self.down = pressed; }
Keycode... | code_fim | hard | {
"lang": "rust",
"repo": "nathanj/rustboy",
"path": "/src/joypad.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lyswifter/forest path: /blockchain/chain/src/weight.rs
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use forest_blocks::Tipset;
use fvm_shared::bigint::BigInt;
use ipld_blockstore::BlockStore;
<|fim_suffix|>/// The `Scale` trait abstracts away the logic of... | code_fim | medium | {
"lang": "rust",
"repo": "lyswifter/forest",
"path": "/blockchain/chain/src/weight.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The `Scale` trait abstracts away the logic of assigning a weight to a chain,
/// which can be consensus specific. For example it can depend on the stake and
/// power of validators, or it can be as simple as the height of the blocks in
/// a `Nakamoto` style consensus.
pub trait Scale {
/// Calcul... | code_fim | medium | {
"lang": "rust",
"repo": "lyswifter/forest",
"path": "/blockchain/chain/src/weight.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.current_token = self.get_next_token();
let left = self.current_token;
self.eat(INTEGER);
let op = self.current_token;
self.eat(PLUS);
let right = self.current_token;
self.eat(INTEGER);
return left.value + right.value;
}
}
fn m... | code_fim | hard | {
"lang": "rust",
"repo": "Kadekool/Interpreter-Practice",
"path": "/Basic-Calculator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kadekool/Interpreter-Practice path: /Basic-Calculator.rs
let INTEGER = "INTEGER";
let PLUS = "PLUS";
let EOF = "EOF";
let Minus = "Minus";
struct Token{
type: String;
value: String;
}
impl Token{
fn init(&self,type: &str, value: &i32) -> Token{
Token {
type:type.... | code_fim | hard | {
"lang": "rust",
"repo": "Kadekool/Interpreter-Practice",
"path": "/Basic-Calculator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn eat(&self, token_type: String){
if (self.current_token.type == token_type){
self.current_token = self.get_next_token();
}else{
self.error()
}
}
fn expr(&self) ->i32{
self.current_token = self.get_next_token();
let left = self... | code_fim | hard | {
"lang": "rust",
"repo": "Kadekool/Interpreter-Practice",
"path": "/Basic-Calculator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn local_addr(_: &net::UnixStream) -> io::Result<SocketAddr> {
os_required!()
}
pub(crate) fn peer_addr(_: &net::UnixStream) -> io::Result<SocketAddr> {
os_required!()
}
}<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/mio-0.7.11/s... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/mio-0.7.11/src/sys/shell/uds.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn pair() -> io::Result<(net::UnixStream, net::UnixStream)> {
os_required!()
}
pub(crate) fn local_addr(_: &net::UnixStream) -> io::Result<SocketAddr> {
os_required!()
}
pub(crate) fn peer_addr(_: &net::UnixStream) -> io::Result<SocketAddr> {
os_req... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/mio-0.7.11/src/sys/shell/uds.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/mio-0.7.11/src/sys/shell/uds.rs
pub(crate) mod datagram {
use crate::net::SocketAddr;
use std::io;
use std::os::unix::net;
use std::path::Path;
pub(crate) fn bind(_: &Path) -> io::Result<net::UnixDatagram> {
os_r... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/mio-0.7.11/src/sys/shell/uds.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>//#set_loc(50, "range.rs");
let mut _klen: int;
let mut _trans = 0;
let mut _keys: int;
let mut _goto_targ = 0;
loop _goto: {
match _goto_targ {
0 => {
if p == pe {
_goto_targ = 4;
loop _goto;
}
if c... | code_fim | hard | {
"lang": "rust",
"repo": "JohnMurray/learn",
"path": "/ragel/range.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JohnMurray/learn path: /ragel/range.rs
//#set_loc(1, "range.rl");
//#set_loc(5, "range.rl");
//#set_loc(9, "range.rs");
static _range_key_offsets: &[i8] = &[
0, 0, 2
];
static _range_trans_keys: &[u8] = &[
97, 122, 0
];
static _range_single_lengths: &[i8] = &[
0, 0... | code_fim | hard | {
"lang": "rust",
"repo": "JohnMurray/learn",
"path": "/ragel/range.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
//#set_loc(8, "range.rl");
//#set_loc(43, "range.rs");
fn main() -> () {
let cs = range_start;
//#set_loc(9, "range.rl");
//#set_loc(50, "range.rs");
let mut _klen: int;
let mut _trans = 0;
let mut _keys: int;
let mut _goto_targ = 0;
loop _goto: {
match _goto_targ {... | code_fim | hard | {
"lang": "rust",
"repo": "JohnMurray/learn",
"path": "/ragel/range.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nikofil/competitive path: /adventofcode2022/3b.rs
fn main() {
let mut j = include_str!("3").lines();
let mut o=0u64;
while let(Some(x),Some(y),Some(z))= (j.next(),j.next(),j.next()) {
x.bytes().filter(<|fim_suffix|>s char); o += if c < 91 {c-64+26} else {c-96} as u64});
}... | code_fim | medium | {
"lang": "rust",
"repo": "nikofil/competitive",
"path": "/adventofcode2022/3b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>s char); o += if c < 91 {c-64+26} else {c-96} as u64});
}
println!("{}", o);
}<|fim_prefix|>// repo: nikofil/competitive path: /adventofcode2022/3b.rs
fn main() {
let mut j = include_str!("3").lines();
let mut o=0u64;
while <|fim_middle|>let(Some(x),Some(y),Some(z))= (j.next(),j.next(... | code_fim | medium | {
"lang": "rust",
"repo": "nikofil/competitive",
"path": "/adventofcode2022/3b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: francescofranze/pratt path: /src/lib.rs
#[cfg(not(feature="gc3c"))]
#[macro_use]
pub mod rcbox;
#[cfg(not(feature="gc3c"))]
pub use rcbox::PrattBox;
#[cfg(feature="gc3c")]
extern crate gc3c;
#[cfg(feature="gc3c")]
use gc3c::{Gc, Mark};
#[cfg(feature="gc3c")]
pub type PrattBox<T> = Gc<T>;
#[cf... | code_fim | hard | {
"lang": "rust",
"repo": "francescofranze/pratt",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> this.borrow_mut().led(this.clone(), self, left)
}
pub fn parse(&self, rbp: u8) -> PrattBox<S> {
let mut t = self.current().unwrap();
self.advance();
let mut left = self.nud(t);
let mut lookahead = self.current().unwrap();
while rbp < lookahead.bor... | code_fim | hard | {
"lang": "rust",
"repo": "francescofranze/pratt",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for scheme in self.0.iter() {
match scheme.1 {
Some(ref data) => {
write!(f, "{} {}", scheme.0, base64::encode(&data))?;
}
None => {
write!(f, "{}", scheme.0)?;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/sardine-rs",
"path": "/hyper/src/www_authenticate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Devolutions/sardine-rs path: /hyper/src/www_authenticate.rs
use base64;
use hyperx;
use hyperx::header;
use std::fmt;
use std::str;
use hyperx::header::RawLike;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum AuthenticateScheme {
Srd,
}
impl fmt::Display for AuthenticateScheme {
fn f... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/sardine-rs",
"path": "/hyper/src/www_authenticate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ifive")))]
pub use maix_m1w::*;
#[cfg(all(feature = "bsp_maix_m1w", not(feature = "bsp_hifive")))]
pub use maix_m1w::MaixM1W as target_board;<|fim_prefix|>// repo: Knight-Ops/riscv-rtos path: /src/bsp/mod.rs
#[cfg(all(feature = "bsp_hifive", not(feature = "bsp_maix_m1w")))]
pub mod hifive;
#[cfg(all(feat... | code_fim | hard | {
"lang": "rust",
"repo": "Knight-Ops/riscv-rtos",
"path": "/src/bsp/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Knight-Ops/riscv-rtos path: /src/bsp/mod.rs
#[cfg(all(feature = "bsp_hifive", not(feature = "bsp_maix_m1w")))]
pub mod hifive;
#[cfg(all(feature = "bsp_hifive", not(feature = "bsp_maix_m1w")))]
pub use hifive::*;
#[cfg(all(feature = "bsp_hifive", not(feature = "bsp_maix_m1w")))]
pub use hifive::... | code_fim | medium | {
"lang": "rust",
"repo": "Knight-Ops/riscv-rtos",
"path": "/src/bsp/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Valgrind notices this magic instruction sequence and interprets
// it as a kind of hypercall. When not running under Valgrind,
// the instructions do nothing and `default` is returned.
asm!("
rolq $$3, %rdi
rolq $$13, %rdi
rolq $$61, %rdi
rolq $$51, %rd... | code_fim | medium | {
"lang": "rust",
"repo": "steveklabnik/vgrs",
"path": "/src/arch/x86_64-linux-macos.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steveklabnik/vgrs path: /src/arch/x86_64-linux-macos.rs
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#[inline(always)]
pub unsafe fn re... | code_fim | medium | {
"lang": "rust",
"repo": "steveklabnik/vgrs",
"path": "/src/arch/x86_64-linux-macos.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args: [uint, ..6] = [request, arg1, arg2, arg3, arg4, arg5];
let mut result: uint;
// Valgrind notices this magic instruction sequence and interprets
// it as a kind of hypercall. When not running under Valgrind,
// the instructions do nothing and `default` is returned.
asm!(... | code_fim | medium | {
"lang": "rust",
"repo": "steveklabnik/vgrs",
"path": "/src/arch/x86_64-linux-macos.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: genonullfree/lx path: /src/main.rs
use clap::{App, AppSettings, Arg};
use std::fs;
use std::os::unix::fs::{FileTypeExt, PermissionsExt};
use std::str;
fn main() {
let matches = App::new("lx")
.version("0.1.0")
.author("geno")
.about("List files with hex formatted out... | code_fim | hard | {
"lang": "rust",
"repo": "genonullfree/lx",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let meta = match fs::metadata(file) {
Ok(x) => x,
Err(_) => return '?',
};
let ftype: char;
if meta.file_type().is_symlink() {
ftype = 's';
} else if meta.file_type().is_dir() {
ftype = 'd';
} else if meta.file_type().is_block_device() {
ftyp... | code_fim | hard | {
"lang": "rust",
"repo": "genonullfree/lx",
"path": "/src/main.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.