text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: 0xflotus/grapl path: /src/rust/node-identifier/tests/assetdb_integration_tests.rs
use graph_descriptions::graph_description::host::HostId;
use node_identifier::assetdb::AssetIdDb;
use node_identifier::init_dynamodb_client;
use rusoto_core::Region;
use tokio::runtime::Runtime;
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "0xflotus/grapl",
"path": "/src/rust/node-identifier/tests/assetdb_integration_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Loizage/casper-get-started-3 path: /contract/src/errors.rs
use casper_types::ApiError;
#[repr(u16)]
pub enum Error {
UnknownApiCommand = 1,
PermissionDenied = 2,
ThresholdViolation = 3,
MaxKeysLimit = 4,
DuplicateKey = 5,
KeyManagementThreshold = 6,
DeploymentThresho... | code_fim | hard | {
"lang": "rust",
"repo": "Loizage/casper-get-started-3",
"path": "/contract/src/errors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ASTBase {
pub fn empty()->Self { ASTBase { base: Simplify{ base: RawASTBase::empty() }}}
pub fn raw_ast(&self)->&RawASTBase { &self.base.base }
pub fn raw_ast_mut(&mut self)->&mut RawASTBase { &mut self.base.base }}
test_base_consts!(ASTBase);
test_base_when!(ASTBase);
#[test] fn ast_and(){
... | code_fim | hard | {
"lang": "rust",
"repo": "tangentstorm/bex",
"path": "/src/ast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tangentstorm/bex path: /src/ast.rs
//! Abstract syntax trees (simple logic combinators).
use std::collections::{HashMap,HashSet};
use crate::base::*;
use crate::{nid, NID, Fun};
use crate::{vid, vid::VID};
use crate::{ops, ops::Ops};
use crate::simp;
#[derive(Debug)]
pub struct RawASTBase {... | code_fim | hard | {
"lang": "rust",
"repo": "tangentstorm/bex",
"path": "/src/ast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MWatch/kernel path: /kernel/src/application/states/mwatch.rs
use crate::application::FrameBuffer;
use crate::application::states::prelude::*;
use crate::system::input::InputEvent;
use crate::system::{System, Host};
use embedded_graphics::image::{Image, ImageRaw};
use embedded_graphics::mono_fon... | code_fim | hard | {
"lang": "rust",
"repo": "MWatch/kernel",
"path": "/kernel/src/application/states/mwatch.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Text::with_alignment(
"@MabezDev on Github",
Point::new(size.width as i32 / 2, 116),
style,
Alignment::Center,
)
.draw(display).ok();
None
}
fn input(&mut self, _system: &mut System<impl Host>, input: InputEvent) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "MWatch/kernel",
"path": "/kernel/src/application/states/mwatch.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> parse_filters(&vec!["brighten=1.1".to_string()]).unwrap();
}
#[test]
#[should_panic]
fn test_parse_filter_brighten_invalid_amount() {
parse_filters(&vec!["brighten=not_a_number".to_string()]).unwrap();
}
#[test]
#[should_panic]
fn test_parse_filter_bright... | code_fim | hard | {
"lang": "rust",
"repo": "JaakkoLipsanen/imgedit.rs",
"path": "/src/filters/parse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JaakkoLipsanen/imgedit.rs path: /src/filters/parse.rs
use std::error::Error;
use super::Filter;
/// Parses a list of strings as filters
pub fn parse_filters(filters: &[String]) -> Result<Vec<Filter>, Box<Error>> {
filters
.iter()
.map(|filter| {
let filter_name: ... | code_fim | hard | {
"lang": "rust",
"repo": "JaakkoLipsanen/imgedit.rs",
"path": "/src/filters/parse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gmiam/stubr path: /lib/src/model/response/template/req_ext.rs
use std::{borrow::Cow, collections::HashMap, iter, str::from_utf8};
use std::iter::FromIterator;
use itertools::Itertools;
use serde_json::Value;
use wiremock::Request;
pub(crate) type Queries<'a> = HashMap<Cow<'a, str>, Value>;
pub... | code_fim | hard | {
"lang": "rust",
"repo": "gmiam/stubr",
"path": "/lib/src/model/response/template/req_ext.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn headers(&self) -> Option<Headers> {
let headers = self.headers.iter()
.map(|(k, v)| {
let mut iter = v.iter();
let values = if let Some(first) = iter.next() {
if let Some(second) = iter.next() {
let all ... | code_fim | hard | {
"lang": "rust",
"repo": "gmiam/stubr",
"path": "/lib/src/model/response/template/req_ext.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn headers(&self) -> Option<Headers<'_>>;
}
impl RequestExt for Request {
fn url(&self) -> &str {
self.url.host_str()
.and_then(|host| self.url.as_str().split(host).last())
.unwrap_or_else(|| self.url.as_str())
}
fn path_segments(&self) -> Option<Vec<&str>... | code_fim | hard | {
"lang": "rust",
"repo": "gmiam/stubr",
"path": "/lib/src/model/response/template/req_ext.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bertptrs/adventofcode path: /2021/src/day25.rs
use std::io::Read;
fn read_input(input: &mut dyn Read) -> (usize, Vec<u8>) {
let mut result = Vec::new();
input.read_to_end(&mut result).unwrap();
let width = result.iter().position(|&c| c == b'\n').unwrap();
result.retain(|c| !c.i... | code_fim | hard | {
"lang": "rust",
"repo": "bertptrs/adventofcode",
"path": "/2021/src/day25.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> changes
}
pub fn part1(input: &mut dyn Read) -> String {
let (width, mut state) = read_input(input);
(1..)
.find(|_| !advance(width, &mut state))
.unwrap()
.to_string()
}
#[cfg(test)]
mod tests {
use super::*;
use crate::test_implementation;
const SAMPL... | code_fim | hard | {
"lang": "rust",
"repo": "bertptrs/adventofcode",
"path": "/2021/src/day25.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut offset = x;
while offset < state.len() - width {
if state[offset] == b'v' && state[offset + width] == b'.' {
state.swap(offset, offset + width);
changes = true;
offset += 2 * width;
} else {
of... | code_fim | hard | {
"lang": "rust",
"repo": "bertptrs/adventofcode",
"path": "/2021/src/day25.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crypto-forks/zero2prod path: /src/routes/mod.rs
mod health_checkers;
mod renamers;
mod sub_con<|fim_suffix|>b_confirm::*;
pub use subscriptions_ANYHOW::*;<|fim_middle|>firm;
mod subscriptions_ANYHOW;
pub use health_checkers::*;
pub use renamers::*;
pub use su | code_fim | medium | {
"lang": "rust",
"repo": "crypto-forks/zero2prod",
"path": "/src/routes/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>b_confirm::*;
pub use subscriptions_ANYHOW::*;<|fim_prefix|>// repo: crypto-forks/zero2prod path: /src/routes/mod.rs
mod health_checkers;
mod renamers;
mod sub_con<|fim_middle|>firm;
mod subscriptions_ANYHOW;
pub use health_checkers::*;
pub use renamers::*;
pub use su | code_fim | medium | {
"lang": "rust",
"repo": "crypto-forks/zero2prod",
"path": "/src/routes/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aburd/chip-8-interpreter-rust path: /src/display.rs
use console::Term;
pub fn draw_pixels(pixels: &[bool], w: usize, h: usize) {
let term = Term::stdout();
let frame = pixels
.chunks(w)
.map(|row| {
row.i<|fim_suffix|>Vec<String>>()
.join("\n");
t... | code_fim | medium | {
"lang": "rust",
"repo": "aburd/chip-8-interpreter-rust",
"path": "/src/display.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>Vec<String>>()
.join("\n");
term.write_str(&frame);
term.clear_last_lines(h);
}<|fim_prefix|>// repo: aburd/chip-8-interpreter-rust path: /src/display.rs
use console::Term;
pub fn draw_pixels(pixels: &[bool], w: usize, h: usize) {
let term = Term::stdout();
let frame = pixels
... | code_fim | medium | {
"lang": "rust",
"repo": "aburd/chip-8-interpreter-rust",
"path": "/src/display.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Transaction with multiple operations
pool.transaction(|conn| {
diesel::insert_into(dsl::users)
.values((dsl::id.eq(0), dsl::name.eq("Jim")))
.execute(conn)
.unwrap();
diesel::insert_into(dsl::users)
.values((dsl::id.eq(1), dsl::nam... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/async-bb8-diesel",
"path": "/examples/usage.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let manager = async_bb8_diesel::ConnectionManager::<PgConnection>::new("localhost:1234");
let pool = bb8::Pool::builder().build(manager).await.unwrap();
// Insert by values
let _ = diesel::insert_into(dsl::users)
.values((dsl::id.eq(0), dsl::name.eq("Jim")))
.execute_async... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/async-bb8-diesel",
"path": "/examples/usage.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/async-bb8-diesel path: /examples/usage.rs
use async_bb8_diesel::{
AsyncConnection, AsyncRunQueryDsl, AsyncSaveChangesDsl, ConnectionError, OptionalExtension,
PoolError,
};
use diesel::{pg::PgConnection, prelude::*};
table! {
users (id) {
id -> Integer,
... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/async-bb8-diesel",
"path": "/examples/usage.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use crate::section_0141::small_node_size;
use crate::section_0200::delete_token_ref;
use crate::section_1341::close_node;
use crate::section_1341::language_node;
use crate::section_1341::open_node;
use crate::section_1341::open_node_size;
use crate::section_1341::special_node;
... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_1358.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_node {
free_node($globals, p, small_node_size as _);
}
// othercases confusion("ext3")
else {
confusion($globals, crate::strpool_str!("ext3"))?;
}
// @:this can't happen ext3}{\quad ext3@>
// endcases;@/
// goto done;
crate::goto_forward_label!($lbl_done);
... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_1358.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_1358.rs
//! ` `
// @<Wipe out the whatsit...@>=
pub(crate) macro Wipe_out_the_whatsit_node_p_and_goto_done($globals:expr, $p:expr, $lbl_done:lifetime) {{
let p = $p;
let subtype_p = subtype!($globals, p);
// begin case subtype(p) o... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_1358.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: schungx/rhai path: /src/func/builtin.rs
lo(as_int, as_int)),
PowerOf => return impl_op!(INT => power(as_int, as_int)),
RightShift => return impl_op!(INT => Ok(shift_right(as_int, as_int))),
LeftShift => return impl_op!(INT => Ok(shift_left(as_int, ... | code_fim | hard | {
"lang": "rust",
"repo": "schungx/rhai",
"path": "/src/func/builtin.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Non-compatible ranges
if (type1, type2)
== (
TypeId::of::<ExclusiveRange>(),
TypeId::of::<InclusiveRange>(),
)
|| (type1, type2)
== (
TypeId::of::<InclusiveRange>(),
TypeId::of::<ExclusiveRange>(),
... | code_fim | hard | {
"lang": "rust",
"repo": "schungx/rhai",
"path": "/src/func/builtin.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: schungx/rhai path: /src/func/builtin.rs
_ => (),
}
return match op {
EqualsTo => impl_op!(INT => as_int == as_int),
NotEqualsTo => impl_op!(INT => as_int != as_int),
GreaterThan => impl_op!(INT => as_int > a... | code_fim | hard | {
"lang": "rust",
"repo": "schungx/rhai",
"path": "/src/func/builtin.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>type UnderlyingType = Box<Iterator<Item = Result<u8, Error>>>;
pub struct TokenIterator {
iterator: Peekable<UnderlyingType>
}
impl TokenIterator {
pub fn new(file: File) -> TokenIterator {
TokenIterator{ iterator: (Box::new(file.bytes()) as UnderlyingType).peekable() }
}
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "fennekki/cbLIA",
"path": "/src/tokenizer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fennekki/cbLIA path: /src/tokenizer.rs
use std::io::Bytes;
use std::io::Read;
use std::iter::Peekable;
use std::fs::File;
use std::result::Result;
use std::io::Error;
macro_rules! emit_token_number {
($buf:ident) => {{
// The following involves some magic
// First convert th... | code_fim | hard | {
"lang": "rust",
"repo": "fennekki/cbLIA",
"path": "/src/tokenizer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, S> TaskMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Delete a task from a TaskQueue.
///
/// # Arguments
///
/// * `project` - The project under which the queue lies.
/// * `taskqueue` - The taskqueue to delete a task f... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/google-apis-rs",
"path": "/gen/taskqueue1_beta2/src/api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/google-apis-rs path: /gen/taskqueue1_beta2/src/api.rs
rtCall {
hub: self.hub,
_request: request,
_project: project.to_string(),
_taskqueue: taskqueue.to_string(),
_delegate: Default::default(),
_additional_params: Defa... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/google-apis-rs",
"path": "/gen/taskqueue1_beta2/src/api.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/google-apis-rs",
"path": "/gen/taskqueue1_beta2/src/api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bottlerocket-os/bottlerocket path: /sources/models/src/modeled_types/shared.rs
ply an empty domain, which isn't
// allowed (must be at least one character).
ensure!(
!input.starts_with('-') && !input.starts_with('.'),
error::InvalidLinuxHostnameSnafu {
... | code_fim | hard | {
"lang": "rust",
"repo": "bottlerocket-os/bottlerocket",
"path": "/sources/models/src/modeled_types/shared.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let valid_identifier = input
.chars()
.all(|c| (c.is_ascii() && c.is_alphanumeric()) || c == '-')
&& input.len() <= CONTAINERD_ID_LENGTH;
ensure!(valid_identifier, error::InvalidIdentifierSnafu { input });
Ok(Identifier {
inner: input... | code_fim | hard | {
"lang": "rust",
"repo": "bottlerocket-os/bottlerocket",
"path": "/sources/models/src/modeled_types/shared.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bottlerocket-os/bottlerocket path: /sources/models/src/modeled_types/shared.rs
est]
fn valid_single_line_string() {
assert!(SingleLineString::try_from("").is_ok());
assert!(SingleLineString::try_from("hi").is_ok());
let long_string = " ".repeat(9999);
assert!(... | code_fim | hard | {
"lang": "rust",
"repo": "bottlerocket-os/bottlerocket",
"path": "/sources/models/src/modeled_types/shared.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/connectors/query-connector/src/filter/scalar/compare.rs
Into<ConditionValue>,
{
Filter::from(ScalarFilter {
projection: ScalarProjection::Single(self.clone()),
condition: ScalarCondition::NotContains(val.into()),
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connectors/query-connector/src/filter/scalar/compare.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Field does not contain the given value.
fn not_contains<T>(&self, val: T) -> Filter
where
T: Into<ConditionValue>,
{
Filter::from(ScalarFilter {
projection: ScalarProjection::Compound(self.as_scalar_fields().expect("Todo composites in filters.")),
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connectors/query-connector/src/filter/scalar/compare.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
T: Into<ConditionValue>,
{
Filter::from(ScalarFilter {
projection: ScalarProjection::Compound(self.as_scalar_fields().expect("Todo composites in filters.")),
condition: ScalarCondition::LessThan(val.into()),
mode: QueryMode::Default,
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connectors/query-connector/src/filter/scalar/compare.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> { __gl_imports::mem::transmute::<_, extern "system" fn(types::GLdouble, types::GLdouble, types::GLdouble) -> ()>(self.Vertex3d.f)(x, y, z) }
#[allow(non_snake_case)] #[allow(unused_variables)] #[allow(dead_code)]
#[inline] pub unsafe fn Vertex3dv(&self, v: *const types::GLdouble) -> () { __gl... | code_fim | hard | {
"lang": "rust",
"repo": "jbowen93/Rust",
"path": "/Piston_Test1/target/debug/build/glutin-0f9344966ce31e75/out/test_gl_bindings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbowen93/Rust path: /Piston_Test1/target/debug/build/glutin-0f9344966ce31e75/out/test_gl_bindings.rs
es)] #[allow(dead_code)]
#[inline] pub unsafe fn PixelStoref(&self, pname: types::GLenum, param: types::GLfloat) -> () { __gl_imports::mem::transmute::<_, extern "system" fn(types::GL... | code_fim | hard | {
"lang": "rust",
"repo": "jbowen93/Rust",
"path": "/Piston_Test1/target/debug/build/glutin-0f9344966ce31e75/out/test_gl_bindings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Component for AppleComponent {
type Storage = NullStorage<Self>;
}<|fim_prefix|>// repo: chtorr97/amethyst_snake path: /src/components/apple.rs
use amethyst::ecs::prelude::*;
<|fim_middle|>#[derive(Default)]
pub struct AppleComponent {}
| code_fim | easy | {
"lang": "rust",
"repo": "chtorr97/amethyst_snake",
"path": "/src/components/apple.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chtorr97/amethyst_snake path: /src/components/apple.rs
use amethyst::ecs::prelude::*;
<|fim_suffix|>impl Component for AppleComponent {
type Storage = NullStorage<Self>;
}<|fim_middle|>#[derive(Default)]
pub struct AppleComponent {}
| code_fim | easy | {
"lang": "rust",
"repo": "chtorr97/amethyst_snake",
"path": "/src/components/apple.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod data_stream;
pub use self::data_stream::DataStream;
mod stream_state;
use self::stream_state::{DequeueWriteResult, StreamState};
mod stream_map;
use self::stream_map::{StreamMap, StreamMapEntry};
mod client_configuration;
pub use self::client_configuration::ClientConfiguration;
mod server_configur... | code_fim | hard | {
"lang": "rust",
"repo": "Lukazoid/lz_quic",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lukazoid/lz_quic path: /src/lib.rs
#![recursion_limit = "1024"]
#![cfg_attr(feature = "unstable", feature(test))]
#![allow(dead_code)]
extern crate binary_tree;
#[macro_use]
extern crate bitflags;
extern crate byteorder;
extern crate bytes;
extern crate chrono;
extern crate conv;
extern crate d... | code_fim | hard | {
"lang": "rust",
"repo": "Lukazoid/lz_quic",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod stream_map;
use self::stream_map::{StreamMap, StreamMapEntry};
mod client_configuration;
pub use self::client_configuration::ClientConfiguration;
mod server_configuration;
pub use self::server_configuration::ServerConfiguration;
mod new_client;
pub use self::new_client::NewClient;
mod perspective;... | code_fim | hard | {
"lang": "rust",
"repo": "Lukazoid/lz_quic",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: outersky/simple_excel_writer path: /src/workbook.rs
pe_xml(value));
writer.write_all(fmt.as_bytes())?;
}
let fmt_tail = "\n </numFmts>\n".as_bytes();
writer.write_all(fmt_tail)?;
}
let mid = br#" <fonts count="1">
... | code_fim | hard | {
"lang": "rust",
"repo": "outersky/simple_excel_writer",
"path": "/src/workbook.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: outersky/simple_excel_writer path: /src/workbook.rs
{}\" fillId=\"{}\" borderId=\"{}\" xfId=\"{}\" applyNumberFormat=\"{}\"/>", xf.num_fmt_id, xf.font_id, xf.fill_id, xf.border_id, xf.xf_id, xf.apply_num_fmt);
writer.write_all(xf_entry.as_bytes())?;
}
let ... | code_fim | hard | {
"lang": "rust",
"repo": "outersky/simple_excel_writer",
"path": "/src/workbook.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> </a:gs>
</a:gsLst>
<a:path path="circle">
<a:fillToRect l="50000" t="-80000" r="50000" b="180000"/>
</a:path>
</a:gradFill>
<a:gradFill rotWithShape="1">
<a:gsLst>
... | code_fim | hard | {
"lang": "rust",
"repo": "outersky/simple_excel_writer",
"path": "/src/workbook.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if c == '\n' {
xx = 0;
yy += VERTICAL_SPACE;
continue;
}
if let Some(i) = CHARS.find(c) {
let mut data = self.data.chunks((WIDTH * HEIGHT) as usize).nth(i).unwrap().iter();
for y in yy..yy + HEIGHT {
for x in xx..xx + WIDTH {
let val = *data.next().unwrap() as usi... | code_fim | hard | {
"lang": "rust",
"repo": "bytefall/lotus3",
"path": "/src/graphics/sprite_font.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytefall/lotus3 path: /src/graphics/sprite_font.rs
use super::{Color, Point, Printable};
const CHARS: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.()";
const WIDTH: u32 = 16;
const HEIGHT: u32 = 18;
const HORIZONTAL_SPACE: u32 = 14;
const VERTICAL_SPACE: u32 = 24;
const PALETTE: &[Color] = &... | code_fim | hard | {
"lang": "rust",
"repo": "bytefall/lotus3",
"path": "/src/graphics/sprite_font.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(i) = CHARS.find(c) {
let mut data = self.data.chunks((WIDTH * HEIGHT) as usize).nth(i).unwrap().iter();
for y in yy..yy + HEIGHT {
for x in xx..xx + WIDTH {
let val = *data.next().unwrap() as usize;
if val == 0 {
continue;
}
let buffer = &mut b... | code_fim | hard | {
"lang": "rust",
"repo": "bytefall/lotus3",
"path": "/src/graphics/sprite_font.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pombredanne/chm-hash-rs path: /benches/state_lookup.rs
use criterion::{criterion_group, criterion_main, Criterion};
use rand::rngs::StdRng;
use rand::seq::SliceRandom;
use rand::SeedableRng;
use std::collections::HashMap;
const TABLE: [(&str, &str, u32); 50] = [
("AL", "Alabama", 4335400),... | code_fim | hard | {
"lang": "rust",
"repo": "pombredanne/chm-hash-rs",
"path": "/benches/state_lookup.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng: StdRng = SeedableRng::seed_from_u64(42);
keys.shuffle(&mut rng);
c.bench_function("perfect hash lookup", move |b| {
let h = h.clone();
b.iter(move || {
assert_eq!(TABLE[h.hash("NV")].1, TABLE[27].1);
assert_eq!(TABLE[h.hash("KS")].1, TABLE[... | code_fim | hard | {
"lang": "rust",
"repo": "pombredanne/chm-hash-rs",
"path": "/benches/state_lookup.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FenrirWolf/megaton-hammer path: /megaton-ipc/src/nn/audio/detail/impl_i_final_output_recorder_manager_for_applet.rs
use megaton_hammer::kernel::{FromKObject, KObject, Session};
use megaton_hammer::error::Result;
#[derive(Debug)]
pub struct IFinalOutputRecorderManagerForApplet(Session);
impl I... | code_fim | hard | {
"lang": "rust",
"repo": "FenrirWolf/megaton-hammer",
"path": "/megaton-ipc/src/nn/audio/detail/impl_i_final_output_recorder_manager_for_applet.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[repr(C)] #[derive(Clone)]
struct InRaw {
unk0: u64,
unk1: u64,
}
let req = Request::new(1)
.args(InRaw {
unk0,
unk1,
})
;
let mut res : Response<()> = self.0.send(req)?;
Ok(res.pop_handle())
}
}
impl FromKObject for IFinalOutputRecorderManagerForApplet {
unsafe fn ... | code_fim | hard | {
"lang": "rust",
"repo": "FenrirWolf/megaton-hammer",
"path": "/megaton-ipc/src/nn/audio/detail/impl_i_final_output_recorder_manager_for_applet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Add<&'a Self> for U64
{
type Output = U64;
fn add(self, rhs: &'a Self) -> Self::Output
{
max(self, *rhs)
}
}
impl AddAssign for U64
{
fn add_assign<'a>(&mut self, rhs: Self)
{
*self = max(*self, rhs);
}
}
impl<'a> AddAssign<&'a Self> for U64
{
fn add_assign(&mut self, rhs:&'a Self)
... | code_fim | hard | {
"lang": "rust",
"repo": "Emoun/progysis",
"path": "/src/core/lattices/complete_lattice_for_std_types/u_64.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Emoun/progysis path: /src/core/lattices/complete_lattice_for_std_types/u_64.rs
use crate::core::{CompleteLattice, Bottom};
use std::{
ops::{
Add, AddAssign
},
cmp::{
max
}
};
#[derive(Copy, Clone, Debug, PartialOrd, PartialEq, Ord, Eq)]
pub struct U64(pub u64);
impl CompleteLattice fo... | code_fim | hard | {
"lang": "rust",
"repo": "Emoun/progysis",
"path": "/src/core/lattices/complete_lattice_for_std_types/u_64.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
max(self, rhs)
}
}
impl<'a> Add<&'a Self> for U64
{
type Output = U64;
fn add(self, rhs: &'a Self) -> Self::Output
{
max(self, *rhs)
}
}
impl AddAssign for U64
{
fn add_assign<'a>(&mut self, rhs: Self)
{
*self = max(*self, rhs);
}
}
impl<'a> AddAssign<&'a Self> for U64
{
fn add_assign... | code_fim | hard | {
"lang": "rust",
"repo": "Emoun/progysis",
"path": "/src/core/lattices/complete_lattice_for_std_types/u_64.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tarqd/unhtml.rs path: /unhtml/src/err.rs
use derive_more::{Display, From};
// TODO: SourceNotFound should contain selector info
#[derive(Display, Debug, From)]
pub enum Error {
#[d<|fim_suffix|> type_name: String,
err: String,
},
}
impl std::error::Error for Error {}
pub... | code_fim | hard | {
"lang": "rust",
"repo": "tarqd/unhtml.rs",
"path": "/unhtml/src/err.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> type_name: String,
err: String,
},
}
impl std::error::Error for Error {}
pub type Result<T> = std::result::Result<T, Error>;<|fim_prefix|>// repo: tarqd/unhtml.rs path: /unhtml/src/err.rs
use derive_more::{Display, From};
// TODO: SourceNotFound should contain selector info
#[derive... | code_fim | medium | {
"lang": "rust",
"repo": "tarqd/unhtml.rs",
"path": "/unhtml/src/err.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(n < BIG_NUMBER.len());
BIG_NUMBER.chars()
.filter_map(|c| c.to_digit(10)) // c.to_digit is Option
.map(|n| n as u64)
.collect::<Vec<u64>>()
.windows(n)
.map(|w| w.iter().fold(1, |a, b| a*b))
.max()
.unwrap()
}
fn main() {
printl... | code_fim | medium | {
"lang": "rust",
"repo": "laucia/euler-project",
"path": "/src/bin/8.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laucia/euler-project path: /src/bin/8.rs
// [Problem 8]: (https://projecteuler.net/problem=8)
// - - - - - - - - - - - - - - - - - - - - - - - - -
// The four adjacent digits in the 1000-digit number that have the greatest
// product are 9 × 9 × 8 × 9 = 5832.
// 7316717653133062491922511... | code_fim | hard | {
"lang": "rust",
"repo": "laucia/euler-project",
"path": "/src/bin/8.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let hex_addr = format!("0x{}", self.to_hex());
let checksummed_addr = eth_checksum::checksum(&hex_addr);
checksummed_addr
}
}
// impl StrAddr for Address {}
impl StrAddr for H160 {}<|fim_prefix|>// repo: dendisuhubdy/degen-wallet path: /degen-wallet-rs/src/eth/wallet/domain.r... | code_fim | medium | {
"lang": "rust",
"repo": "dendisuhubdy/degen-wallet",
"path": "/degen-wallet-rs/src/eth/wallet/domain.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dendisuhubdy/degen-wallet path: /degen-wallet-rs/src/eth/wallet/domain.rs
use std::fmt::LowerHex;
use bitcoin::hashes::hex::ToHex;
use web3::types::H160;
//the below got replaced with web3::types::Address
// #[derive(Debug, Serialize, Deserialize, Clone)]
// pub struct EthAddr(String);
//
// ... | code_fim | medium | {
"lang": "rust",
"repo": "dendisuhubdy/degen-wallet",
"path": "/degen-wallet-rs/src/eth/wallet/domain.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct ASTWhile {
pub condition: ASTExpr,
pub block: ASTStmtBlock
}
#[derive(Debug)]
pub struct ASTFor {
pub ident: Symbol,
pub iter: ASTExpr,
pub block: ASTStmtBlock
}
#[derive(Debug)]
pub enum ASTOperator {
Assign,
Or,
And,
Not,
Ls,
Gt,
... | code_fim | hard | {
"lang": "rust",
"repo": "Teln0/SolidPython",
"path": "/src/ast/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Teln0/SolidPython path: /src/ast/mod.rs
use crate::span::{BytePos, Symbol};
#[derive(Debug)]
pub enum ASTStmtKind {
FnDef(ASTFnDef),
Assert(ASTExpr),
If(ASTIf),
While(ASTWhile),
For(ASTFor),
Break,
Continue,
Return(ASTExpr),
Expr(ASTExpr)
// TODO : Class
... | code_fim | hard | {
"lang": "rust",
"repo": "Teln0/SolidPython",
"path": "/src/ast/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = lines.next();
let qaly = lines.fold(0.0f32, |acc, line| {
let input = line.unwrap();
let parsed_input = input
.split_whitespace()
.take(2)
.map(str::parse::<f32>)
.filter_map(std::result::Result::ok)
.collect::<Ve... | code_fim | medium | {
"lang": "rust",
"repo": "lancelafontaine/coding-challenges",
"path": "/kattis/qaly/rust/qaly/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lancelafontaine/coding-challenges path: /kattis/qaly/rust/qaly/src/main.rs
use std::io::{self, BufRead, Write};
type Result<T> = std::result::Result<T, Box<std::error::Error>>;
<|fim_suffix|> let stdin = io::stdin();
let stdout = io::stdout();
let stdin_handle = stdin.lock();
le... | code_fim | medium | {
"lang": "rust",
"repo": "lancelafontaine/coding-challenges",
"path": "/kattis/qaly/rust/qaly/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let qaly = lines.fold(0.0f32, |acc, line| {
let input = line.unwrap();
let parsed_input = input
.split_whitespace()
.take(2)
.map(str::parse::<f32>)
.filter_map(std::result::Result::ok)
.collect::<Vec<f32>>();
let qual... | code_fim | hard | {
"lang": "rust",
"repo": "lancelafontaine/coding-challenges",
"path": "/kattis/qaly/rust/qaly/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = vec![1, 2, 3];
let one = &n[0];
// using .get
match n.get(2) {
Some(three) => println!("matched letter {}", three),
None => println!("invalid element")
}
}<|fim_prefix|>// repo: ECJ222/the-year-of-the-rustacean path: /vectors/src/main.rs
#![allow(unused_variab... | code_fim | medium | {
"lang": "rust",
"repo": "ECJ222/the-year-of-the-rustacean",
"path": "/vectors/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ECJ222/the-year-of-the-rustacean path: /vectors/src/main.rs
#![allow(unused_variables)]
fn main() {
<|fim_suffix|> // using .get
match n.get(2) {
Some(three) => println!("matched letter {}", three),
None => println!("invalid element")
}
}<|fim_middle|> let v: Vec<i3... | code_fim | medium | {
"lang": "rust",
"repo": "ECJ222/the-year-of-the-rustacean",
"path": "/vectors/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // using .get
match n.get(2) {
Some(three) => println!("matched letter {}", three),
None => println!("invalid element")
}
}<|fim_prefix|>// repo: ECJ222/the-year-of-the-rustacean path: /vectors/src/main.rs
#![allow(unused_variables)]
fn main() {
let v: Vec<i32> = Vec::new(... | code_fim | easy | {
"lang": "rust",
"repo": "ECJ222/the-year-of-the-rustacean",
"path": "/vectors/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn remove(&mut self, id: &ProposalShortId) -> Option<PoolEntry> {
self.inner.remove(id)
}
pub(crate) fn fetch(&self, n: usize) -> Vec<ProposalShortId> {
self.inner.keys().take(n).cloned().collect()
}
}
impl CellProvider for PendingQueue {
fn cell(&self, o: ... | code_fim | hard | {
"lang": "rust",
"repo": "321cherish/ckb",
"path": "/shared/src/tx_pool/pending.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 321cherish/ckb path: /shared/src/tx_pool/pending.rs
#![allow(dead_code)]
use crate::tx_pool::types::PoolEntry;
use ckb_core::cell::{CellMeta, CellProvider, CellStatus};
use ckb_core::transaction::{OutPoint, ProposalShortId, Transaction};
use ckb_core::Cycle;
use fnv::FnvHashMap;
#[derive(Defau... | code_fim | hard | {
"lang": "rust",
"repo": "321cherish/ckb",
"path": "/shared/src/tx_pool/pending.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn size(&self) -> usize {
self.inner.len()
}
pub(crate) fn add_tx(&mut self, cycles: Option<Cycle>, tx: Transaction) -> Option<PoolEntry> {
let short_id = tx.proposal_short_id();
self.inner.insert(short_id, PoolEntry::new(tx, 0, cycles))
}
pub(crate) fn co... | code_fim | medium | {
"lang": "rust",
"repo": "321cherish/ckb",
"path": "/shared/src/tx_pool/pending.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct MeshColorData {
pub name: String,
pub data: Vec<Vec4>,
}
// TODO: entity queries
// TODO: mesh building<|fim_prefix|>// repo: BlenderCN-Org/wasm-toys path: /src/scene/types.rs
use common::*;
#[derive(Debug)]
pub struct ToyFile {
pub scenes: Vec<SceneData>,
pub entities: ... | code_fim | medium | {
"lang": "rust",
"repo": "BlenderCN-Org/wasm-toys",
"path": "/src/scene/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BlenderCN-Org/wasm-toys path: /src/scene/types.rs
use common::*;
#[derive(Debug)]
pub struct ToyFile {
pub scenes: Vec<SceneData>,
pub entities: Vec<EntityData>,
pub meshes: Vec<MeshData>,
}
#[derive(Debug)]
pub struct SceneData {
pub name: String,
pub entities: Vec<u16>
}
#[derive(Debug... | code_fim | medium | {
"lang": "rust",
"repo": "BlenderCN-Org/wasm-toys",
"path": "/src/scene/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct MeshData {
pub positions: Vec<Vec3>,
pub indices: MeshIndices,
pub color_data: Vec<MeshColorData>,
}
#[derive(Debug)]
pub enum MeshIndices {
U8(Vec<u8>),
U16(Vec<u16>),
}
#[derive(Debug)]
pub struct MeshColorData {
pub name: String,
pub data: Vec<Vec4>,
}
// TODO: ent... | code_fim | medium | {
"lang": "rust",
"repo": "BlenderCN-Org/wasm-toys",
"path": "/src/scene/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>lete::*;
pub use get::*;
pub use update::*;<|fim_prefix|>// repo: LazyMechanic/wussup path: /src/api/rest/models/settings/mod.rs
pub mod common;
pub mod create;
pub mod de<|fim_middle|>lete;
pub mod get;
pub mod update;
pub use common::*;
pub use create::*;
pub use de | code_fim | medium | {
"lang": "rust",
"repo": "LazyMechanic/wussup",
"path": "/src/api/rest/models/settings/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LazyMechanic/wussup path: /src/api/rest/models/settings/mod.rs
pub mod common;
pub mod create;
pub mod de<|fim_suffix|>e common::*;
pub use create::*;
pub use delete::*;
pub use get::*;
pub use update::*;<|fim_middle|>lete;
pub mod get;
pub mod update;
pub us | code_fim | easy | {
"lang": "rust",
"repo": "LazyMechanic/wussup",
"path": "/src/api/rest/models/settings/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e common::*;
pub use create::*;
pub use delete::*;
pub use get::*;
pub use update::*;<|fim_prefix|>// repo: LazyMechanic/wussup path: /src/api/rest/models/settings/mod.rs
pub mod common;
pub mod create;
pub mod de<|fim_middle|>lete;
pub mod get;
pub mod update;
pub us | code_fim | easy | {
"lang": "rust",
"repo": "LazyMechanic/wussup",
"path": "/src/api/rest/models/settings/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zerohours/rocket-authorization path: /src/lib.rs
extern crate rocket;
pub mod parse;
pub mod respond;
<|fim_suffix|> pub use parse::{basic::Basic, oauth::OAuth, Authorization, Credential, ParseError};
pub use respond::request_authorization;
}<|fim_middle|>pub mod prelude {
use super... | code_fim | easy | {
"lang": "rust",
"repo": "zerohours/rocket-authorization",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub use parse::{basic::Basic, oauth::OAuth, Authorization, Credential, ParseError};
pub use respond::request_authorization;
}<|fim_prefix|>// repo: zerohours/rocket-authorization path: /src/lib.rs
extern crate rocket;
pub mod parse;
pub mod respond;
<|fim_middle|>pub mod prelude {
use super... | code_fim | easy | {
"lang": "rust",
"repo": "zerohours/rocket-authorization",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn fits(&self, size: usize) -> bool { size == 0 }
fn auth(&self) -> Auth { Anyone }
fn run(&mut self, _: &[&str], _: &Context, _: &mut Db) -> Outcome {
Ok(vec![Reply("Marp.".to_owned())])
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn marps() {
... | code_fim | medium | {
"lang": "rust",
"repo": "jnbooth/tex",
"path": "/src/command/zyn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jnbooth/tex path: /src/command/zyn.rs
use super::*;
pub struct Zyn;
impl Command for Zyn {
fn cmds(&self) -> Vec<String> {
abbrev("zyn")
}
fn usage(&self) -> String { "".to_owned() }
<|fim_suffix|> assert_eq!(Zyn.test_def("").unwrap(), "Marp.")
}
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "jnbooth/tex",
"path": "/src/command/zyn.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Zyn.test_def("").unwrap(), "Marp.")
}
}<|fim_prefix|>// repo: jnbooth/tex path: /src/command/zyn.rs
use super::*;
pub struct Zyn;
impl Command for Zyn {
fn cmds(&self) -> Vec<String> {
abbrev("zyn")
}
fn usage(&self) -> String { "".to_owned() }
... | code_fim | medium | {
"lang": "rust",
"repo": "jnbooth/tex",
"path": "/src/command/zyn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> SoundData(Arc::from(v))
}
}
impl From<Box<[u8]>> for SoundData {
fn from(b: Box<[u8]>) -> Self {
SoundData(Arc::from(b))
}
}
impl AsRef<[u8]> for SoundData {
#[inline]
fn as_ref(&self) -> &[u8] {
self.0.as_ref()
}
}
/// A source of audio data connected to... | code_fim | hard | {
"lang": "rust",
"repo": "Phlosioneer/ggez",
"path": "/src/audio.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Pauses playback
pub fn pause(&self) {
self.sink.pause()
}
/// Resumes playback
pub fn resume(&self) {
self.sink.play()
}
/// Stops playback
pub fn stop(&self) {
self.sink.stop()
}
/// Returns whether or not the source is stopped
//... | code_fim | hard | {
"lang": "rust",
"repo": "Phlosioneer/ggez",
"path": "/src/audio.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phlosioneer/ggez path: /src/audio.rs
//! Provides an interface to output sound to the user's speakers.
//!
//! It consists of two main types: `SoundData` is just raw sound data,
//! and a `Source` is a `SoundData` connected to a particular sound
//! channel.
use std::fmt;
use std::io;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "Phlosioneer/ggez",
"path": "/src/audio.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dsp/wezterm path: /src/frontend/glium/window.rs
let width = width as u16;
let height = height as u16;
let renderer = Renderer::new(&host.display, width, height, fonts)?;
Ok(GliumTerminalWindow {
host,
config: Arc::clone(config),
fon... | code_fim | hard | {
"lang": "rust",
"repo": "dsp/wezterm",
"path": "/src/frontend/glium/window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
state: ElementState,
button: glutin::MouseButton,
modifiers: glium::glutin::ModifiersState,
) -> Result<(), Error> {
let mux = Mux::get().unwrap();
let tab = match mux.get_active_tab_for_window(self.get_mux_window_id()) {
Some(tab)... | code_fim | hard | {
"lang": "rust",
"repo": "dsp/wezterm",
"path": "/src/frontend/glium/window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dsp/wezterm path: /src/frontend/glium/window.rs
hanged(None, Some(dpi_scale), width as u16, height as u16)?;
} else {
self.resize_surfaces(width as u16, height as u16, false)?;
}
Ok(())
}
}
impl GliumTerminalWindow {
pub fn new(
event_loop: &R... | code_fim | hard | {
"lang": "rust",
"repo": "dsp/wezterm",
"path": "/src/frontend/glium/window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seanaye/wasm-game-of-life path: /src/lib.rs
mod utils;
extern crate fixedbitset;
use wasm_bindgen::prelude::*;
use fixedbitset::FixedBitSet;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: ... | code_fim | hard | {
"lang": "rust",
"repo": "seanaye/wasm-game-of-life",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for row in 0..self.height {
for col in 0..self.width {
let id = self.get_index(row, col);
if self.new_cells[id] {
next.set(id, true);
self.new_cells.set(id, false);
} else {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "seanaye/wasm-game-of-life",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut start_ok = connection::StartOk::default();
start_ok.client_properties = client_properties;
start_ok.mechanism = "PLAIN".to_string();
start_ok.response = b"\0mq\0mq".to_vec();
start_ok.locale = "en_US".to_string();
tx.send(Frame::from_method(0, &start_ok).unwrap()).unwrap();... | code_fim | hard | {
"lang": "rust",
"repo": "zBaitu/rabbitmq-rust-client",
"path": "/examples/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zBaitu/rabbitmq-rust-client path: /examples/test.rs
extern crate amqp;
use std::io::{self, Read};
use std::thread;
use std::time::Duration;
use amqp::conf::Conf;
use amqp::frame::Frame;
use amqp::protocol::*;
use amqp::transport::Transport;
use amqp::types;
use amqp::types::*;
use amqp::types:... | code_fim | hard | {
"lang": "rust",
"repo": "zBaitu/rabbitmq-rust-client",
"path": "/examples/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let open = connection::Open::default();
tx.send(Frame::from_method(0, &open).unwrap()).unwrap();
let frame = tx.recv().unwrap();
let open_ok: connection::OpenOk = frame.to_method().unwrap();
println!("{:#?}", open_ok);
//thread::sleep(Duration::from_secs(3));
io::stdin().read... | code_fim | hard | {
"lang": "rust",
"repo": "zBaitu/rabbitmq-rust-client",
"path": "/examples/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'zf, T> ZeroFrom<'zf, ZeroSlice<T>> for ZeroVec<'zf, T>
where
T: 'static + AsULE + ?Sized,
{
#[inline]
fn zero_from(other: &'zf ZeroSlice<T>) -> Self {
ZeroVec::new_borrowed(other.as_ule_slice())
}
}
impl<'zf, T> ZeroFrom<'zf, ZeroSlice<T>> for &'zf ZeroSlice<T>
where
T: ... | code_fim | hard | {
"lang": "rust",
"repo": "mozilla/gecko-dev",
"path": "/third_party/rust/zerovec/src/zerofrom_impls.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unicode",
"source": "the-stack-v2"
} |
<|fim_suffix|> other
}
}
impl<'zf, 's, K, V> ZeroFrom<'zf, ZeroMap<'s, K, V>> for ZeroMap<'zf, K, V>
where
K: 'static + for<'b> ZeroMapKV<'b> + ?Sized,
V: 'static + for<'b> ZeroMapKV<'b> + ?Sized,
<K as ZeroMapKV<'zf>>::Container: ZeroFrom<'zf, <K as ZeroMapKV<'s>>::Container>,
<V as ZeroMap... | code_fim | hard | {
"lang": "rust",
"repo": "mozilla/gecko-dev",
"path": "/third_party/rust/zerovec/src/zerofrom_impls.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unicode",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mozilla/gecko-dev path: /third_party/rust/zerovec/src/zerofrom_impls.rs
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
use crate::map::ZeroM... | code_fim | hard | {
"lang": "rust",
"repo": "mozilla/gecko-dev",
"path": "/third_party/rust/zerovec/src/zerofrom_impls.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unicode",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.