text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>impl Serialize for SystemChannelFlags {
fn serialize<S>(&self, serializer: S) -> StdResult<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u64(self.bits())
}
}<|fim_prefix|>// repo: eatmymalware/serenitylol path: /src/model/guild/system_channel.rs
use bitflags... | code_fim | hard | {
"lang": "rust",
"repo": "eatmymalware/serenitylol",
"path": "/src/model/guild/system_channel.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let args: Vec<String> = std::env::args().collect();
let yaml_file = &args[1];
let s = std::fs::read_to_string(yaml_file).unwrap();
let yaml = YamlLoader::load_from_str(&s).unwrap();
let config = &yaml[0];
let (w, mut c) = parse_config(config);
let canv = world::rend... | code_fim | medium | {
"lang": "rust",
"repo": "gcohara/rusrat",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gcohara/rusrat path: /src/main.rs
#![allow(dead_code)]
mod canvas;
mod lighting;
mod matrices;
mod rays;
mod shapes;
mod tuple;
mod world;
mod yaml;
use yaml::parse_config;
use yaml_rust::YamlLoader;
pub const REFLECTION_RECURSION_DEPTH: usize = 7;
<|fim_suffix|>fn main() {
let args: Vec... | code_fim | medium | {
"lang": "rust",
"repo": "gcohara/rusrat",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test = Test::new();
let (bob, room_id) = test.initial_fixtures(r#"{"visibility": "private"}"#);
let alice = test.create_user();
let response = test.invite(&bob.token, &room_id, &alice.id);
assert_eq!(response.status, Status::Ok);
assert!(test.join_roo... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/homeserver",
"path": "/src/api/r0/join.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruma/homeserver path: /src/api/r0/join.rs
match RoomMembership::find(&connection, &room_id, &kicker.id)? {
Some(ref membership) if membership.membership == "join" => {}
_ => Err(ApiError::unauthorized(
"The kicker is not currently in the room".to_... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/homeserver",
"path": "/src/api/r0/join.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruma/homeserver path: /src/api/r0/join.rs
q)) => req.user_id,
Ok(None) => Err(ApiError::bad_json(None))?,
Err(err) => Err(ApiError::bad_json(err.to_string()))?,
};
let connection = DB::from_request(request)?;
let config = Config::from_request(requ... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/homeserver",
"path": "/src/api/r0/join.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raftario/libraryan path: /src/models/permissions.rs
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub enum Permission {
Admin,
RegisterUser,
UpdateUser,
DeleteUser,
UploadBook,
UpdateBook,
DeleteBook,
CreateAuthor,
UpdateAuthor,
DeleteAuthor,
CreateCateg... | code_fim | hard | {
"lang": "rust",
"repo": "raftario/libraryan",
"path": "/src/models/permissions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<db::Permission> for Permission {
fn from(p: db::Permission) -> Self {
Self::from(p.id)
}
}
pub mod db {
use crate::schema::permissions;
#[derive(Identifiable, Queryable)]
#[table_name = "permissions"]
pub struct Permission {
pub id: i32,
pub name... | code_fim | hard | {
"lang": "rust",
"repo": "raftario/libraryan",
"path": "/src/models/permissions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: dmijatovic/todo_dp_test path: /src/lib.rs
#[macro_use]
extern crate log;
mod db;
pub use db::todo_item::{NewTodoItem, TodoItem};
pub use db::todo_list::{NewTodoList, TodoList, UpdateTodoList};
pub use db::{create_pool, Pool};
pub use db::{todo... | code_fim | easy | {
"lang": "rust",
"repo": "dmijatovic/todo_dp_test",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmijatovic/todo_dp_test path: /src/lib.rs
#[macro_use]
extern crate log;
<|fim_suffix|>#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_middle|>mod db;
pub use db::todo_item::{NewTodoItem, TodoItem};
pub use db::todo_list::{NewTodoList, TodoLi... | code_fim | medium | {
"lang": "rust",
"repo": "dmijatovic/todo_dp_test",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ht32-rs/ht32-rs-nightlies path: /ht32f5xxxx/src/ht32f52357_67/gpioe/perr.rs
#[doc = "Register `PERR` reader"]
pub struct R(crate::R<PERR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<PERR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}... | code_fim | hard | {
"lang": "rust",
"repo": "ht32-rs/ht32-rs-nightlies",
"path": "/ht32f5xxxx/src/ht32f52357_67/gpioe/perr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> W(writer)
}
}
#[doc = "Field `PERST0` reader - PERST0"]
pub type PERST0_R = crate::BitReader;
#[doc = "Field `PERST0` writer - PERST0"]
pub type PERST0_W<'a, const O: u8> = crate::BitWriter<'a, PERR_SPEC, O>;
#[doc = "Field `PERST1` reader - PERST1"]
pub type PERST1_R = crate::BitReader;
#[doc... | code_fim | hard | {
"lang": "rust",
"repo": "ht32-rs/ht32-rs-nightlies",
"path": "/ht32f5xxxx/src/ht32f52357_67/gpioe/perr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> fmt::Display for Grid<T>
where
T: fmt::Display + Default,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let ((min_x, min_y), (max_x, max_y)) = self.bounds();
let default = T::default();
for y in min_y..=max_y {
for x in min_x..=max_x {
... | code_fim | hard | {
"lang": "rust",
"repo": "jacobmischka/adventofcode-2019",
"path": "/src/grid.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacobmischka/adventofcode-2019 path: /src/grid.rs
use rustbox::{Color, RustBox, RB_NORMAL};
use std::collections::HashMap;
use std::fmt;
use std::ops::{Deref, DerefMut};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
pub struct Coord(pub i64, pub i64);
#[derive(Debug, Clone, PartialEq,... | code_fim | hard | {
"lang": "rust",
"repo": "jacobmischka/adventofcode-2019",
"path": "/src/grid.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn emit(&self, u: f64, v: f64, p: &Vec3) -> Vec3 {
self.emit.value(u, v, p) * self.multiplier
}
}<|fim_prefix|>// repo: Krenodeno/YARRT path: /src/materials/emissive.rs
use super::Material;
use crate::hitables::HitRecord;
use crate::structs::{Ray, Texture, Vec3};
use std::sync::Arc;
pu... | code_fim | easy | {
"lang": "rust",
"repo": "Krenodeno/YARRT",
"path": "/src/materials/emissive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> None
}
fn emit(&self, u: f64, v: f64, p: &Vec3) -> Vec3 {
self.emit.value(u, v, p) * self.multiplier
}
}<|fim_prefix|>// repo: Krenodeno/YARRT path: /src/materials/emissive.rs
use super::Material;
use crate::hitables::HitRecord;
use crate::structs::{Ray, Texture, Vec3};
<|f... | code_fim | hard | {
"lang": "rust",
"repo": "Krenodeno/YARRT",
"path": "/src/materials/emissive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Krenodeno/YARRT path: /src/materials/emissive.rs
use super::Material;
use crate::hitables::HitRecord;
use crate::structs::{Ray, Texture, Vec3};
<|fim_suffix|> fn emit(&self, u: f64, v: f64, p: &Vec3) -> Vec3 {
self.emit.value(u, v, p) * self.multiplier
}
}<|fim_middle|>use std::... | code_fim | hard | {
"lang": "rust",
"repo": "Krenodeno/YARRT",
"path": "/src/materials/emissive.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: geovex/dumb_proxy path: /src/config_loader.rs
use serde_derive::Deserialize;
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use toml;
#[derive(Deserialize, Debug, Clone, Default)]
#[serde(default)]
pub struct Config {
pub http: HashMap<String, HttpConfig>,
pub sock... | code_fim | medium | {
"lang": "rust",
"repo": "geovex/dumb_proxy",
"path": "/src/config_loader.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn load_config_default() -> Config {
let t = toml::toml! {
[http.a]
port = 3128
};
t.try_into().unwrap()
}<|fim_prefix|>// repo: geovex/dumb_proxy path: /src/config_loader.rs
use serde_derive::Deserialize;
use std::collections::HashMap;
use std::fs::File;
use std::io::Read... | code_fim | hard | {
"lang": "rust",
"repo": "geovex/dumb_proxy",
"path": "/src/config_loader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hamadakafu/kyopro path: /src/bin/dp_a.rs
use std::cmp::Reverse;
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000_000_007;
<|fim_suffix|>fn main() {
let n: usize = parse_line().unwrap();
l... | code_fim | medium | {
"lang": "rust",
"repo": "hamadakafu/kyopro",
"path": "/src/bin/dp_a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let n: usize = parse_line().unwrap();
let hh: Vec<isize> = parse_line().unwrap();
let mut dp: Vec<usize> = vec![];
dp.push(0);
dp.push((hh[0] - hh[1]).abs() as usize);
for i in 2..n {
dp.push(min(
dp[i - 1] + (hh[i] - hh[i - 1]).abs() as usize,
... | code_fim | medium | {
"lang": "rust",
"repo": "hamadakafu/kyopro",
"path": "/src/bin/dp_a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aegoroff/egoroff.spb.ru path: /egoroff/server/src/domain.rs
use std::{collections::HashSet, path::PathBuf, sync::Arc};
use axum_login::RequireAuthorizationLayer;
use futures::lock::Mutex;
use kernel::{
domain::{ApiResult, User},
graph::{SiteGraph, SiteSection},
sqlite::Sqlite,
};
us... | code_fim | hard | {
"lang": "rust",
"repo": "aegoroff/egoroff.spb.ru",
"path": "/egoroff/server/src/domain.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // act
let poster = Poster::new(api_result, page);
// assert
assert!(poster.has_pages);
assert!(poster.has_next);
assert!(!poster.has_prev);
assert_eq!(poster.pages, vec![1, 2]);
assert_eq!(poster.prev_page, 1);
assert_eq!(poster.nex... | code_fim | hard | {
"lang": "rust",
"repo": "aegoroff/egoroff.spb.ru",
"path": "/egoroff/server/src/domain.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/image/icon_add_photo_alternate.rs
pub struct IconAddPhotoAlternate {
props: crate::Props,
}
impl yew::Component for IconAddPhotoAlternate {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Prop... | code_fim | hard | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsround/image/icon_add_photo_alternate.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(clustered) = index.clustered() {
definition.clustered(clustered);
}
if let Some(algo) = index.algorithm() {
definition.index_type(algo);
}
definition
}<|fim_prefix|>// repo: prisma/prisma-engines path: /schema-engine/connectors/sql-schema-connector/src/in... | code_fim | medium | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/schema-engine/connectors/sql-schema-connector/src/introspection/rendering/indexes.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(sort_order) = field.sort_order() {
definition.sort_order(sort_order);
}
if let Some(length) = field.length() {
definition.length(length);
}
if let Some(ops) = field.opclass() {
let ops = match ops {
I... | code_fim | medium | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/schema-engine/connectors/sql-schema-connector/src/introspection/rendering/indexes.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn match_route() {
let mut router = Router::default();
let mut param_types = HashMap::new();
param_types.insert("id".to_string(), ParamType::U64);
let view_creator = Box::new(|_| Box::new(TestView { kind: "first" }) as Box<View>);
let first_route =... | code_fim | hard | {
"lang": "rust",
"repo": "agrif/percy",
"path": "/crates/router-rs/src/router.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct TestView {
kind: &'static str,
}
impl View for TestView {
fn render(&self) -> VirtualNode {
html! {<div> {self.kind} </div> }
}
}
#[test]
fn match_route() {
let mut router = Router::default();
let mut param_types = HashM... | code_fim | hard | {
"lang": "rust",
"repo": "agrif/percy",
"path": "/crates/router-rs/src/router.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agrif/percy path: /crates/router-rs/src/router.rs
//! Powers routing for frontend web applications
use crate::Route;
use virtual_dom_rs::prelude::*;
/// Holds all of the routes for an application.
///
/// A typical use case is that when we want to move to a new route
/// (such as after clickin... | code_fim | hard | {
"lang": "rust",
"repo": "agrif/percy",
"path": "/crates/router-rs/src/router.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Canop/broot path: /src/verb/internal_select.rs
//! utility functions to help handle the `:select` internal
use {
super::*,
crate::{
app::*,
browser::BrowserState,
command::TriggerType,
display::Screen,
path::{self, PathAnchor},
tree::Tree,... | code_fim | hard | {
"lang": "rust",
"repo": "Canop/broot",
"path": "/src/verb/internal_select.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> verb: &Verb,
internal_exec: &InternalExecution,
base_path: &Path, // either the selected path or the root path
input_arg: Option<&String>,
app_state: &AppState,
) -> PathBuf {
match (input_arg, internal_exec.arg.as_ref()) {
(Some(input_arg), Some(verb_arg)) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "Canop/broot",
"path": "/src/verb/internal_select.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fs::write(
"./persisted_entries.bin",
rmp_serde::to_vec(&ser_entries).unwrap(),
)
.await;
}
pub fn restore_persistent() -> anyhow::Result<HashMap<String, Topic>> {
let data = std::fs::read("./persisted_entries.bin")?;
rmp_serde::from_read(&data[..]).map_err(Into::into... | code_fim | hard | {
"lang": "rust",
"repo": "first-rust-competition/nt4-mvp",
"path": "/server/src/persist.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: first-rust-competition/nt4-mvp path: /server/src/persist.rs
use crate::entry::Topic;
use async_std::fs;
use std::collections::HashMap;
pub async fn flush_persistent(entries: &HashMap<String, Topic>) {
let mut ser_entries = HashMap::new();
for (name, topic) in entries
.iter()
... | code_fim | medium | {
"lang": "rust",
"repo": "first-rust-competition/nt4-mvp",
"path": "/server/src/persist.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akavasis/ZLUDA path: /zluda/src/impl/stream.rs
use super::{
context::{Context, ContextData},
CUresult, GlobalState,
};
use std::{mem, ptr};
use super::{HasLivenessCookie, LiveCheck};
pub type Stream = LiveCheck<StreamData>;
pub const CU_STREAM_LEGACY: *mut Stream = 1 as *mut _;
pub co... | code_fim | hard | {
"lang": "rust",
"repo": "akavasis/ZLUDA",
"path": "/zluda/src/impl/stream.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> cuda_driver_test!(stream_moves_context_to_another_thread);
fn stream_moves_context_to_another_thread<T: CudaDriverFns>() {
assert_eq!(T::cuInit(0), CUresult::CUDA_SUCCESS);
let mut ctx = ptr::null_mut();
assert_eq!(T::cuCtxCreate_v2(&mut ctx, 0, 0), CUresult::CUDA_SUCCESS)... | code_fim | hard | {
"lang": "rust",
"repo": "akavasis/ZLUDA",
"path": "/zluda/src/impl/stream.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_transforms_base/src/pass.rs
use swc_common::pass::CompilerPass;
pub use swc_common::pass::{Optional, Repeated};
use swc_ecma_ast::{Module, Script};
use swc_ecma_visit::Fold;
<|fim_suffix|> s
}
}
pub trait JsPass: CompilerPass + Fold {}
impl<T:... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_transforms_base/src/pass.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: ?Sized> RepeatedJsPass for T where T: Repeated + JsPass {}<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_transforms_base/src/pass.rs
use swc_common::pass::CompilerPass;
pub use swc_common::pass::{Optional, Repeated};
use swc_ecma_ast::{Module, Script};
use swc_ecma_visit::Fold;
pu... | code_fim | medium | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_transforms_base/src/pass.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> m
}
#[inline(always)]
fn fold_script(&mut self, s: Script) -> Script {
s
}
}
pub trait JsPass: CompilerPass + Fold {}
impl<T: ?Sized> JsPass for T where T: CompilerPass + Fold {}
pub trait RepeatedJsPass: Repeated + JsPass {}
impl<T: ?Sized> RepeatedJsPass for T where ... | code_fim | medium | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_transforms_base/src/pass.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JulianSchmid/dlt-parse-rs path: /src/storage/mod.rs
#[cfg(feature = "std")]
mod dlt_storage_reader;
#[cfg(feature = "std")]
pub use dlt_storage_reader::*;
<|fim_suffix|>mod storage_slice;
pub use storage_slice::*;<|fim_middle|>#[cfg(feature = "std")]
mod dlt_storage_writer;
#[cfg(feature = "std... | code_fim | medium | {
"lang": "rust",
"repo": "JulianSchmid/dlt-parse-rs",
"path": "/src/storage/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod storage_slice;
pub use storage_slice::*;<|fim_prefix|>// repo: JulianSchmid/dlt-parse-rs path: /src/storage/mod.rs
#[cfg(feature = "std")]
mod dlt_storage_reader;
#[cfg(feature = "std")]
pub use dlt_storage_reader::*;
#[cfg(feature = "std")]
mod dlt_storage_writer;
#[cfg(feature = "std")]
pub use dl... | code_fim | easy | {
"lang": "rust",
"repo": "JulianSchmid/dlt-parse-rs",
"path": "/src/storage/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clinta/hostgen path: /src/hosts.rs
use crate::ipnet::{ToMac, TryInNet, TryToMac};
use crate::network::InterfaceNetwork;
use ipnetwork::IpNetwork;
use log::warn;
use pnet::datalink::MacAddr;
use serde_yaml::{Mapping, Value};
use std::convert::TryFrom;
use std::net::IpAddr;
pub struct Host {
... | code_fim | hard | {
"lang": "rust",
"repo": "clinta/hostgen",
"path": "/src/hosts.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // try labeled options
if let Some(o) = opts
.iter()
.filter_map(|o| match o {
Self::Labeled(Label::Mac(mac_opts)) => Some(mac_opts),
_ => None,
})
.next()
{
return Self::get_mac(o, net);
... | code_fim | hard | {
"lang": "rust",
"repo": "clinta/hostgen",
"path": "/src/hosts.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wezm/crossterm path: /crossterm_screen/src/screen/mod.rs
//! A module which provides some functionalities to work with the terminal screen.
//! Like allowing you to switch between main and alternate screen or putting the terminal into raw mode.
<|fim_suffix|>use crossterm_utils::TerminalOutput;... | code_fim | easy | {
"lang": "rust",
"repo": "wezm/crossterm",
"path": "/crossterm_screen/src/screen/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::alternate::AlternateScreen;
pub use self::raw::RawScreen;
pub use self::screen::Screen;<|fim_prefix|>// repo: wezm/crossterm path: /crossterm_screen/src/screen/mod.rs
//! A module which provides some functionalities to work with the terminal screen.
//! Like allowing you to switch between m... | code_fim | easy | {
"lang": "rust",
"repo": "wezm/crossterm",
"path": "/crossterm_screen/src/screen/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nwtnni/advent-of-code path: /aoc-15/src/day_10.rs
use std::mem;
use aoc::*;
#[derive(Clone, Debug)]
pub struct ElvesLookElvesSay(Vec<u8>);
impl Fro for ElvesLookElvesSay {
fn fro(input: &str) -> Self {
input
.trim()
.bytes()
.map(|byte| byte - b... | code_fim | hard | {
"lang": "rust",
"repo": "nwtnni/advent-of-code",
"path": "/aoc-15/src/day_10.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution for ElvesLookElvesSay {
fn one(self) -> i64 {
self.expand(40)
}
fn two(self) -> i64 {
self.expand(50)
}
}<|fim_prefix|>// repo: nwtnni/advent-of-code path: /aoc-15/src/day_10.rs
use std::mem;
use aoc::*;
#[derive(Clone, Debug)]
pub struct ElvesLookElvesSay... | code_fim | hard | {
"lang": "rust",
"repo": "nwtnni/advent-of-code",
"path": "/aoc-15/src/day_10.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomcc/slotmap path: /examples/rand_meld_heap.rs
// Randomized meldable heap.
// https://en.wikipedia.org/wiki/Randomized_meldable_heap
extern crate slotmap;
use slotmap::{SlotMap, SecondaryMap, Key, Slottable};
// Intentionally not copy or clone.
struct NodeHandle(Key);
#[derive(Copy, Clone... | code_fim | hard | {
"lang": "rust",
"repo": "thomcc/slotmap",
"path": "/examples/rand_meld_heap.rs",
"mode": "psm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(parent) = self.sm.get_mut(parent_key) {
if parent.children[0] == node {
parent.children[0] = melded_children;
} else {
parent.children[1] = melded_children;
}
} else {
self.root = melded_children;
... | code_fim | hard | {
"lang": "rust",
"repo": "thomcc/slotmap",
"path": "/examples/rand_meld_heap.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: i39/capsule path: /core/src/packets/checksum.rs
/*
* Copyright 2019 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* ht... | code_fim | hard | {
"lang": "rust",
"repo": "i39/capsule",
"path": "/core/src/packets/checksum.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Computes the Internet checksum via incremental update as defined in
/// [IETF RFC 1624].
///
/// Given the following notation:
/// * `HC` - old checksum in header
/// * `HC'` - new checksum in header
/// * `m` - old value of a 16-bit field
/// * `m'` - new value of a 16-bit field
///
/// `HC' = ~(... | code_fim | hard | {
"lang": "rust",
"repo": "i39/capsule",
"path": "/core/src/packets/checksum.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Computes the Internet checksum as defined in [IETF RFC 1071].
///
/// 1. Adjacent octets to be checksummed are paired to form 16-bit integers,
/// and the 1's complement sum of these 16-bit integers is formed.
///
/// 2. To generate a checksum, the checksum field itself is cleared, the
/// 16-bit 1's ... | code_fim | hard | {
"lang": "rust",
"repo": "i39/capsule",
"path": "/core/src/packets/checksum.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn send(message: &str);
}
#[wasm_bindgen]
pub fn greet(input: &str) {
alert(&format!("Input: {}. Mish: {}", input, mish::hello_world()));
}<|fim_prefix|>// repo: projectasiago/mish-web path: /src/lib.rs
#![feature(proc_macro)]
extern crate wasm_bindgen;
extern crate projectasiago_mish as mish;
<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "projectasiago/mish-web",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: projectasiago/mish-web path: /src/lib.rs
#![feature(proc_macro)]
extern crate wasm_bindgen;
extern crate projectasiago_mish as mish;
use wasm_bindgen::prelude::*;
<|fim_suffix|>}
#[wasm_bindgen]
pub fn greet(input: &str) {
alert(&format!("Input: {}. Mish: {}", input, mish::hello_world()));
... | code_fim | medium | {
"lang": "rust",
"repo": "projectasiago/mish-web",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen]
pub fn greet(input: &str) {
alert(&format!("Input: {}. Mish: {}", input, mish::hello_world()));
}<|fim_prefix|>// repo: projectasiago/mish-web path: /src/lib.rs
#![feature(proc_macro)]
extern crate wasm_bindgen;
extern crate projectasiago_mish as mish;
<|fim_middle|>use wasm_bindgen::p... | code_fim | medium | {
"lang": "rust",
"repo": "projectasiago/mish-web",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let denominator = 2.0 * a;
if denominator == 0.0 {
return Solution::NoSolution;
}
let sqr_root = b.powf(2.0) - 4.0 * a * c;
if sqr_root == 0.0 {
let value = (-b + 0.0) / denominator;
if forbidden_numbers.contains(&value) {
Solution::NoSolution
... | code_fim | hard | {
"lang": "rust",
"repo": "C0RR1T/midnight-formula",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: C0RR1T/midnight-formula path: /src/main.rs
use std::io;
enum Solution {
NoSolution,
OneSolution(f64),
TwoSolutions(f64, f64),
}
fn main() {
let std = io::stdin();
loop {
let mut inputs = String::new();
let mut amount_string: String = String::new();
p... | code_fim | hard | {
"lang": "rust",
"repo": "C0RR1T/midnight-formula",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x => {
let first_value = (-b + x.sqrt()) / denominator;
let second_value = (-b - x.sqrt()) / denominator;
let contains_first_value = forbidden_numbers.contains(&first_value);
let contains_second_value = forbidden_numbers.contains(... | code_fim | hard | {
"lang": "rust",
"repo": "C0RR1T/midnight-formula",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/imports/import6.rs
// run-pass
#![allow(unused_imports)]
<|fim_suffix|>mod foo {
pub mod zed {
pub fn baz() { println!("baz"); }
}
}
mod bar {
pub use foo::zed::baz;
}
pub fn main() { baz(); }<|fim_middle|>use foo::zed... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/imports/import6.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod foo {
pub mod zed {
pub fn baz() { println!("baz"); }
}
}
mod bar {
pub use foo::zed::baz;
}
pub fn main() { baz(); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/imports/import6.rs
// run-pass
#![allow(unused_imports)]
<|fim_middle|>use foo::zed... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/imports/import6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn subscriptionwithinvalidname_invalid() {
let input = include_str!("validate_module_names/fixtures/SubscriptionWithInvalidName.invalid.graphql");
let expected = include_str!("validate_module_names/fixtures/SubscriptionWithInvalidName.invalid.expected");
test_fixture(transform_fixture,... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/relay",
"path": "/compiler/crates/relay-transforms/tests/validate_module_names_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = include_str!("validate_module_names/fixtures/FragmentWithValidName.other-suffix.ios.and-another.graphql");
let expected = include_str!("validate_module_names/fixtures/FragmentWithValidName.other-suffix.ios.and-another.expected");
test_fixture(transform_fixture, "FragmentWithValidNa... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/relay",
"path": "/compiler/crates/relay-transforms/tests/validate_module_names_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/relay path: /compiler/crates/relay-transforms/tests/validate_module_names_test.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated Si... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/relay",
"path": "/compiler/crates/relay-transforms/tests/validate_module_names_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/biscuit-rust path: /src/parser.rs
,
value(Operator::In, tag("in")),
value(Operator::NotIn, tag("not in")),
value(Operator::Matches, tag("matches")),
))(i)
}
fn constraint_kind(i: &str) -> IResult<&str, builder::ConstraintKind> {
let (i, op) = delimited(sp... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/biscuit-rust",
"path": "/src/parser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/biscuit-rust path: /src/parser.rs
romStr for builder::Predicate {
type Err = error::Token;
fn from_str(s: &str) -> Result<Self, Self::Err> {
predicate(s)
.map(|(_, o)| o)
.map_err(|_| error::Token::ParseError)
}
}
fn predicate(i: &str) -> IRe... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/biscuit-rust",
"path": "/src/parser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let h = [1, 2].iter().cloned().collect::<HashSet<_>>();
assert_eq!(
super::constraint("$0 in [1, 2]"),
Ok((
"",
builder::Constraint {
id: 0,
kind: builder::ConstraintKind::Integer(builder::IntCo... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/biscuit-rust",
"path": "/src/parser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn format_zero_file_size() {
assert_eq!(format!("{}", ContentRange {
start: 0,
end: 0,
file_size: 0,
}), "bytes */0");
}
fn last(num: u64) -> Range {
Range::SingleRangeOfBytes(Slice::Last(num))
}
fn from(num: u64... | code_fim | hard | {
"lang": "rust",
"repo": "swindon-rs/http-file-headers",
"path": "/src/output.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swindon-rs/http-file-headers path: /src/output.rs
use std::cmp::min;
use std::fmt::{self, Display};
use std::fs::{Metadata, File};
use std::io::{self, Read, Write, Seek, SeekFrom};
use std::time::{UNIX_EPOCH, Duration};
use std::sync::Arc;
use httpdate::HttpDate;
use accept_encoding::Encoding;... | code_fim | hard | {
"lang": "rust",
"repo": "swindon-rs/http-file-headers",
"path": "/src/output.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn smlink_exist() -> bool {
let mut link_path = get_installation_path();
link_path.push("smlink");
match std::fs::read_link(link_path.to_str().unwrap()) {
Ok(fp) => true,
Err(e) => match e.kind() {
std::io::ErrorKind::NotFound => false,
std::io::Erro... | code_fim | hard | {
"lang": "rust",
"repo": "trayanr/fvm",
"path": "/src/symlink.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trayanr/fvm path: /src/symlink.rs
use std::fs::File;
use crate::installation_path::get_installation_path;
#[cfg(target_family = "unix")]
pub fn create_symlink(dir_name: String) {
let mut path = get_installation_path();
let mut link_path = get_installation_path();
path.push(dir_name... | code_fim | hard | {
"lang": "rust",
"repo": "trayanr/fvm",
"path": "/src/symlink.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: claucece/openmls path: /tls-codec/src/tls_vec.rs
//! A vector with a length field for TLS serialisation.
//! Use this for any vector that is serialised.
use serde::ser::SerializeStruct;
use std::convert::TryInto;
use crate::{Cursor, Deserialize, Error, Serialize};
macro_rules! impl_tls_vec {
... | code_fim | hard | {
"lang": "rust",
"repo": "claucece/openmls",
"path": "/tls-codec/src/tls_vec.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl<'de> serde::de::Visitor<'de> for FieldVisitor {
type Value = Field;
fn expecting(
&self,
formatter: &mut std::fmt::Formatter,
) ... | code_fim | hard | {
"lang": "rust",
"repo": "claucece/openmls",
"path": "/tls-codec/src/tls_vec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: input-output-hk/jormungandr path: /jormungandr-lib/src/interfaces/config/mod.rs
mod log;
mod mempool;
mod node;
mod secret;
pub use log::{Log, LogEntry, LogOutput};
pub us<|fim_suffix|>, CorsOrigin, JRpc, LayersConfig, NodeConfig, NodeId, P2p, Policy, PreferredListConfig,
Rest, Tls, TopicsO... | code_fim | medium | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/jormungandr-lib/src/interfaces/config/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Rest, Tls, TopicsOfInterest, TrustedPeer,
};
pub use secret::{Bft, GenesisPraos, NodeSecret};<|fim_prefix|>// repo: input-output-hk/jormungandr path: /jormungandr-lib/src/interfaces/config/mod.rs
mod log;
mod mempool;
mod node;
mod secret;
pub use log::{Log, LogEntry, LogOutput};
pub use mempool::{LogMa... | code_fim | medium | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/jormungandr-lib/src/interfaces/config/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: srghma/lorri path: /src/ops/init.rs
//! Bootstrap a new lorri project
use crate::ops::error::{ok_msg, ExitError, OpResult};
use std::fs::File;
use std::io;
use std::io::Write;
use std::path::Path;
fn create_if_missing(path: &Path, contents: &str, msg: &str) -> Result<(), io::Error> {
if pa... | code_fim | hard | {
"lang": "rust",
"repo": "srghma/lorri",
"path": "/src/ops/init.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// See the documentation for lorri::cli::Command::Init for
/// more details
pub fn main(default_shell: &str, default_envrc: &str) -> OpResult {
create_if_missing(
Path::new("./shell.nix"),
default_shell,
"shell.nix exists, skipping. Make sure it is of a form that works with ni... | code_fim | hard | {
"lang": "rust",
"repo": "srghma/lorri",
"path": "/src/ops/init.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> create_if_missing(
Path::new("./.envrc"),
default_envrc,
".envrc exists, skipping. Please add 'eval \"$(lorri direnv)\" to it to set up lorri support."
).map_err(|e| ExitError::user_error(format!("{}", e)))?;
ok_msg(String::from("\nSetup done."))
}<|fim_prefix|>// repo... | code_fim | hard | {
"lang": "rust",
"repo": "srghma/lorri",
"path": "/src/ops/init.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if depth == 0 {
return inp;
}
let mut ln = Float::with_val(precision, inp.ln());
ln = ln * pi;
ln.exp_mut();
println!("pi{}={}", depth, ln.to_string_radix(10, Some(1039_usize)));
return pow_pi(ln, &pi, depth - 1, precision);
}<|fim_prefix|>// repo: cabarclay/matt-par... | code_fim | hard | {
"lang": "rust",
"repo": "cabarclay/matt-parker-conjecture",
"path": "/src/main.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cabarclay/matt-parker-conjecture path: /src/main.rs
use rug::Float;
use std::fs::File;
use std::io::prelude::Read;
use std::time::SystemTime;
fn main() {
// load digits of pi
let mut f = File::open("pi.10000").expect("file failed to open");
let mut digits_of_pi = String::new();
... | code_fim | medium | {
"lang": "rust",
"repo": "cabarclay/matt-parker-conjecture",
"path": "/src/main.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> dotenv::dotenv().ok();
pretty_env_logger::init();
let spec = oas3::from_path("./data/oas-samples/pet-store.yml").expect("api spec parse error");
let base_url: &str = &spec.primary_server().expect("no primary server").url;
let mut runner = TestRunner::new(base_url, spec.clone());
... | code_fim | medium | {
"lang": "rust",
"repo": "transparencies/oas3-rs",
"path": "/examples/conformance.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let spec = oas3::from_path("./data/oas-samples/pet-store.yml").expect("api spec parse error");
let base_url: &str = &spec.primary_server().expect("no primary server").url;
let mut runner = TestRunner::new(base_url, spec.clone());
runner.add_tests(&[
ConformanceTestSpec::named(
... | code_fim | medium | {
"lang": "rust",
"repo": "transparencies/oas3-rs",
"path": "/examples/conformance.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: transparencies/oas3-rs path: /examples/conformance.rs
#![allow(dead_code, unused_variables)]
use oas3::conformance::{
ConformanceTestSpec, OperationSpec, RequestSpec, ResponseSpec, TestRunner,
};
<|fim_suffix|> dotenv::dotenv().ok();
pretty_env_logger::init();
let spec = oas3::... | code_fim | medium | {
"lang": "rust",
"repo": "transparencies/oas3-rs",
"path": "/examples/conformance.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/simd-intrinsic/simd-intrinsic-generic-bitmask.rs
// Test that the simd_bitmask intrinsic produces ok-ish error
// messages when misused.
#![feature(repr_simd, platform_intrinsics)]
#![allow(non_camel_case_types)]
#[repr(simd)]
#[derive(Copy, C... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/simd-intrinsic/simd-intrinsic-generic-bitmask.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
let _: u8 = simd_bitmask(m2);
let _: u8 = simd_bitmask(m4);
let _: u8 = simd_bitmask(m8);
let _: u16 = simd_bitmask(m16);
let _: u32 = simd_bitmask(m32);
let _: u64 = simd_bitmask(m64);
let _: u16 = simd_bitmask(m2);
//~^ ERROR ... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/simd-intrinsic/simd-intrinsic-generic-bitmask.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ranjitc/nextaction-rs path: /src/protocol.rs
use std::collections::BTreeMap;
use std::cmp::{PartialOrd, Ordering};
use hyper::Client;
use hyper::client::Response;
use hyper::header::{ContentType, UserAgent, Accept, qitem};
use hyper::status::StatusCode;
use hyper::net::HttpsConnector;
use hyper... | code_fim | hard | {
"lang": "rust",
"repo": "ranjitc/nextaction-rs",
"path": "/src/protocol.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn flush(self) -> Result<CommandResponse> {
use std::io::Read;
let count = self.commands.len();
info!("{} items flushed", count);
if count == 0 {
return Ok(CommandResponse::default());
}
let mut resp = self.todoist
.post(vec!... | code_fim | hard | {
"lang": "rust",
"repo": "ranjitc/nextaction-rs",
"path": "/src/protocol.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct TodoistResponse {
pub projects: Option<Vec<Project>>,
pub notes: Option<Vec<Note>>,
pub items: Option<Vec<Item>>,
pub labels: Option<Vec<Label>>,
pub user: Option<User>,
full_sync: bool,
pub sync_token: String,
}
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "ranjitc/nextaction-rs",
"path": "/src/protocol.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn calculate_fuel(mass: i64) -> i64 {
// integer division equals flooring
let fuel = (mass / 3) - 2;
if fuel < 0 { 0 } else { fuel }
}<|fim_prefix|>// repo: sbmueller/AdventOfCode-2019 path: /day1/day1.rs
use std::fs::File;
use std::io::{prelude::*, BufReader, Result};
fn main() -> Result<()... | code_fim | hard | {
"lang": "rust",
"repo": "sbmueller/AdventOfCode-2019",
"path": "/day1/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbmueller/AdventOfCode-2019 path: /day1/day1.rs
use std::fs::File;
use std::io::{prelude::*, BufReader, Result};
fn main() -> Result<()> {
let mut total_fuel = 0;
let mut additional_fuel;
let file = File::open("input.txt")?;
let reader = BufReader::new(file);
for line in r... | code_fim | medium | {
"lang": "rust",
"repo": "sbmueller/AdventOfCode-2019",
"path": "/day1/day1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn calculate_fuel(mass: i64) -> i64 {
// integer division equals flooring
let fuel = (mass / 3) - 2;
if fuel < 0 { 0 } else { fuel }
}<|fim_prefix|>// repo: sbmueller/AdventOfCode-2019 path: /day1/day1.rs
use std::fs::File;
use std::io::{prelude::*, BufReader, Result};
fn main(... | code_fim | hard | {
"lang": "rust",
"repo": "sbmueller/AdventOfCode-2019",
"path": "/day1/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: folkertdev/elm-test-rs path: /src/help.rs
//! Print manually crafted help message.
//! Automatic help is not handled by the lightweight pico-args.
/// Print help message.
pub fn main() {
println!("{}", USAGE);
}
<|fim_suffix|>USAGE:
elm-test-rs [<SUBCOMMAND>] [FLAGS] [TESTFILES]
Fo... | code_fim | medium | {
"lang": "rust",
"repo": "folkertdev/elm-test-rs",
"path": "/src/help.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isabella232/rust-hands-on path: /09-error-handling/error-handling/src/main.rs
#![allow(unused)]
use std::fs::File;
use std::io;
use std::io::{Error, Read};
use std::net::IpAddr;
fn main() {
<|fim_suffix|> // another_panic();
// open_file();
// open_file_2();
// let result: Re... | code_fim | medium | {
"lang": "rust",
"repo": "isabella232/rust-hands-on",
"path": "/09-error-handling/error-handling/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v = vec![1, 2, 3];
v[99];
}
fn open_file() {
let f = File::open("hello.txt"); // f: Result<std::fs::File, std::io::Error>
let x = match f {
Ok(file) => file, // file: std::fs::File
Err(error) => { // error: std::io::Error
panic!("There was a problem openi... | code_fim | medium | {
"lang": "rust",
"repo": "isabella232/rust-hands-on",
"path": "/09-error-handling/error-handling/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrDIMAS/rg3d-physics path: /src/rigid_body.rs
use rg3d_core::{
math::vec3::Vec3,
visitor::{Visit, VisitResult, Visitor},
pool::Handle
};
use crate::{
contact::Contact,
convex_shape::{ConvexShape, TriangleShape},
gjk_epa,
static_geometry::{
StaticTriangle,
... | code_fim | hard | {
"lang": "rust",
"repo": "mrDIMAS/rg3d-physics",
"path": "/src/rigid_body.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn solve_triangle_collision(&mut self, triangle: &StaticTriangle, triangle_index: usize, static_geom: Handle<StaticGeometry>) {
let triangle_shape = ConvexShape::Triangle(TriangleShape {
vertices: triangle.points
});
if let Some(simplex) = gjk_epa::gjk_is_inter... | code_fim | hard | {
"lang": "rust",
"repo": "mrDIMAS/rg3d-physics",
"path": "/src/rigid_body.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)]
pub struct UserResponse {
id: uuid::Uuid
}
impl UserResponse {
pub fn new(id: uuid::Uuid) -> Self {
Self { id }
}
}<|fim_prefix|>// repo: dreamteam-challanges/pic-pay-challenge path: /src/schemata/mod.rs
use crate::diplomat::db::{self, DbExecu... | code_fim | medium | {
"lang": "rust",
"repo": "dreamteam-challanges/pic-pay-challenge",
"path": "/src/schemata/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dreamteam-challanges/pic-pay-challenge path: /src/schemata/mod.rs
use crate::diplomat::db::{self, DbExecutor};
use crate::adapter;
use actix::prelude::*;
use diesel::{result::QueryResult};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct User {
pub n... | code_fim | medium | {
"lang": "rust",
"repo": "dreamteam-challanges/pic-pay-challenge",
"path": "/src/schemata/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn transform_tags<'ev>(
parser: impl Iterator<Item = Event<'ev>>
) -> impl Iterator<Item = Event<'ev>> {
parser.map(|mut ev| {
match ev {
Event::Start(ref mut tag) | Event::End(ref mut tag) => {
Self::transform_tag(tag);
... | code_fim | hard | {
"lang": "rust",
"repo": "PeterCxy/paprika",
"path": "/src/blog.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PeterCxy/paprika path: /src/blog.rs
// Utility functions and structs for the blogging system
// Due to limitations of the Cloudflare Workers KV, we do not
// store the entire state in one record; instead, different
// parts are stroed in different records. This also increases
// efficiency, sin... | code_fim | hard | {
"lang": "rust",
"repo": "PeterCxy/paprika",
"path": "/src/blog.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
if let Some(args) = e.release_args() {
simulation.key_release(args);
}
if let Some(args) = e.update_args() {
grid.update(simulation.get_buttons());
simulation.update_camera(&mut camera, args.dt, fps_window.... | code_fim | hard | {
"lang": "rust",
"repo": "clynamen/roadsim2d",
"path": "/src/bin/road_main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let vertices_mat = nb::DMatrix::<f64>::from_row_slice(3, 6, &[
0.0, 2.0, 0.0, 4.0, 5.0, 4.0,
0.0, 0.0, 2.0, 4.0, 4.0, 5.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0
]);
let transformed_m... | code_fim | hard | {
"lang": "rust",
"repo": "clynamen/roadsim2d",
"path": "/src/bin/road_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.