text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> // let a = Select {
// props: SelectProps { age: 1 },
// s: 1,
// };
// let s = a.render;
// let a:Vec<impl ToVNodeChild> = vec![]
// a.push("value");
// a.push(1);
// let mut b = json!({"a":"123","b":"234"}).as_object().unwrap();
// let mut c = json!({"d":"... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/kelake",
"path": "/examples/html/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laopo001/kelake path: /examples/html/src/main.rs
#![allow(unused)]
use kelake::vnode::{format, Component, ToVNodeChild, VNode, VNodeChild};
use kelake_macro::react;
// use serde_json::{json, Value};
struct Select {
s: i32,
props: SelectProps,
}
struct SelectProps {
age: i32,
}
impl... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/kelake",
"path": "/examples/html/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Patrik-Stas/play_with_rust path: /old_futures/src/pwpatrik.rs
use std::collections::HashMap;
pub fn patrik_plays()
{
let mut routes: HashMap<String, i32> = HashMap::new();
routes.insert("a".into(), 1);
routes.insert("b".into(), 2);
routes.insert("c".into(), 3);
routes.insert... | code_fim | hard | {
"lang": "rust",
"repo": "Patrik-Stas/play_with_rust",
"path": "/old_futures/src/pwpatrik.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let collected = routes.iter().map(|keyvalue| keyvalue.1).collect::<Vec<_>>();;
println!("iter collected = {:?}", collected);
}<|fim_prefix|>// repo: Patrik-Stas/play_with_rust path: /old_futures/src/pwpatrik.rs
use std::collections::HashMap;
pub fn patrik_plays()
{
let mut routes: HashMap<St... | code_fim | medium | {
"lang": "rust",
"repo": "Patrik-Stas/play_with_rust",
"path": "/old_futures/src/pwpatrik.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let aq_custom = routes.get("aq".into()).unwrap_or_else(||&123);
println!("value = {:?} (custom result calculation)", aq_custom);
let collected = routes.iter().map(|keyvalue| keyvalue.1).collect::<Vec<_>>();;
println!("iter collected = {:?}", collected);
}<|fim_prefix|>// repo: Patrik-Stas... | code_fim | hard | {
"lang": "rust",
"repo": "Patrik-Stas/play_with_rust",
"path": "/old_futures/src/pwpatrik.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laopo001/leetcode-rust path: /src/super_egg_drop/mod.rs
#![allow(non_snake_case)]
struct Solution;
// Runtime: 8 ms, faster than 50.00%
impl Solution {
pub fn super_egg_drop(k: i32, n: i32) -> i32 {
if k == 1 {
return n;
}
let K = k as usize;
let N... | code_fim | medium | {
"lang": "rust",
"repo": "laopo001/leetcode-rust",
"path": "/src/super_egg_drop/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return m as i32;
}
}
}
N as i32
}
}
#[test]
fn test() {
assert_eq!(Solution::super_egg_drop(2, 7), 4);
}<|fim_prefix|>// repo: laopo001/leetcode-rust path: /src/super_egg_drop/mod.rs
#![allow(non_snake_case)]
struct Solution;
// Runtime: 8 ms,... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/leetcode-rust",
"path": "/src/super_egg_drop/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DNature/rover path: /src/utils/table.rs
use prettytable::{format::consts::FORMAT_BOX_CHARS, Table};
<|fim_suffix|>pub fn get_table() -> Table {
let mut table = Table::new();
table.set_format(*FORMAT_BOX_CHARS);
table
}<|fim_middle|>pub use prettytable::{cell, row};
| code_fim | easy | {
"lang": "rust",
"repo": "DNature/rover",
"path": "/src/utils/table.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_table() -> Table {
let mut table = Table::new();
table.set_format(*FORMAT_BOX_CHARS);
table
}<|fim_prefix|>// repo: DNature/rover path: /src/utils/table.rs
use prettytable::{format::consts::FORMAT_BOX_CHARS, Table};
<|fim_middle|>pub use prettytable::{cell, row};
| code_fim | easy | {
"lang": "rust",
"repo": "DNature/rover",
"path": "/src/utils/table.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: R1tschY/qobject-rs path: /tests/slots/src/lib.rs
#![allow(unused)]
use qt5qml::core::{QMetaObject, QMetaProperty, QObject, QObjectRef, QString, ToQString};
use qt5qml::cstr;
use std::collections::HashMap;
use std::convert::TryInto;
use std::ptr;
include!(concat!(env!("OUT_DIR"), "/qffi_TestObj... | code_fim | hard | {
"lang": "rust",
"repo": "R1tschY/qobject-rs",
"path": "/tests/slots/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> obj.own_properties()
.map(|e| (e.name().to_str().unwrap().to_owned(), e))
.collect()
}
fn slot_calls(obj: &mut QObject) -> i32 {
let props = get_props(obj.meta_object());
props
.get("slotCalls")
.unwrap()
.read(obj.as_qobject())
.try_into()
... | code_fim | hard | {
"lang": "rust",
"repo": "R1tschY/qobject-rs",
"path": "/tests/slots/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let secret_number_guess: u32 = match secret_number_guess.trim().parse() {
Ok(num) => num,
Err(_) => {
println!("\n Please enter a number");
continue;
}
};
match secret_number_guess.cmp(&secret_number) {
Ordering::Less => println!("\n Your guess is less ... | code_fim | medium | {
"lang": "rust",
"repo": "alexUXUI/learn-rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexUXUI/learn-rust path: /src/main.rs
use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn main() {
loop {
println!("\n Generating random number betwen 1 - 3 🌀");
let secret_number = rand::thread_rng().gen_range(1, 4);
<|fim_suffix|> match secret_number_guess.cmp(&secret_numb... | code_fim | hard | {
"lang": "rust",
"repo": "alexUXUI/learn-rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unovor/frame path: /minicbor-0.5.1/src/encode.rs
//! Traits and types for encoding CBOR.
//!
//! This module defines the trait [`Encode`] and the actual [`Encoder`].
//! It also defines a [`Write`] trait to store the encoded bytes.
mod encoder;
mod error;
pub mod write;
pub use encoder::Encode... | code_fim | hard | {
"lang": "rust",
"repo": "unovor/frame",
"path": "/minicbor-0.5.1/src/encode.rs",
"mode": "psm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "std")]
encode_sequential! {
Vec<T>
std::collections::VecDeque<T>
std::collections::LinkedList<T>
std::collections::BinaryHeap<T>
std::collections::HashSet<T>
std::collections::BTreeSet<T>
}
macro_rules! encode_arrays {
($($n:expr)*) => {
$(
... | code_fim | hard | {
"lang": "rust",
"repo": "unovor/frame",
"path": "/minicbor-0.5.1/src/encode.rs",
"mode": "spm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
impl Encode for () {
fn encode<W: Write>(&self, _: &mut Encoder<W>) -> Result<(), Error<W::Error>> {
Ok(())
}
}
#[cfg(target_pointer_width = "32")]
impl Encode for usize {
fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>> {
e... | code_fim | hard | {
"lang": "rust",
"repo": "unovor/frame",
"path": "/minicbor-0.5.1/src/encode.rs",
"mode": "spm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if h == 1 || w == 1 {
println!("1");
} else {
let col0 = (h + 2 - 1) / 2;
let col1 = h / 2;
let n_col0 = (w + 2 - 1) / 2;
let n_col1 = w / 2;
println!("{}", col0 * n_col0 + col1 * n_col1);
}
}<|fim_prefix|>// repo: doraneko94/RustAntBook path: /... | code_fim | medium | {
"lang": "rust",
"repo": "doraneko94/RustAntBook",
"path": "/atcoder/examples/panasonic2020b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doraneko94/RustAntBook path: /atcoder/examples/panasonic2020b.rs
fn read1<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
let s = r... | code_fim | medium | {
"lang": "rust",
"repo": "doraneko94/RustAntBook",
"path": "/atcoder/examples/panasonic2020b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>vanagari
HTCHANAKYA = 56, // 56 Indic encoding - Devanagari
UTF16BE = 57, // big-endian UTF-16
UTF16LE = 58, // little-endian UTF-16
UTF32BE = 59, // big-endian UTF-32
UTF32LE = 60, // little-endian UTF-32
BINARYENC... | code_fim | hard | {
"lang": "rust",
"repo": "emk/rust-cld2",
"path": "/cld2-sys/src/encodings.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emk/rust-cld2 path: /cld2-sys/src/encodings.rs
#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Clone,Copy)]
#[repr(C)]
pub enum Encoding {
ISO_8859_1 = 0, // ASCII
ISO_8859_2 = 1, // Latin2
ISO_8859_3 = 2, //
ISO_8859_4 = 3, // Lat... | code_fim | hard | {
"lang": "rust",
"repo": "emk/rust-cld2",
"path": "/cld2-sys/src/encodings.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_put_calls_notifiers() {
isar!(isar, col => col!(oid => DataType::Long));
let p = col.get_properties().first().unwrap().1;
let mut qb1 = col.new_query_builder();
qb1.set_filter(LongBetweenCond::filter(p, 1, 1).unwrap());
let q1 = qb1.build();... | code_fim | hard | {
"lang": "rust",
"repo": "medmedmedic/isar-core",
"path": "/src/collection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn unlink_all(
&self,
txn: &mut IsarTxn,
link_index: usize,
backlink: bool,
oid: i64,
) -> Result<()> {
let link = self.get_link_backlink(link_index, backlink)?;
txn.write(|cursors, change_set| {
self.register_link_change(chan... | code_fim | hard | {
"lang": "rust",
"repo": "medmedmedic/isar-core",
"path": "/src/collection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: medmedmedic/isar-core path: /src/collection.rs
return illegal_arg("Invalid IndexKey for this collection");
}
Ok(())
}
pub fn auto_increment(&self, _txn: &mut IsarTxn) -> Result<i64> {
self.auto_increment_internal()
}
pub(crate) fn auto_increment_in... | code_fim | hard | {
"lang": "rust",
"repo": "medmedmedic/isar-core",
"path": "/src/collection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pariz/advent-of-code-2020 path: /src/day01/mod.rs
use itertools::Itertools;
fn parse_lines<T: std::str::FromStr>(input: &str) -> impl Iterator<Item = T> + '_ {
input.trim().lines().filter_map(|line| line.parse().ok())
}
pub fn part1(input: &str) -> Option<u32> {
let nums: Vec<u32> = pa... | code_fim | medium | {
"lang": "rust",
"repo": "pariz/advent-of-code-2020",
"path": "/src/day01/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
static TEST_INPUT: &str = include_str!("test_input.txt");
static INPUT: &str = include_str!("input.txt");
#[test]
fn part1_works() {
assert_eq!(part1(TEST_INPUT), Some(514_579));
assert_eq!(part1(INPUT), Some(1_019_371));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "pariz/advent-of-code-2020",
"path": "/src/day01/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.as_ref()
}
}
impl<T, V> AsMut<[T]> for LsVec<T, V>
where
T: Float,
V: Clone + IndexMut<usize, Output = T> + HasLen + Sized + AsMut<[T]>,
{
fn as_mut(&mut self) -> &mut [T] {
self.0.as_mut()
}
}
impl<T, V> Deref for LsVec<T, V>
where
T: Float,
V: Clone +... | code_fim | hard | {
"lang": "rust",
"repo": "astrojhgu/scorus",
"path": "/src/linear_space/type_wrapper.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astrojhgu/scorus path: /src/linear_space/type_wrapper.rs
#![allow(clippy::needless_range_loop)]
use super::traits::{IndexableLinearSpace, InnerProdSpace, LinearSpace, PDInnerProdSpace};
use crate::utils::HasLen;
use num::traits::Float;
use std::convert::{AsMut, AsRef};
use std::ops::{Add, Mul, S... | code_fim | hard | {
"lang": "rust",
"repo": "astrojhgu/scorus",
"path": "/src/linear_space/type_wrapper.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bdero/rust-examples path: /rust_by_example/10.1_library/main.rs
// This should be compiled as a library
<|fim_suffix|>fn private_function() {
println!("called library's private_function()");
}
pub fn indirect_access() {
print!("called library's indirect_access(), that\n> ");
priva... | code_fim | medium | {
"lang": "rust",
"repo": "bdero/rust-examples",
"path": "/rust_by_example/10.1_library/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn indirect_access() {
print!("called library's indirect_access(), that\n> ");
private_function();
}<|fim_prefix|>// repo: bdero/rust-examples path: /rust_by_example/10.1_library/main.rs
// This should be compiled as a library
pub fn public_function() {
println!("called library's public... | code_fim | medium | {
"lang": "rust",
"repo": "bdero/rust-examples",
"path": "/rust_by_example/10.1_library/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("called library's private_function()");
}
pub fn indirect_access() {
print!("called library's indirect_access(), that\n> ");
private_function();
}<|fim_prefix|>// repo: bdero/rust-examples path: /rust_by_example/10.1_library/main.rs
// This should be compiled as a library
<|fim_mi... | code_fim | medium | {
"lang": "rust",
"repo": "bdero/rust-examples",
"path": "/rust_by_example/10.1_library/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> commands: &mut Commands,
time: Res<Time>,
mut bodies: ResMut<bevy_rapier2d::rapier::dynamics::RigidBodySet>,
movers: Query<(
Entity,
&bevy_rapier2d::physics::RigidBodyHandleComponent,
&MoveTowards,
&crate::game::OwnedBy,
)>,
centers: Query<&GlobalTra... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/wotm",
"path": "/src/space.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn orbite_around(
time: Res<Time>,
mut bodies: ResMut<bevy_rapier2d::rapier::dynamics::RigidBodySet>,
orbiters: Query<(&bevy_rapier2d::physics::RigidBodyHandleComponent, &Orbiter)>,
centers: Query<&GlobalTransform>,
) {
for (rigid_body, orbiter) in orbiters.iter() {
let mut bod... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/wotm",
"path": "/src/space.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/wotm path: /src/space.rs
ips[match owned_by {
crate::game::OwnedBy::Player(i) => *i,
crate::game::OwnedBy::Neutral => 2,
}]
.choose(&mut rand::thread_rng())
.unwrap();
let orbiter = Orbiter::every(
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/wotm",
"path": "/src/space.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>b mod ex17_12;
pub mod ex17_13;
pub mod ex17_14;
pub mod ex17_15;
pub mod ex17_16;
pub mod ex17_17;<|fim_prefix|>// repo: jabcross/My-CtCI-Solutions path: /rust/src/chapter_17/mod.rs
#![allow(clippy::needless_range_loop)]
#![allow(clippy::len_zero)]
#![allow(clippy::comparison_chain)]
#![allow(dead_code)... | code_fim | medium | {
"lang": "rust",
"repo": "jabcross/My-CtCI-Solutions",
"path": "/rust/src/chapter_17/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jabcross/My-CtCI-Solutions path: /rust/src/chapter_17/mod.rs
#![allow(clippy::needless_range_loop)]
#![allow(clippy::len_zero)]
#![allow(clippy::comparison_chai<|fim_suffix|>b mod ex17_12;
pub mod ex17_13;
pub mod ex17_14;
pub mod ex17_15;
pub mod ex17_16;
pub mod ex17_17;<|fim_middle|>n)]
#![al... | code_fim | medium | {
"lang": "rust",
"repo": "jabcross/My-CtCI-Solutions",
"path": "/rust/src/chapter_17/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Faultless/rust-training path: /finder/src/main.rs
extern crate lib;
extern create util;
use lib::{connector, filterer, scraper};
<|fim_suffix|> // filter City Pop Audio.
let city_pop: vec<Media> = filterer::filter_by(util::Type::Genre, media_vec);
}<|fim_middle|>fn main() {
// Connect to ... | code_fim | medium | {
"lang": "rust",
"repo": "Faultless/rust-training",
"path": "/finder/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // filter City Pop Audio.
let city_pop: vec<Media> = filterer::filter_by(util::Type::Genre, media_vec);
}<|fim_prefix|>// repo: Faultless/rust-training path: /finder/src/main.rs
extern crate lib;
extern create util;
use lib::{connector, filterer, scraper};
fn main() {
// Connect to a site.
let ... | code_fim | medium | {
"lang": "rust",
"repo": "Faultless/rust-training",
"path": "/finder/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: openstax/adaptarr-server path: /crates/web/src/extractors.rs
use actix_web::{
Either,
FromRequest,
HttpMessage,
HttpRequest,
HttpResponse,
ResponseError,
dev::Payload,
error::ErrorUnsupportedMediaType,
http::{StatusCode, header::ACCEPT_LANGUAGE},
web::{For... | code_fim | hard | {
"lang": "rust",
"repo": "openstax/adaptarr-server",
"path": "/crates/web/src/extractors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn deref(&self) -> &Connection {
&self.0
}
}
/// Error returned by [`Database`]'s implementation of [`FromRequest`] when
/// connection pool has not been configured.
#[derive(ApiError, Debug, Fail)]
#[api(internal)]
#[fail(display = "database pool needs to be set for Database extraction t... | code_fim | hard | {
"lang": "rust",
"repo": "openstax/adaptarr-server",
"path": "/crates/web/src/extractors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Error returned by [`Locale`]'s implementation of [`FromRequest`] when locale
/// data has not been configured.
#[derive(ApiError, Debug, Fail)]
#[api(internal)]
#[fail(display = "locale data (Data<I18n>) needs to be set for Locale \
extraction to work")]
pub struct LocaleDataMissingError;
/// Par... | code_fim | hard | {
"lang": "rust",
"repo": "openstax/adaptarr-server",
"path": "/crates/web/src/extractors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ggez/ggez path: /examples/04_snake.rs
ly across the screen because
// it's moving a full tile every frame.
const DESIRED_FPS: u32 = 8;
/// Now we define a struct that will hold an entity's position on our game board
/// or grid which we defined above. We'll use signed integers because we only w... | code_fim | hard | {
"lang": "rust",
"repo": "ggez/ggez",
"path": "/examples/04_snake.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Next we create an enum that will represent all the possible
/// directions that our snake could move.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Direction {
Up,
Down,
Left,
Right,
}
impl Direction {
/// We create a helper function that will allow us to easily get the invers... | code_fim | hard | {
"lang": "rust",
"repo": "ggez/ggez",
"path": "/examples/04_snake.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Snake {
pub fn new(pos: GridPosition) -> Self {
let mut body = VecDeque::new();
// Our snake will initially have a head and one body segment,
// and will be moving to the right.
body.push_back(Segment::new((pos.x - 1, pos.y).into()));
Snake {
he... | code_fim | hard | {
"lang": "rust",
"repo": "ggez/ggez",
"path": "/examples/04_snake.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The type of asynchronous futures returned by method `gossip_subscription`.
///
/// The future resolves to a stream that will be used by the protocol
/// implementation to produce a server-streamed response.
type GossipSubscriptionFuture: Future<Item = Self::GossipSubscription, Erro... | code_fim | medium | {
"lang": "rust",
"repo": "SUSYLABS/rust-cardano",
"path": "/network-core/src/server/gossip.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SUSYLABS/rust-cardano path: /network-core/src/server/gossip.rs
///! Gossip service abstraction.
use crate::{
error::Error,
gossip::{Gossip, Node},
};
use futures::prelude::*;
/// Intreface for the node discovery service implementation
/// in the p2p network.
pub trait GossipService {
... | code_fim | hard | {
"lang": "rust",
"repo": "SUSYLABS/rust-cardano",
"path": "/network-core/src/server/gossip.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ref2 = &concrete;
let t2 = thread::spawn(move || {
for i in 5..10 {
println!("Thread2: {} - {}", i, ref2);
}
});
t1.join();
t2.join();
}<|fim_prefix|>// repo: jbiason/random path: /movereftest/src/main.rs
use std::thread;
fn main() {
let concrete ... | code_fim | medium | {
"lang": "rust",
"repo": "jbiason/random",
"path": "/movereftest/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbiason/random path: /movereftest/src/main.rs
use std::thread;
fn main() {
let concrete = String::from("Hello!");
<|fim_suffix|> let ref2 = &concrete;
let t2 = thread::spawn(move || {
for i in 5..10 {
println!("Thread2: {} - {}", i, ref2);
}
});
... | code_fim | medium | {
"lang": "rust",
"repo": "jbiason/random",
"path": "/movereftest/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomcc/fruity path: /src/foundation/mod.rs
//! [Foundation](https://developer.apple.com/documentation/foundation) framework.
//!
//! # Feature Flag
//!
//! This module corresponds to the **`foundation`**
//! [feature flag](../index.html#feature-flags).
//!
//! It also transitively enables [`objc... | code_fim | medium | {
"lang": "rust",
"repo": "thomcc/fruity",
"path": "/src/foundation/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use cmp::*;
pub use geometry::*;
pub use nsnumber::*;
pub use nsrange::*;
pub use nsstring::*;
#[link(name = "Foundation", kind = "framework")]
extern "C" {}<|fim_prefix|>// repo: thomcc/fruity path: /src/foundation/mod.rs
//! [Foundation](https://developer.apple.com/documentation/foundation) framew... | code_fim | medium | {
"lang": "rust",
"repo": "thomcc/fruity",
"path": "/src/foundation/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type BoxResult<T> = Result<T, Box<dyn std::error::Error>>;<|fim_prefix|>// repo: bpglaser/red-mountain-resize path: /src/lib.rs
#[macro_use]
extern crate clap;
<|fim_middle|>pub mod carve;
pub mod config;
pub mod energy;
pub mod grid;
| code_fim | medium | {
"lang": "rust",
"repo": "bpglaser/red-mountain-resize",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bpglaser/red-mountain-resize path: /src/lib.rs
#[macro_use]
extern crate clap;
<|fim_suffix|>pub type BoxResult<T> = Result<T, Box<dyn std::error::Error>>;<|fim_middle|>pub mod carve;
pub mod config;
pub mod energy;
pub mod grid;
| code_fim | medium | {
"lang": "rust",
"repo": "bpglaser/red-mountain-resize",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: felixmc/gerrit-cli path: /src/print.rs
// use std::str::FromStr;
use term::{Attr, color};
use prettytable;
use prettytable::cell::Cell;
use ansi_term::Colour::{Red, Green};
use gerrit::{ChangeReview, ReviewResult};
<|fim_suffix|>pub fn trim (input: &String, len: usize) -> &str {
if input.... | code_fim | hard | {
"lang": "rust",
"repo": "felixmc/gerrit-cli",
"path": "/src/print.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn trim (input: &String, len: usize) -> &str {
if input.len() > len {
&input[..len]
} else {
&input[..]
}
}<|fim_prefix|>// repo: felixmc/gerrit-cli path: /src/print.rs
// use std::str::FromStr;
use term::{Attr, color};
use prettytable;
use prettytable::cell::Cell;
use an... | code_fim | hard | {
"lang": "rust",
"repo": "felixmc/gerrit-cli",
"path": "/src/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laiboonh/yew path: /crates/macro/tests/html-list-fail.rs
use yew_macro::{html, test_html};
test_html! { |t1| <> }
t<|fim_suffix|> <></><></> }
test_html! { |t7| <>invalid</> }
fn main() {}<|fim_middle|>est_html! { |t2| </> }
test_html! { |t3| <><> }
test_html! { |t4| </></> }
test_html! { |t5|... | code_fim | medium | {
"lang": "rust",
"repo": "laiboonh/yew",
"path": "/crates/macro/tests/html-list-fail.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> <></><></> }
test_html! { |t7| <>invalid</> }
fn main() {}<|fim_prefix|>// repo: laiboonh/yew path: /crates/macro/tests/html-list-fail.rs
use yew_macro::{html, test_html};
test_html! { |t1| <> }
t<|fim_middle|>est_html! { |t2| </> }
test_html! { |t3| <><> }
test_html! { |t4| </></> }
test_html! { |t5|... | code_fim | medium | {
"lang": "rust",
"repo": "laiboonh/yew",
"path": "/crates/macro/tests/html-list-fail.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aristotle9/qt_generator-output path: /qt_3d_core/src/property_value_added_change.rs
/// C++ type: <span style='color: green;'>```Qt3DCore::QPropertyValueAddedChange```</span>
#[repr(C)]
pub struct PropertyValueAddedChange(u8);
impl PropertyValueAddedChange {
/// C++ method: <span style='color... | code_fim | hard | {
"lang": "rust",
"repo": "aristotle9/qt_generator-output",
"path": "/qt_3d_core/src/property_value_added_change.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>let ffi_result = unsafe { ::ffi::qt_3d_core_c_QPropertyValueAddedChange_G_static_cast_Qt3DCore_QPropertyValueAddedChangeBase_ptr(self as *const ::property_value_added_change::PropertyValueAddedChange as *mut ::property_value_added_change::PropertyValueAddedChange) };
unsafe { ffi_result.as_ref() }.expect(... | code_fim | hard | {
"lang": "rust",
"repo": "aristotle9/qt_generator-output",
"path": "/qt_3d_core/src/property_value_added_change.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ASK) as u32) << OFFSET;
self.w
}
}
#[doc = "Values that can be written to the field `IPEN0`"]
pub enum IPEN0W {
#[doc = "Flag EXICONx.FL is excluded from the pattern detection"]
VALUE1,
#[doc = "Flag EXICONx.FL is included in the pattern detection"]
VALUE2,
}
impl IPEN0W {
... | code_fim | hard | {
"lang": "rust",
"repo": "m9s/xmc1000",
"path": "/xmc1000/src/eru0/exocon/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>2)
}
#[doc = r" Sets the field bit"]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r" Clears the field bit"]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r" Writes raw bits to the field"]
#[inline]
pub fn bit(self, v... | code_fim | hard | {
"lang": "rust",
"repo": "m9s/xmc1000",
"path": "/xmc1000/src/eru0/exocon/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m9s/xmc1000 path: /xmc1000/src/eru0/exocon/mod.rs
*self == ISSR::VALUE1
}
#[doc = "Checks if the value of the field is `VALUE2`"]
#[inline]
pub fn is_value2(&self) -> bool {
*self == ISSR::VALUE2
}
#[doc = "Checks if the value of the field is `VALUE3`"]
... | code_fim | hard | {
"lang": "rust",
"repo": "m9s/xmc1000",
"path": "/xmc1000/src/eru0/exocon/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/**
* Adds a storage to an user associated with its user id.
*/
pub fn add_storage(
conn: &PgCon,
user_id: i32,
model: &NewStorage,
) -> Result<(), XamXamServiceError> {
if model.get_name().is_empty() {
return Err(XamXamServiceError::StorageNameIsEmpty);
}
storage::insert_... | code_fim | medium | {
"lang": "rust",
"repo": "mich2000/smartapp",
"path": "/backend/xam-xam-bis-bll/src/service/storage.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mich2000/smartapp path: /backend/xam-xam-bis-bll/src/service/storage.rs
use crate::err::XamXamServiceError;
use crate::viewmodels::edit_storage::EditStorage;
use crate::viewmodels::new_storage::NewStorage;
use crate::viewmodels::storage_name::StorageName;
use crate::viewmodels::storage_names::St... | code_fim | hard | {
"lang": "rust",
"repo": "mich2000/smartapp",
"path": "/backend/xam-xam-bis-bll/src/service/storage.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>doc = "CPACR register accessor: an alias for `Reg<CPACR_SPEC>`"]
pub type CPACR = crate::Reg<cpacr::CPACR_SPEC>;
#[doc = "Coprocessor access control register"]
pub mod cpacr;<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f401/fpu_cpacr.rs
#[doc = r... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f401/fpu_cpacr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>::Reg<cpacr::CPACR_SPEC>;
#[doc = "Coprocessor access control register"]
pub mod cpacr;<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f401/fpu_cpacr.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - C<|fim_midd... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f401/fpu_cpacr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f401/fpu_cpacr.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - C<|fim_suffix|>::Reg<cpacr::CPACR_SPEC>;
#[doc = "Coprocessor access control register"]
pub mod cpacr;<|fim_midd... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f401/fpu_cpacr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = centroid.point.len();
Cluster {
centroid,
points_count: 0,
points_sum: Point::new(vec![0.0; n]),
}
}
}
/// ClusterSet is collection of clusters.
/// Capacity of ClusterSet is always same as number of clusters.
#[derive(Debug, Clone,... | code_fim | hard | {
"lang": "rust",
"repo": "Yokeshthirumoorthi/RustMLProjects",
"path": "/kmeans/src/cluster.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// ClusterSet is collection of clusters.
/// Capacity of ClusterSet is always same as number of clusters.
#[derive(Debug, Clone, PartialEq)]
pub struct ClusterSet {
pub clusters: Vec<Cluster>,
}
impl ClusterSetObject for ClusterSet {
fn new(clusters: Vec<Cluster>) -> ClusterSet {
Cluster... | code_fim | hard | {
"lang": "rust",
"repo": "Yokeshthirumoorthi/RustMLProjects",
"path": "/kmeans/src/cluster.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yokeshthirumoorthi/RustMLProjects path: /kmeans/src/cluster.rs
// Copyright © 2020 Yokesh Thirumoorthi
// [This program is licensed under the "MIT License"]
// Please see the file LICENSE in the source
// distribution of this software for license terms.
use crate::point::*;
use std::convert::Fro... | code_fim | hard | {
"lang": "rust",
"repo": "Yokeshthirumoorthi/RustMLProjects",
"path": "/kmeans/src/cluster.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(serde_http_headermap::from_headermap::<Basic>(&headers).is_ok());
}
#[test]
fn can_serialize_struct() {
#[derive(Serialize)]
struct Basic {
host: String,
content_length: Option<String>,
}
let my_struct = Basic {
host: "localhost".to_string(),
c... | code_fim | hard | {
"lang": "rust",
"repo": "mockersf/serde_http_headermap",
"path": "/tests/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mockersf/serde_http_headermap path: /tests/tests.rs
extern crate http;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_http_headermap;
#[test]
fn can_deserialize_struct() {
#[derive(Deserialize)]
struct Basic {
host: String,
content_lengt... | code_fim | medium | {
"lang": "rust",
"repo": "mockersf/serde_http_headermap",
"path": "/tests/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Serialize)]
struct Basic {
host: String,
content_length: Option<String>,
}
let my_struct = Basic {
host: "localhost".to_string(),
content_length: None,
};
assert!(serde_http_headermap::to_headermap(&my_struct).is_ok());
}<|fim_prefix|>// r... | code_fim | medium | {
"lang": "rust",
"repo": "mockersf/serde_http_headermap",
"path": "/tests/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub extern "win64" fn uefi_start(image: uefi::Handle, st: &'static SystemTable<Boot>) -> ! {
uefi_services::init(&st).expect_success("Failed to initialize utilities");
st.stdout()
.reset(false)
.expect_success("Failed to reset stdout");
loop {}
}<|fim_prefix|>// r... | code_fim | easy | {
"lang": "rust",
"repo": "sunnycase/rust-learn",
"path": "/os/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sunnycase/rust-learn path: /os/src/main.rs
#![no_std]
#![no_main]
extern crate uefi;
extern crate uefi_services;
<|fim_suffix|> st.stdout()
.reset(false)
.expect_success("Failed to reset stdout");
loop {}
}<|fim_middle|>use uefi::prelude::*;
#[no_mangle]
pub extern "win... | code_fim | hard | {
"lang": "rust",
"repo": "sunnycase/rust-learn",
"path": "/os/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tabase;
pub use hir_db::{HirDatabase, HirStorage};
pub use inputs::{InputDatabase, InputStorage, SourceCache};
pub use sources::{FileId, Source};<|fim_prefix|>// repo: briancabbott/GitHub-Repository-Downloader path: /TypeScript/resources/code/ts_lib/Apollo-Latest/apollographql/apollo-rs/crates/apollo-com... | code_fim | medium | {
"lang": "rust",
"repo": "briancabbott/GitHub-Repository-Downloader",
"path": "/TypeScript/resources/code/ts_lib/Apollo-Latest/apollographql/apollo-rs/crates/apollo-compiler/src/database/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tDatabase, InputStorage, SourceCache};
pub use sources::{FileId, Source};<|fim_prefix|>// repo: briancabbott/GitHub-Repository-Downloader path: /TypeScript/resources/code/ts_lib/Apollo-Latest/apollographql/apollo-rs/crates/apollo-compiler/src/database/mod.rs
pub mod db;
pub mod hir;
mod ast;
mod documen... | code_fim | medium | {
"lang": "rust",
"repo": "briancabbott/GitHub-Repository-Downloader",
"path": "/TypeScript/resources/code/ts_lib/Apollo-Latest/apollographql/apollo-rs/crates/apollo-compiler/src/database/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut output = count.to_string();
if count == 1 {
output.push_str(" item left");
} else {
output.push_str(" items left");
}
rc.writer.write(output.as_bytes()).unwrap();
Ok(())
}
pub fn render<'mw, T: ToJson>(res: Response<'mw>, path: &str, data: &T) -> Middlewa... | code_fim | hard | {
"lang": "rust",
"repo": "yanns/rust-playground",
"path": "/todo-list-redux/src/template.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yanns/rust-playground path: /todo-list-redux/src/template.rs
use rustc_serialize::json::ToJson;
use nickel::{Response, MiddlewareResult};
use std::path::Path;
use handlebars::{Handlebars, Renderable, RenderError, RenderContext, Helper, Context, JsonRender};
fn filter_todo(c: &Context,
... | code_fim | hard | {
"lang": "rust",
"repo": "yanns/rust-playground",
"path": "/todo-list-redux/src/template.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(unused_variables)]
fn active_count(c: &Context,
h: &Helper,
ha: &Handlebars,
rc: &mut RenderContext)
-> Result<(), RenderError> {
let todos = c.navigate(".", "todos").as_array().unwrap();
let count = todos.into_iter()
... | code_fim | hard | {
"lang": "rust",
"repo": "yanns/rust-playground",
"path": "/todo-list-redux/src/template.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BarePotato/gooey path: /gooey/examples/widget_explorer_screens/mod.rs
use std::{borrow::Cow, fmt::Debug};
use gooey::{
core::{
styles::{Alignment, VerticalAlignment},
WeakWidgetRegistration,
},
widgets::{
button::Button,
component::{Behavior, Componen... | code_fim | hard | {
"lang": "rust",
"repo": "BarePotato/gooey",
"path": "/gooey/examples/widget_explorer_screens/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> layout.finish()
}
fn receive_event(
component: &mut gooey_widgets::component::Component<Self>,
event: Self::Event,
context: &gooey_core::Context<gooey_widgets::component::Component<Self>>,
) {
let button = &component.buttons[event];
if let Some(... | code_fim | hard | {
"lang": "rust",
"repo": "BarePotato/gooey",
"path": "/gooey/examples/widget_explorer_screens/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn materialize(
&self,
storage: &gooey_core::WidgetStorage,
navigator: WeakWidgetRegistration,
) -> gooey_core::WidgetRegistration {
match self {
Page::MainMenu => storage.register(Component::new(MainMenu::new(navigator), storage)),
Page::Nav... | code_fim | hard | {
"lang": "rust",
"repo": "BarePotato/gooey",
"path": "/gooey/examples/widget_explorer_screens/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
a: u32,
b: u32,
}
println!("{}", a + b);
}<|fim_prefix|>// repo: therk987/verification-helper path: /examples/rust/verification/src/bin/library-checker-aplusb.rs
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/aplusb
<|fim_middle|>use input::input;
... | code_fim | easy | {
"lang": "rust",
"repo": "therk987/verification-helper",
"path": "/examples/rust/verification/src/bin/library-checker-aplusb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", a + b);
}<|fim_prefix|>// repo: therk987/verification-helper path: /examples/rust/verification/src/bin/library-checker-aplusb.rs
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/aplusb
use input::input;
fn main() {
<|fim_middle|> input! {
a: u32,
b: ... | code_fim | easy | {
"lang": "rust",
"repo": "therk987/verification-helper",
"path": "/examples/rust/verification/src/bin/library-checker-aplusb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: therk987/verification-helper path: /examples/rust/verification/src/bin/library-checker-aplusb.rs
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/aplusb
use input::input;
<|fim_suffix|> println!("{}", a + b);
}<|fim_middle|>fn main() {
input! {
a: u32,
b: ... | code_fim | medium | {
"lang": "rust",
"repo": "therk987/verification-helper",
"path": "/examples/rust/verification/src/bin/library-checker-aplusb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EdenEast/jun path: /jun/src/models/user.rs
use chrono::naive::NaiveDateTime;
use juniper::GraphQLInputObject;
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use uuid::Uuid;
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, FromRow, juniper::GraphQLObject)]
pub struct AuthToken {
... | code_fim | hard | {
"lang": "rust",
"repo": "EdenEast/jun",
"path": "/jun/src/models/user.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, FromRow, juniper::GraphQLObject)]
pub struct AuthUser {
pub user_id: Uuid,
pub token_id: Uuid,
pub token: Uuid,
pub username: String,
pub email: String,
pub image: Option<String>,
}
#[derive(Debug, GraphQLInputObject)]
pub struct CreateUser ... | code_fim | hard | {
"lang": "rust",
"repo": "EdenEast/jun",
"path": "/jun/src/models/user.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> p1 += 1;
}
cur = nums[p2];
p2 += 1;
}
return p1 as i32;
}
}<|fim_prefix|>// repo: lawvs/Algorithm-Training path: /leetcode/026.remove-duplicates-from-sorted-array.rs
impl Solution {
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
... | code_fim | hard | {
"lang": "rust",
"repo": "lawvs/Algorithm-Training",
"path": "/leetcode/026.remove-duplicates-from-sorted-array.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lawvs/Algorithm-Training path: /leetcode/026.remove-duplicates-from-sorted-array.rs
impl Solution {
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
if nums.len() <= 1 {
retu<|fim_suffix|> p1 += 1;
}
cur = nums[p2];
p2 += 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "lawvs/Algorithm-Training",
"path": "/leetcode/026.remove-duplicates-from-sorted-array.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ums[0];
while p2 < nums.len() {
if nums[p2] != cur {
nums[p1] = nums[p2];
p1 += 1;
}
cur = nums[p2];
p2 += 1;
}
return p1 as i32;
}
}<|fim_prefix|>// repo: lawvs/Algorithm-Training path: /leetcode/... | code_fim | hard | {
"lang": "rust",
"repo": "lawvs/Algorithm-Training",
"path": "/leetcode/026.remove-duplicates-from-sorted-array.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl QueryEnvironment for MockEnvironment {
fn get_or_default(&self, key: &str, default: &str) -> String {
if key == MONGODB_URL_KEY { String::from(default) } else { format!("from_{}", key) }
}
}
#[test]
fn test_new() {
let environment = Box::new(MockEn... | code_fim | hard | {
"lang": "rust",
"repo": "marcuslimdw/pythagoras-assessment",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marcuslimdw/pythagoras-assessment path: /src/config.rs
use std::env;
use log::warn;
const WEBSOCKET_URL_KEY: &str = "PYTHAGORAS_WEBSOCKET_URL";
const MONGODB_URL_KEY: &str = "PYTHAGORAS_MONGODB_URL";
const REDIS_URL_KEY: &str = "PYTHAGORAS_REDIS_URL";
const DEFAULT_WEBSOCKET_URL: &str = "wss:... | code_fim | hard | {
"lang": "rust",
"repo": "marcuslimdw/pythagoras-assessment",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
struct MockEnvironment;
impl QueryEnvironment for MockEnvironment {
fn get_or_default(&self, key: &str, default: &str) -> String {
if key == MONGODB_URL_KEY { String::from(default) } else { format!("from_{}", key) }
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "marcuslimdw/pythagoras-assessment",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use nom::bytes::complete::escaped;
use nom::bytes::complete::is_not;
use nom::character::complete::char;
use nom::sequence::delimited;
delimited(
char('"'),
escaped(is_not("\\\""), '\\', char('"')),
char('"'),
)(input)
}
fn single_quoted_string(input: &str... | code_fim | hard | {
"lang": "rust",
"repo": "nschoellhorn/bmos",
"path": "/bmos-shell/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> delimited(
char('"'),
escaped(is_not("\\\""), '\\', char('"')),
char('"'),
)(input)
}
fn single_quoted_string(input: &str) -> IResult<&str, &str> {
use nom::bytes::complete::escaped;
use nom::bytes::complete::is_not;
use nom::character::complete::char;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "nschoellhorn/bmos",
"path": "/bmos-shell/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nschoellhorn/bmos path: /bmos-shell/src/parser.rs
use alloc::vec::Vec;
use nom::IResult;
const ALLOWED_CHARS: &'static str = ".:/-_";
pub fn parse_command_line(input: &str) -> IResult<&str, Vec<&str>> {
use nom::branch::alt;
use nom::character::complete::multispace1;
use nom::multi... | code_fim | hard | {
"lang": "rust",
"repo": "nschoellhorn/bmos",
"path": "/bmos-shell/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let (Some(player_pos), Some(target_pos)) =
(player_pos, target_pos)
{
// https://stackoverflow.com/a/20916980/10927893
let dist = {
let x = player_pos.x - target_pos.x;
let y = player_pos.y -... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/LD46-TheHum",
"path": "/src/systems/song_volume_proximity.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let factor_invert = 1.0 - self.factor;
let new_volume = (1.0 - dist * factor_invert).max(0.0);
let prev_volume = self.prev_volume.get_or_insert(1.0);
if *prev_volume != new_volume {
song.set_volume(new_volume);
... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/LD46-TheHum",
"path": "/src/systems/song_volume_proximity.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Noah2610/LD46-TheHum path: /src/systems/song_volume_proximity.rs
use super::system_prelude::*;
use deathframe::amethyst::ecs::Component;
use std::marker::PhantomData;
pub struct SongVolumeProximitySystem<C>
where
C: Component,
{
song_key: SongKey,
factor: f32,
prev_volum... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/LD46-TheHum",
"path": "/src/systems/song_volume_proximity.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> builtin_func2!("with-meta",nometa |_,_,obj:Rc<Ast>, meta:Rc<Ast>|Ok({
Ast::WithMeta{
obj,
meta,
}
}));
builtin_func1!("seq",nometa |_,_,arg:Rc<Ast>|Ok({
match &*arg {
Ast::Round(x) | Ast::Square(x)... | code_fim | hard | {
"lang": "rust",
"repo": "vi/mal-rust-vi",
"path": "/stepA/src/stdfn_part5.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vi/mal-rust-vi path: /stepA/src/stdfn_part5.rs
#![allow(unused_imports)]
use super::{Ast, Malvi, SAst};
use std::rc::Rc;
use crate::im::Vector;
use crate::im::HashMap;
impl Malvi {
pub fn stdfn_part5(&mut self) {
declare_macros_for_builtins!(self);
builtin_func1!("meta", ... | code_fim | hard | {
"lang": "rust",
"repo": "vi/mal-rust-vi",
"path": "/stepA/src/stdfn_part5.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.