text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> self::routes::mount(
rocket::build()
.manage(smartx_whitedog_zeus_client::ZeusClient::infer().await?)
.attach(cors),
)
.launch()
.await?;
Ok(())
}<|fim_prefix|>// repo: kerryeon/smartx-whitedog path: /zeus/manager/src/main.rs
#[macro_use]
extern crate r... | code_fim | hard | {
"lang": "rust",
"repo": "kerryeon/smartx-whitedog",
"path": "/zeus/manager/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct Version {
pub major: u32,
pub minor: u32,
pub micro: Option<u32>,
pub build_info: Option<String>,
}
impl Client {
pub fn version(&mut self, x: Arg) -> Result<Version, HglibError> {
let (data, _) = x.run(self)?;
let pat = Regex::new(r".*?(\d+... | code_fim | medium | {
"lang": "rust",
"repo": "daehyeok/hglib-rust",
"path": "/src/commands/version.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Version {
major: cap[1].iter().fold(0, |r, x| r * 10 + u32::from(*x - b'0')),
minor: cap[2].iter().fold(0, |r, x| r * 10 + u32::from(*x - b'0')),
micro,
build_info,
})
}
}<|fim_prefix|>// repo: daehyeok/hglib-rust path: /src/commands/... | code_fim | hard | {
"lang": "rust",
"repo": "daehyeok/hglib-rust",
"path": "/src/commands/version.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daehyeok/hglib-rust path: /src/commands/version.rs
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
use regex::bytes::Regex;
use crate::clien... | code_fim | hard | {
"lang": "rust",
"repo": "daehyeok/hglib-rust",
"path": "/src/commands/version.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Return an iterator over all [`Diagnostic`]s.
pub fn iter(&self) -> impl Iterator<Item = &Diagnostic> {
self.diagnostics.values()
}
/// Return an iterator over all [`Diagnostic`]s, by mutable reference.
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Diagnostic> {
... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_diagnostic/src/diagnostic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bevyengine/bevy path: /crates/bevy_diagnostic/src/diagnostic.rs
use bevy_app::App;
use bevy_ecs::system::{Deferred, Res, Resource, SystemBuffer, SystemParam};
use bevy_log::warn;
use bevy_utils::{Duration, Instant, StableHashMap, Uuid};
use std::{borrow::Cow, collections::VecDeque};
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_diagnostic/src/diagnostic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lafolle/Agastya path: /aoc/day10/src/lib.rs
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
println!("ans: {}", part1());
}
}
fn part1() -> u32 {
let contents = "46,41,212,83,1,255,157,65,139,52,39,254,2,86,0,204".to_string();
let lengths: V... | code_fim | hard | {
"lang": "rust",
"repo": "lafolle/Agastya",
"path": "/aoc/day10/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> cp += len + skip_size;
skip_size += 1;
}
list[0] as u32 * list[1] as u32
}<|fim_prefix|>// repo: lafolle/Agastya path: /aoc/day10/src/lib.rs
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
println!("ans: {}", part1());
}
}
fn part1() -... | code_fim | medium | {
"lang": "rust",
"repo": "lafolle/Agastya",
"path": "/aoc/day10/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elrnv/vtkio path: /src/basic.rs
use std::any::Any;
use std::num::NonZeroUsize;
use std::str::FromStr;
use byteorder::ByteOrder;
use num_traits::Zero;
use nom::branch::alt;
use nom::bytes::streaming::{tag, tag_no_case};
use nom::character::complete::{digit1, line_ending, multispace0, space0};
u... | code_fim | hard | {
"lang": "rust",
"repo": "elrnv/vtkio",
"path": "/src/basic.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! impl_from_ascii {
($type:ty, $fn:path) => {
impl FromAscii for $type {
fn from_ascii(input: &[u8]) -> IResult<&[u8], $type> {
$fn(input)
}
}
};
}
impl_from_ascii!(u8, nom::character::complete::u8);
impl_from_ascii!(i8, nom::char... | code_fim | hard | {
"lang": "rust",
"repo": "elrnv/vtkio",
"path": "/src/basic.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Into<Vec<NearMiss>> for FindNearMissesResult {
fn into(self) -> Vec<NearMiss> {
self.near_misses
}
}<|fim_prefix|>// repo: mmitteregger/wiremock-client-rs path: /src/verification/find_near_misses_result.rs
use serde::{Deserialize, Serialize};
use crate::verification::NearMiss;
<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "mmitteregger/wiremock-client-rs",
"path": "/src/verification/find_near_misses_result.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmitteregger/wiremock-client-rs path: /src/verification/find_near_misses_result.rs
use serde::{Deserialize, Serialize};
use crate::verification::NearMiss;
<|fim_suffix|>impl FindNearMissesResult {
pub fn near_misses(&self) -> &[NearMiss] {
&self.near_misses
}
}
impl Into<Vec<N... | code_fim | medium | {
"lang": "rust",
"repo": "mmitteregger/wiremock-client-rs",
"path": "/src/verification/find_near_misses_result.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gatoWololo/differential-datalog path: /rust/template/distributed_datalog/src/accumulate/mod.rs
mod accumulator;
mod observer;
#[cfg(any(test, feature = "test"))]
mod test;
mod txndistributor;
<|fim_suffix|>#[cfg(any(test, feature = "test"))]
pub use test::eq_updates;
#[cfg(any(test, feature = "... | code_fim | medium | {
"lang": "rust",
"repo": "gatoWololo/differential-datalog",
"path": "/rust/template/distributed_datalog/src/accumulate/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: little-dude/netlink path: /genetlink/examples/dump_family_policy.rs
// SPDX-License-Identifier: MIT
use std::env::args;
use anyhow::{bail, Error};
use futures::StreamExt;
use genetlink::new_connection;
use netlink_packet_core::{
NetlinkHeader,
NetlinkMessage,
NetlinkPayload,
NL... | code_fim | medium | {
"lang": "rust",
"repo": "little-dude/netlink",
"path": "/genetlink/examples/dump_family_policy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if argv.len() < 2 {
eprintln!("Usage: dump_family_policy <family name>");
bail!("Required arguments not given");
}
let nlmsg = NetlinkMessage {
header: NetlinkHeader {
flags: NLM_F_REQUEST | NLM_F_DUMP,
..Default::default()
},
pa... | code_fim | medium | {
"lang": "rust",
"repo": "little-dude/netlink",
"path": "/genetlink/examples/dump_family_policy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut responses = handle.request(nlmsg).await?;
while let Some(result) = responses.next().await {
let resp = result?;
match resp.payload {
NetlinkPayload::InnerMessage(genlmsg) => {
if genlmsg.payload.cmd == GenlCtrlCmd::GetPolicy {
... | code_fim | hard | {
"lang": "rust",
"repo": "little-dude/netlink",
"path": "/genetlink/examples/dump_family_policy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saqib006/learn-rust-programming path: /src/enums.rs
// enums are types which have a few definite values
enum Movement{
// variants
Up,
Down,
Left,
Right
}
fn move_avator(m:Movement){
<|fim_suffix|>
pub fn run(){
let avator1 = Movement::Left;
let avator2 = Movement... | code_fim | hard | {
"lang": "rust",
"repo": "saqib006/learn-rust-programming",
"path": "/src/enums.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn run(){
let avator1 = Movement::Left;
let avator2 = Movement::Right;
let avator3 = Movement::Up;
let avator4 = Movement::Down;
move_avator(avator1);
move_avator(avator2);
move_avator(avator3);
move_avator(avator4);
}<|fim_prefix|>// repo: saqib006/learn-rust-program... | code_fim | hard | {
"lang": "rust",
"repo": "saqib006/learn-rust-programming",
"path": "/src/enums.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //perform action depending on info
match m {
Movement::Up => println!("Avator moving up"),
Movement::Down => println!("Avator moving down"),
Movement::Left => println!("Avator moving left"),
Movement::Right => println!("Avator moving right")
}
}
pub fn run(){
... | code_fim | medium | {
"lang": "rust",
"repo": "saqib006/learn-rust-programming",
"path": "/src/enums.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elsuizo/rust_ciaa_z3r0 path: /src/dma/chreqmaskc/mod.rs
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::CHREQMASKC {
#[doc = r" Writes to the register"]
#[inline]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{... | code_fim | hard | {
"lang": "rust",
"repo": "elsuizo/rust_ciaa_z3r0",
"path": "/src/dma/chreqmaskc/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
const OFFSET: u8 = 3;
self.w.bits &= !((MASK as u32) << OFFSET);
self.w.bits |= ((value & MASK) as u32) << OFFSET;
self.w
}
}
#[doc = r" Proxy"]
pub struct _CH4REQMASKCW<'a> {
w: &'a mut W,
}
impl<'a> _CH4REQMASKCW<'a> {
#[doc = r" Sets the field bit"]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "elsuizo/rust_ciaa_z3r0",
"path": "/src/dma/chreqmaskc/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.w.bits |= ((value & MASK) as u32) << OFFSET;
self.w
}
}
impl W {
#[doc = r" Reset value of the register"]
#[inline]
pub fn reset_value() -> W {
W { bits: 0 }
}
#[doc = r" Writes raw bits to the register"]
#[inline]
pub unsafe fn bits(&mut self, bits: u... | code_fim | hard | {
"lang": "rust",
"repo": "elsuizo/rust_ciaa_z3r0",
"path": "/src/dma/chreqmaskc/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn assert_simplified<E1, E2>(input: E1, expected: E2)
where E1: IntoAnyExprOrError,
E2: IntoAnyExprOrError
{
let mut input = input.into_any_expr_or_error().unwrap();
let expected = expected.into_any_expr_or_error().unwrap();
simplify(&mut input);
... | code_fim | hard | {
"lang": "rust",
"repo": "inspier/stevia",
"path": "/simplifier/src/base.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn new_builder() -> PlainExprTreeBuilder {
PlainExprTreeBuilder::default()
}
#[test]
fn integration_01() {
let b = new_builder();
assert_simplified(
b.bitvec_add_n(vec![
b.bitvec_var(BitvecTy::w32(), "x"),
b.bitvec_const(... | code_fim | hard | {
"lang": "rust",
"repo": "inspier/stevia",
"path": "/simplifier/src/base.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: inspier/stevia path: /simplifier/src/base.rs
use stevia_ast::{
prelude::*,
ty::BitvecTy,
modular_ast_transformer,
transformer::{
TraverseTransformer,
AnyExprTransformer,
TransformEffect,
},
};
use crate::simplifications;
pub mod prelude {
pub use ... | code_fim | hard | {
"lang": "rust",
"repo": "inspier/stevia",
"path": "/simplifier/src/base.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bemyak/teloxide-core path: /src/types/chat_id.rs
use derive_more::{Display, From};
use serde::{Deserialize, Serialize};
/// A unique identifier for the target chat or username of the target channel
/// (in the format `@channelusername`).
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, De... | code_fim | medium | {
"lang": "rust",
"repo": "bemyak/teloxide-core",
"path": "/src/types/chat_id.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expected_json = String::from(r#"123456"#);
let actual_json = serde_json::to_string(&ChatId::Id(123_456)).unwrap();
assert_eq!(expected_json, actual_json)
}
#[test]
fn chat_id_channel_username_serialization() {
let expected_json = String::from(r#""@username... | code_fim | hard | {
"lang": "rust",
"repo": "bemyak/teloxide-core",
"path": "/src/types/chat_id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> })
}
}
pub struct CategoryDom {
}
impl CategoryDom {
pub fn render(cat: Rc<Category>, state: Rc<State>, is_root: bool) -> Dom {
let element_name = if is_root { "dropdown-tree" } else { "dropdown-tree-child" };
html!(element_name, {
.property_signal("label", ... | code_fim | hard | {
"lang": "rust",
"repo": "NaomiLea/ji-cloud",
"path": "/frontend/apps/crates/entry/admin/src/categories/dom.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> html!(element_name, {
.property_signal("label", cat.name.signal_cloned())
.property_signal("expanded", cat.expanded.signal())
.property_signal("hasChildren", cat.has_children_signal())
.property_signal("mode", cat.editing.signal().map(|editing| {
... | code_fim | hard | {
"lang": "rust",
"repo": "NaomiLea/ji-cloud",
"path": "/frontend/apps/crates/entry/admin/src/categories/dom.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NaomiLea/ji-cloud path: /frontend/apps/crates/entry/admin/src/categories/dom.rs
use dominator::{Dom, html, clone, with_node};
use futures_signals::signal::{Mutable, Signal, SignalExt};
use futures_signals::signal_vec::{MutableVec, SignalVec, SignalVecExt};
use std::rc::Rc;
use super::{state::*, ... | code_fim | hard | {
"lang": "rust",
"repo": "NaomiLea/ji-cloud",
"path": "/frontend/apps/crates/entry/admin/src/categories/dom.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pseudo-su/slack_manage_cli path: /src/main.rs
use std::fs;
use dotenv;
mod commands;
mod usergroups;
mod app_error;
mod channels;
mod users;
mod cli_opts;
use cli_opts::{Opts,GlobalOpts};
use app_error::AppError;
use structopt::StructOpt;
<|fim_suffix|> let token = token?;
// let verbos... | code_fim | hard | {
"lang": "rust",
"repo": "pseudo-su/slack_manage_cli",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match root_opts.command {
cli_opts::Command::ListMembers(command_ops) => {
commands::list_members(token, command_ops.query_opts)?
},
cli_opts::Command::AddMembersToChannel(command_opts) => {
commands::add_members_to_channel(token, command_opts.channel_na... | code_fim | hard | {
"lang": "rust",
"repo": "pseudo-su/slack_manage_cli",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> quickcheck! {
fn serializes(x: AutomationResponse) -> Result<TestResult, Error> {
use std::u16;
if x.mission_command_list.len() > (u16::MAX as usize) { return Ok(TestResult::discard()); }
if x.vehicle_command_list.len() > (u16::MAX as usize) { return Ok(Test... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/uxas_generated_lmcp",
"path": "/src/afrl/cmasi/automation_response.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GaloisInc/uxas_generated_lmcp path: /src/afrl/cmasi/automation_response.rs
// ===============================================================================
// Authors: AFRL/RQQA
// Organization: Air Force Research Laboratory, Aerospace Systems Directorate, Power and Control Division
//
// Cop... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/uxas_generated_lmcp",
"path": "/src/afrl/cmasi/automation_response.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn size(&self) -> usize {
if let Some(x) = AutomationResponseT::as_afrl_cmasi_automation_response(self.as_ref()) {
x.size()
} else {
unreachable!()
}
}
}
impl AutomationResponseT for AutomationResponse {
fn as_afrl_cmasi_automation_response(&se... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/uxas_generated_lmcp",
"path": "/src/afrl/cmasi/automation_response.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ret = unsafe {
ffi::crypto_box_seal_open(
// decrypted, ciphertext, CIPHERTEXT_LEN, recipient_pk, recipient_sk
m.as_mut_ptr(),
c.as_ptr(),
c.len() as c_ulong... | code_fim | hard | {
"lang": "rust",
"repo": "IvySeo/encrypt_decrypt_example",
"path": "/src/decrypt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IvySeo/encrypt_decrypt_example path: /src/decrypt.rs
// ============================================= DECRYPT =============================================
//! A particular combination of `Curve25519`, `Blake2B`, `XSalsa20` and `Poly1305`.
#![crate_name = "sodiumoxide"]
#![crate_type = "lib"]
e... | code_fim | hard | {
"lang": "rust",
"repo": "IvySeo/encrypt_decrypt_example",
"path": "/src/decrypt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if c.len() < SEALBYTES {
println!("error!");
return Err(());
}
let mut m = vec![0u8; c.len() - SEALBYTES];
let ret = unsafe {
ffi::crypto_box_seal_open(
// decrypted, ciphertext, CIPHERTEXT_LEN, recipient_pk, recipient_s... | code_fim | hard | {
"lang": "rust",
"repo": "IvySeo/encrypt_decrypt_example",
"path": "/src/decrypt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> setup_scenario(
rlbot,
ball_scenario.initial_state(),
car_scenario.initial_state(),
car_scenario.starting_boost,
enemy_scenario.initial_state(),
enemy_scenario.starting_boost,
);
let rigid_body_tick = physicist.next_flat().unwrap();
let firs... | code_fim | hard | {
"lang": "rust",
"repo": "aaronalbers/self-driving-car",
"path": "/brain/src/integration_tests/running_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aaronalbers/self-driving-car path: /brain/src/integration_tests/running_test.rs
use crate::{
behavior::higher_order::{Fuse, NullBehavior},
eeg::Event,
integration_tests::{
playback::{BallPlayback, BallRecording, CarPlayback, CarRecording},
utils::rotator,
},
s... | code_fim | hard | {
"lang": "rust",
"repo": "aaronalbers/self-driving-car",
"path": "/brain/src/integration_tests/running_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rlbot: &rlbot::RLBot,
ball: &RecordingRigidBodyState,
car: &RecordingRigidBodyState,
car_boost: f32,
enemy: &RecordingRigidBodyState,
enemy_boost: f32,
num_boosts: i32,
) {
let ball_state = rlbot::DesiredBallState::new().physics(
rlbot::DesiredPhysics::new()
... | code_fim | hard | {
"lang": "rust",
"repo": "aaronalbers/self-driving-car",
"path": "/brain/src/integration_tests/running_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakmeier/div-rs path: /src/style.rs
use crate::{error::*, utils::doc};
pub(crate) fn add_div_styles_to_document() -> Result<(), DivError> {
let css = r#"<|fim_suffix|> "#;
let head = doc()?.head().ok_or(DivError::MissingHead)?;
let style = doc()?.create_element("style")?;
style... | code_fim | medium | {
"lang": "rust",
"repo": "jakmeier/div-rs",
"path": "/src/style.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>le.set_attribute("type", "text/css")?;
style.set_text_content(Some(css));
head.append_child(&style)?;
Ok(())
}<|fim_prefix|>// repo: jakmeier/div-rs path: /src/style.rs
use crate::{error::*, utils::doc};
pub(crate) fn add_div_styles_to_document() -> Result<(), DivError> {
let css = r#"
... | code_fim | medium | {
"lang": "rust",
"repo": "jakmeier/div-rs",
"path": "/src/style.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> "#;
let head = doc()?.head().ok_or(DivError::MissingHead)?;
let style = doc()?.create_element("style")?;
style.set_attribute("type", "text/css")?;
style.set_text_content(Some(css));
head.append_child(&style)?;
Ok(())
}<|fim_prefix|>// repo: jakmeier/div-rs path: /src/style.rs
us... | code_fim | medium | {
"lang": "rust",
"repo": "jakmeier/div-rs",
"path": "/src/style.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexkreidler/sdmx-rust path: /lib/sdmx_sources.rs
use serde::{Deserialize, Serialize};
use std::{fmt::Debug, time::Duration};
pub type Sources = Vec<Source>;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Source {
pub id: String,
#[serde(skip_serializing_if = "Option::is_no... | code_fim | hard | {
"lang": "rust",
"repo": "alexkreidler/sdmx-rust",
"path": "/lib/sdmx_sources.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[serde(default)]
pub response_content_types: Vec<String>,
/// Accept headers for data queries
#[serde(skip_serializing_if = "Option::is_none")]
pub data_accept: Option<Accept>,
#[serde(default)]
// #[serde(skip_serializing_if = "Option::is_none")]
pub elapsed: Vec<Durati... | code_fim | medium | {
"lang": "rust",
"repo": "alexkreidler/sdmx-rust",
"path": "/lib/sdmx_sources.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hajifkd/rusq path: /src/prelude.rs
//!
//! A module meant to be glob imported when using Rusq.
//!
<|fim_suffix|>pub use gates::single::SingleGateApplicator;
pub use gates::double::DoubleGateApplicator;
pub use gates::triple::TripleGateApplicator;<|fim_middle|>pub use simulator::QuantumSimulato... | code_fim | medium | {
"lang": "rust",
"repo": "hajifkd/rusq",
"path": "/src/prelude.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use gates::single::SingleGateApplicator;
pub use gates::double::DoubleGateApplicator;
pub use gates::triple::TripleGateApplicator;<|fim_prefix|>// repo: hajifkd/rusq path: /src/prelude.rs
//!
//! A module meant to be glob imported when using Rusq.
//!
<|fim_middle|>pub use simulator::QuantumSimulato... | code_fim | medium | {
"lang": "rust",
"repo": "hajifkd/rusq",
"path": "/src/prelude.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for pixel in img.pixels_mut() {
let white: Rgba<u8> = Rgba { data: [255, 255, 255, 255] };
*pixel = white;
}
for cell in &qr.body {
for pixel in get_pixel_points(&cell) {
let (x, y, color) = pixel;
// if x % 20 == 0 || y % 20 == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "wismer/qr-encode",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wismer/qr-encode path: /src/main.rs
pub mod qr_encoder;
extern crate image as image_lib;
extern crate reed_solomon;
use qr_encoder::qr::QR;
use qr_encoder::config::{QRConfig};
use qr_encoder::cell::{Cell, CellType, Color};
use qr_encoder::util::{get_pixel_points, args};
use std::fs::File;
use... | code_fim | hard | {
"lang": "rust",
"repo": "wismer/qr-encode",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for cell in &qr.body {
for pixel in get_pixel_points(&cell) {
let (x, y, color) = pixel;
// if x % 20 == 0 || y % 20 == 0 {
// // cell border
// let rgb = Rgba { data: [125, 125, 125, 255] };
// img.put_pixel(x, y, rgb);
... | code_fim | medium | {
"lang": "rust",
"repo": "wismer/qr-encode",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kampfkarren/rbx-tree path: /rbx_xml/src/types/strings.rs
use std::io::{Read, Write};
use rbx_dom_weak::RbxValue;
use crate::{
core::XmlType,
deserializer::{DecodeError, XmlEventReader},
serializer::{EncodeError, XmlWriteEvent, XmlEventWriter},
};
pub struct StringType;
impl XmlTy... | code_fim | hard | {
"lang": "rust",
"repo": "Kampfkarren/rbx-tree",
"path": "/rbx_xml/src/types/strings.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test_value = "\n\t";
let expected_value = RbxValue::String {
value: test_value.to_owned(),
};
test_util::test_xml_round_trip::<StringType, _>(test_value, expected_value);
}
#[test]
fn de_protected_string() {
let test_value = "Hello,\n\t... | code_fim | hard | {
"lang": "rust",
"repo": "Kampfkarren/rbx-tree",
"path": "/rbx_xml/src/types/strings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Return the current DTD handler.
fn get_dtd_handler(&self) -> Option<&DH>;
/// Return the current DTD handler (mutable).
fn get_dtd_handler_mut(&self) -> Option<&mut DH>;
/// Return the current entity resolver.
fn get_entity_resolver(&self) -> Option<&ER>;
/// Return the cur... | code_fim | hard | {
"lang": "rust",
"repo": "compenguy/xml_parser_traits",
"path": "/src/sax2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: compenguy/xml_parser_traits path: /src/sax2.rs
tion.
///
/// The SAX parser must continue to provide normal parsing events after invoking this
/// method: it should still be possible for the application to process the document through
/// to the end. If the application cannot do ... | code_fim | hard | {
"lang": "rust",
"repo": "compenguy/xml_parser_traits",
"path": "/src/sax2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: compenguy/xml_parser_traits path: /src/sax2.rs
eport additional errors after a call to `fatal_error`. In other words, a SAX
/// driver class may throw an exception after reporting any `fatal_error`. Also parsers may throw
/// appropriate exceptions for non-XML errors. For example, `XmlReader.par... | code_fim | hard | {
"lang": "rust",
"repo": "compenguy/xml_parser_traits",
"path": "/src/sax2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: logicchains/Levgen-Parallel-Benchmarks path: /PR.rs
extern mod extra;
use std::{os, int, uint, u32, vec, comm};
use extra::time;
static TileDim: u32 = 50;
static WidMin: u32 = 2;
static RestWidMax: u32 = 8;
static NumLevs: uint= 800;
static NumCores: uint = 4;
static NumTries: uint = 50000... | code_fim | hard | {
"lang": "rust",
"repo": "logicchains/Levgen-Parallel-Benchmarks",
"path": "/PR.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn not_crash(new_x: u32, new_y: u32, new_w: u32, new_h: u32, rs: &[Room]) -> bool {
do rs.iter().all |r| {
let Room { x, y, w, h, _ } = *r;
((x + w + 1) < new_x ||
x > (new_x + new_w + 1) ||
(y + h + 1) < new_y ||
y > (new_y + new_h + 1))
}
}
fn room_to... | code_fim | hard | {
"lang": "rust",
"repo": "logicchains/Levgen-Parallel-Benchmarks",
"path": "/PR.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // quickly skip over data that doesn't need escaping
let n = data
.iter()
.take_while(|&&c| {
c != b'"' && c != b'&' && c != b'\'' && c != b'<' && c != b'>'
})
.count();
if n > 0 {
self.0.write(&data[0..n])... | code_fim | hard | {
"lang": "rust",
"repo": "Noughmad/ructe",
"path": "/src/template_utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Noughmad/ructe path: /src/template_utils.rs
/// This trait should be implemented for any value that can be the
/// result of an expression in a template.
///
/// This trait decides how to format the given object as html.
/// There exists a default implementation for any `T: Display` that
/// for... | code_fim | hard | {
"lang": "rust",
"repo": "Noughmad/ructe",
"path": "/src/template_utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod canvas;
#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))]
mod gl_canvas;
mod state;
#[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))]
mod webgl_canvas;
mod window;<|fim_prefix|>// repo: wizardwatch/kiss3d path: /src/window/mod.rs
//! The window, and things to handle the renderi... | code_fim | hard | {
"lang": "rust",
"repo": "wizardwatch/kiss3d",
"path": "/src/window/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wizardwatch/kiss3d path: /src/window/mod.rs
//! The window, and things to handle the rendering loop and events.
<|fim_suffix|>mod canvas;
#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))]
mod gl_canvas;
mod state;
#[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))]
mod webg... | code_fim | hard | {
"lang": "rust",
"repo": "wizardwatch/kiss3d",
"path": "/src/window/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_orbits() {
let input = vec![
"COM)B", "B)C", "C)D", "D)E", "E)F", "B)G", "G)H", "D)I", "E)J", "J)K", "K)L",
];
let edges: Vec<_> = input.iter().map(|e| e.parse::<Edge>().unwrap()).collect();
let map = OrbitMap::from_edges(&edges);
... | code_fim | hard | {
"lang": "rust",
"repo": "meyerphi/advent-of-code",
"path": "/2019/src/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: meyerphi/advent-of-code path: /2019/src/day6.rs
mod common;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::str::FromStr;
struct Edge {
source: String,
target: String,
}
impl FromStr for Edge {
type Err = &'static str;
fn from_str(s: &str) -> Result<Sel... | code_fim | hard | {
"lang": "rust",
"repo": "meyerphi/advent-of-code",
"path": "/2019/src/day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub trait Device {
// Each device has it's own type of handle
// eg: OpenGL has Rc as it does not support any multithreading anyways
fn supports_multithreading(&self) -> bool;
fn enable_debug_layer(&self) -> Result< (), String>;
fn create_command_list(&self) -> Box<dyn CommandList... | code_fim | hard | {
"lang": "rust",
"repo": "jonathansty/wireframe-rs",
"path": "/src/device/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonathansty/wireframe-rs path: /src/device/mod.rs
pub mod opengl;
use std::cell::RefCell;
use std::sync::Arc;
use crate::pipeline::Pipeline;
use crate::helpers;
#[allow(dead_code)]
#[derive(Copy, Clone)]
pub enum PrimitiveTopology {
Triangles,
Lines,
}
impl PrimitiveTopology {
fn ... | code_fim | medium | {
"lang": "rust",
"repo": "jonathansty/wireframe-rs",
"path": "/src/device/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn create_default_device(window : &sdl2::video::Window) -> DeviceHandle {
let device_handle = Arc::new(RefCell::new(opengl::GLDevice::for_sdl2(window).unwrap()));
DeviceHandle{
inner: device_handle
}
}<|fim_prefix|>// repo: jonathansty/wireframe-rs path: /src/device/mod.rs
pub mod... | code_fim | hard | {
"lang": "rust",
"repo": "jonathansty/wireframe-rs",
"path": "/src/device/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_accuracy /= no_splits as f32;
println!("Accuracy {}", test_accuracy);
assert!(test_accuracy > 0.9);
}
#[test]
fn serialization() {
let (data, target) = load_data();
let mut test_accuracy = 0.0;
let no_splits = 10;
let mut cv = ... | code_fim | hard | {
"lang": "rust",
"repo": "decentriq/rustlearn",
"path": "/src/linear_models/sgdclassifier.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: decentriq/rustlearn path: /src/linear_models/sgdclassifier.rs
multiclass::OneVsRestWrapper;
use utils::{check_data_dimensionality, check_matched_dimensions, check_valid_labels};
/// Hyperparameters for a `SGDClassifier` model.
#[derive(Serialize, Deserialize)]
pub struct Hyperparameters {
... | code_fim | hard | {
"lang": "rust",
"repo": "decentriq/rustlearn",
"path": "/src/linear_models/sgdclassifier.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> model.coefficients.as_mut_slice()[0] = 1.0;
model.coefficients.as_mut_slice()[1] = -1.0;
model.fit(&X, &y).unwrap();
assert!(model.coefficients.data()[0] == 0.5);
assert!(model.coefficients.data()[1] == -0.5);
// Should be regularised away to zero
... | code_fim | hard | {
"lang": "rust",
"repo": "decentriq/rustlearn",
"path": "/src/linear_models/sgdclassifier.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mashtizadeh/wasmtime path: /crates/c-api/src/lib.rs
//! This file defines the extern "C" API, which is compatible with the
//! [Wasm C API](https://github.com/WebAssembly/wasm-c-api).
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
// TODO complete the C API
mod config... | code_fim | hard | {
"lang": "rust",
"repo": "mashtizadeh/wasmtime",
"path": "/crates/c-api/src/lib.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod config;
mod engine;
mod error;
mod r#extern;
mod func;
mod global;
mod instance;
mod linker;
mod memory;
mod module;
mod r#ref;
mod store;
mod table;
mod trap;
mod types;
mod val;
mod vec;
pub use crate::config::*;
pub use crate::engine::*;
pub use crate::error::*;
pub use crate::func::*;
pub use cra... | code_fim | medium | {
"lang": "rust",
"repo": "mashtizadeh/wasmtime",
"path": "/crates/c-api/src/lib.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>ring),
Match(String),
NotMatch(String),
},
Text {
Contains(String),
Match(String),
NotMatch(String),
},
FlavorText {
Contains(String),
Match(String),
NotMatch(String),
},
}<|fim_prefix|>// repo: Lenqth/mtgjson-test path: ... | code_fim | hard | {
"lang": "rust",
"repo": "Lenqth/mtgjson-test",
"path": "/server/src/mtgjson/search.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lenqth/mtgjson-test path: /server/src/mtgjson/search.rs
enum Query {
Color {
Contain(Vec<Color>),
Match(Vec<Color>),
DontContain(Vec<Color>),
},
ColorIdentity {
Contain(Vec<Color>),
Match(Vec<Color>),
DontContain(Vec<Color>),
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Lenqth/mtgjson-test",
"path": "/server/src/mtgjson/search.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: norlen/clox-rust path: /src/vm/call_frame.rs
use super::{value::Value, Result, VMError};
use crate::memory::{Closure, Function, Gc};
#[derive(Clone)]
pub struct CallFrame {
pub closure: Gc<Closure>,
pub(super) ip: usize,
pub(super) stack_base: usize,
}
impl CallFrame {
pub(supe... | code_fim | hard | {
"lang": "rust",
"repo": "norlen/clox-rust",
"path": "/src/vm/call_frame.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(super) fn code(&self) -> &Vec<u8> {
&self.closure.as_ref().function.as_ref().chunk.code
}
pub(super) fn constants(&self) -> &Vec<Value> {
&self.closure.as_ref().function.as_ref().chunk.constants
}
}<|fim_prefix|>// repo: norlen/clox-rust path: /src/vm/call_frame.rs
us... | code_fim | hard | {
"lang": "rust",
"repo": "norlen/clox-rust",
"path": "/src/vm/call_frame.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(super) fn next_instruction_as_jump(&mut self) -> Result<usize> {
let b0 = self.next_instruction()? as usize;
let b1 = self.next_instruction()? as usize;
Ok(b0 << 8 | b1)
}
pub(super) fn function(&self) -> &Function {
self.closure.as_ref().function.as_ref()
... | code_fim | hard | {
"lang": "rust",
"repo": "norlen/clox-rust",
"path": "/src/vm/call_frame.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jan-xyz/adventofcode path: /2021/4/src/lib.rs
"LAST WINNER! board={:?}", cp);
return (sum_remaining(*cp), number);
}
}
}
None => {}
}
}
}
(-1, -1)
}
fn sum_remain... | code_fim | hard | {
"lang": "rust",
"repo": "jan-xyz/adventofcode",
"path": "/2021/4/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jan-xyz/adventofcode path: /2021/4/src/lib.rs
test]
fn test_flatindex_to_col() {
assert_eq!(flatindex_to_col(0), 0);
assert_eq!(flatindex_to_col(1), 1);
assert_eq!(flatindex_to_col(2), 2);
assert_eq!(flatindex_to_col(3), 3);
assert_eq!(flatindex_to_col... | code_fim | hard | {
"lang": "rust",
"repo": "jan-xyz/adventofcode",
"path": "/2021/4/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let numbers = vec![
25, 8, 32, 53, 22, 94, 55, 80, 33, 4, 63, 14, 60, 95, 31, 89, 30, 5, 47, 66, 84, 70,
17, 74, 99, 82, 21, 35, 64, 2, 76, 9, 90, 56, 78, 28, 51, 86, 49, 98, 29, 96, 23, 58,
52, 75, 41, 50, 13, 72, 92, 83, 62, 37, 18, 11, 34, 71, 91, 85, 27, 12,... | code_fim | hard | {
"lang": "rust",
"repo": "jan-xyz/adventofcode",
"path": "/2021/4/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> do term::ios::preserve {
term::ios::raw();
loop_chars();
}
loop_chars();
}<|fim_prefix|>// repo: doy/rust-term path: /test/termios2.rs
extern mod term;
fn loop_chars () {
<|fim_middle|> loop {
let ch = io::stdin().read_char();
io::stdout().write_char(ch);
... | code_fim | medium | {
"lang": "rust",
"repo": "doy/rust-term",
"path": "/test/termios2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doy/rust-term path: /test/termios2.rs
extern mod term;
fn loop_chars () {
loop {
let ch = io::stdin().read_char();
io::stdout().write_char(ch);
if ch == 'q' {
break;
}
}
}
<|fim_suffix|> do term::ios::preserve {
term::ios::raw();
... | code_fim | easy | {
"lang": "rust",
"repo": "doy/rust-term",
"path": "/test/termios2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lunabunn/kapp path: /src/window.rs
use crate::platform::*;
use std::cell::RefCell;
use std::rc::Rc;
/// A handle used to control a Window.
/// The window is closed when the Window instance is dropped.
pub struct Window {
pub id: WindowId,
platform_application: Rc<RefCell<PlatformApplica... | code_fim | hard | {
"lang": "rust",
"repo": "lunabunn/kapp",
"path": "/src/window.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Lets the OS know where it should place text input related popups like
/// accent character selection.
/// Position is specified relative to the window's upper left corner.
/// ONLY SUPPORTED ON MAC (for now)
pub fn set_text_input_rectangle(&self, x: f64, y: f64, width: f64, height:... | code_fim | hard | {
"lang": "rust",
"repo": "lunabunn/kapp",
"path": "/src/window.rs",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/p256-0.10.1/src/arithmetic/projective.rs
y: FieldElement::ONE,
z: FieldElement::ZERO,
};
/// Base point of P-256.
pub const GENERATOR: Self = Self {
x: AffinePoint::GENERATOR.x,
y: AffinePoint::GE... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/p256-0.10.1/src/arithmetic/projective.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AddAssign<&ProjectivePoint> for ProjectivePoint {
fn add_assign(&mut self, rhs: &ProjectivePoint) {
*self = ProjectivePoint::add(self, rhs);
}
}
impl Add<AffinePoint> for ProjectivePoint {
type Output = ProjectivePoint;
fn add(self, other: AffinePoint) -> ProjectivePoint {
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/p256-0.10.1/src/arithmetic/projective.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Mul<&Scalar> for ProjectivePoint {
type Output = ProjectivePoint;
fn mul(self, other: &Scalar) -> ProjectivePoint {
ProjectivePoint::mul(&self, other)
}
}
impl MulAssign<Scalar> for ProjectivePoint {
fn mul_assign(&mut self, rhs: Scalar) {
*self = ProjectivePoint::mu... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/p256-0.10.1/src/arithmetic/projective.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let matches = Command::new("hello")
.arg(Arg::new("CONFIG_FILE").index(1).required(true))
.get_matches();
let config_file = matches.get_one::<String>("CONFIG_FILE").unwrap();
let config: LoggerConfig = track_try_unwrap!(serdeconv::from_toml_file(config_file));
let builder ... | code_fim | medium | {
"lang": "rust",
"repo": "sile/sloggers",
"path": "/examples/hello.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config: LoggerConfig = track_try_unwrap!(serdeconv::from_toml_file(config_file));
let builder = track_try_unwrap!(config.try_to_builder());
let logger = track_try_unwrap!(builder.build());
info!(logger, "Hello World!");
}<|fim_prefix|>// repo: sile/sloggers path: /examples/hello.rs
#[... | code_fim | hard | {
"lang": "rust",
"repo": "sile/sloggers",
"path": "/examples/hello.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sile/sloggers path: /examples/hello.rs
#[macro_use]
extern crate slog;
#[macro_use]
extern crate trackable;
use clap::{Arg, Command};
use sloggers::{Build, Config, LoggerConfig};
<|fim_suffix|> let config: LoggerConfig = track_try_unwrap!(serdeconv::from_toml_file(config_file));
let bui... | code_fim | hard | {
"lang": "rust",
"repo": "sile/sloggers",
"path": "/examples/hello.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Patryk27/cr8r path: /apps/controller/src/rpc/config.rs
use serde::Deserialize;
<|fim_suffix|> #[serde(default)]
pub secret: Option<String>,
}<|fim_middle|>#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
pub struct RpcConfig {
pub address: String,
| code_fim | medium | {
"lang": "rust",
"repo": "Patryk27/cr8r",
"path": "/apps/controller/src/rpc/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[serde(default)]
pub secret: Option<String>,
}<|fim_prefix|>// repo: Patryk27/cr8r path: /apps/controller/src/rpc/config.rs
use serde::Deserialize;
<|fim_middle|>#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
pub struct RpcConfig {
pub address: String,
| code_fim | medium | {
"lang": "rust",
"repo": "Patryk27/cr8r",
"path": "/apps/controller/src/rpc/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jqnatividad/qsv path: /src/select.rs
use std::{
cmp::Ordering,
collections::HashSet,
fmt,
iter::{self, repeat},
ops, slice,
str::FromStr,
};
use regex::bytes::Regex;
use serde::de::{Deserialize, Deserializer, Error};
#[derive(Clone)]
pub struct SelectColumns {
selec... | code_fim | hard | {
"lang": "rust",
"repo": "jqnatividad/qsv",
"path": "/src/select.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(&row[*idx])
}
let get_field: _GetField = get_field;
self.iter().scan(row, get_field)
}
pub fn normal(&self) -> NormalSelection {
let Selection(inds) = self;
if inds.is_empty() {
return NormalSelection(vec![]);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jqnatividad/qsv",
"path": "/src/select.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bonedaddy/termplay path: /src/converters/truecolor.rs
use image::{GenericImage, Pixel};
use std::io::{self, Write};
#[derive(Clone, Copy, Debug)]
pub struct TrueColor;
<|fim_suffix|> where W: Write,
I: GenericImage<Pixel = P>,
P: Pixel<Subpixel = u8>
{
... | code_fim | medium | {
"lang": "rust",
"repo": "bonedaddy/termplay",
"path": "/src/converters/truecolor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ui_sessions = Arc::new(Sessions::new());
let github_handler_state =
Arc::new(GithubHandlerState::new(config.clone(), github.clone(), jira.clone(), core_remote.clone()));
let main_service = move || {
Ok(OctobotService::new(config.clone(), ui_sessions.clone(), github_handler... | code_fim | hard | {
"lang": "rust",
"repo": "thielium/octobot",
"path": "/src/server/main.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thielium/octobot path: /src/server/main.rs
use std::fs;
use std::io;
use std::io::Seek;
use std::net::SocketAddr;
use std::sync::{Arc, mpsc};
use std::thread;
use hyper::server::Http;
use rustls;
use rustls::internal::pemfile;
use tokio_core::reactor::Core;
use tokio_proto;
use tokio_rustls;
u... | code_fim | hard | {
"lang": "rust",
"repo": "thielium/octobot",
"path": "/src/server/main.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let jira: Option<Arc<jira::api::Session>>;
if let Some(ref jira_config) = config.jira {
jira = match JiraSession::new(core_remote.clone(), &jira_config) {
Ok(s) => Some(Arc::new(s)),
Err(e) => panic!("Error initiating jira session: {}", e),
};
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "thielium/octobot",
"path": "/src/server/main.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl App {
pub fn new(cx: &mut Cx) -> Self {
set_widget_style(cx, &StyleOptions{..StyleOptions::default()});
Self {
desktop_window: DesktopWindow::new(cx),
button: NormalButton::new(cx),
menu:Menu::main(vec![
Menu::sub("Example", vec... | code_fim | medium | {
"lang": "rust",
"repo": "rustyforks/makepad",
"path": "/examples/cmykw_example/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustyforks/makepad path: /examples/cmykw_example/src/main.rs
use makepad_render::*;
use makepad_widget::*;
//use tiff::decoder::{Decoder, DecodingResult};
//use tiff::ColorType;
use std::fs::File;
struct App {
desktop_window: DesktopWindow,
menu: Menu,
button:NormalButton,
}
<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "rustyforks/makepad",
"path": "/examples/cmykw_example/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.