text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>/// Generate a random 32-bit signed integer from the provided ChaCha8 RNG #[no_mangle] pub extern "C" fn chacha8_next_i32(rng: &mut ChaCha) -> i32 { rng.generate() } /// Generate a random 64-bit signed integer from the provided ChaCha8 RNG #[no_mangle] pub extern "C" fn chacha8_next_i64(rng: &mut ChaCha...
code_fim
hard
{ "lang": "rust", "repo": "DBLouis/nanorand-rs", "path": "/nanorand-abi/src/chacha/chacha8.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|>/// Generate a random 32-bit signed integer within a specified range from the provided ChaCha8 RNG #[no_mangle] pub extern "C" fn chacha8_range_i32(rng: &mut ChaCha, lower: i32, upper: i32) -> i32 { rng.generate_range(lower..=upper) } /// Generate a random 64-bit signed integer within a specified range ...
code_fim
hard
{ "lang": "rust", "repo": "DBLouis/nanorand-rs", "path": "/nanorand-abi/src/chacha/chacha8.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DBLouis/nanorand-rs path: /nanorand-abi/src/chacha/chacha8.rs use nanorand::{ChaCha8 as ChaCha, Rng}; /// Create a ChaCha RNG, using 8 rounds. #[no_mangle] pub extern "C" fn new_chacha8() -> ChaCha { ChaCha::new() } /// Create a ChaCha RNG, using 8 rounds, /// and the provided 256-bit key and...
code_fim
hard
{ "lang": "rust", "repo": "DBLouis/nanorand-rs", "path": "/nanorand-abi/src/chacha/chacha8.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chenenjie/kas path: /kas-wgpu/examples/counter.rs // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License in the LICENSE-APACHE file or at: // https://www.apache.org/license...
code_fim
hard
{ "lang": "rust", "repo": "chenenjie/kas", "path": "/kas-wgpu/examples/counter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> -> Response<VoidMsg> { match msg { Message::Decr => { self.counter = self.counter.saturating_sub(1); *mgr |= self.display.set_string(self.counter.to_string()); ...
code_fim
hard
{ "lang": "rust", "repo": "chenenjie/kas", "path": "/kas-wgpu/examples/counter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> env_logger::init(); // Most examples use make_widget! for layout, but here we use the Row widget // (compare with sync-counter.rs). Note that Row produces (index, child_msg) // messages, thus we use map_msg to remove the unwanted index. let buttons = Row::new(vec![ TextButton:...
code_fim
hard
{ "lang": "rust", "repo": "chenenjie/kas", "path": "/kas-wgpu/examples/counter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gasu16/Calcolatrice path: /src/main.rs use std::env; fn main() { let args: Vec<String> = env::args().collect(); let x: i32 = args[1].parse().unwrap(); <|fim_suffix|>fn add(x: i32, y: i32) { println!("{}", x + y); } fn sub(x: i32, y: i32) { println!("{}", x - y); } fn mul(x:...
code_fim
hard
{ "lang": "rust", "repo": "Gasu16/Calcolatrice", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn mul(x: i32, y: i32) { println!("{}", x * y); } fn div(x: i32, y: i32) { println!("{}", x / y); }<|fim_prefix|>// repo: Gasu16/Calcolatrice path: /src/main.rs use std::env; fn main() { let args: Vec<String> = env::args().collect(); let x: i32 = args[1].parse().unwrap(); let y: ...
code_fim
medium
{ "lang": "rust", "repo": "Gasu16/Calcolatrice", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brianloveswords/learn-rust path: /007: 10001st prime/10001st-prime2.rs use std::iter::range_step_inclusive; struct PrimeIter { state: u64 } fn main() { println!("{}", nth_prime(100001)); } impl Iterator<u64> for PrimeIter { fn next(&mut self) -> Option<u64> { loop { ...
code_fim
hard
{ "lang": "rust", "repo": "brianloveswords/learn-rust", "path": "/007: 10001st prime/10001st-prime2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if num == 2 { return true } if num < 2 || num % 2 == 0 { return false } let limit = sqrt(num); for i in range_step_inclusive(3, limit, 1) { if num % i == 0 { return false } } true } fn sqrt(num: u64) -> u64 { ((num as f64).sqrt().ceil()) as u...
code_fim
hard
{ "lang": "rust", "repo": "brianloveswords/learn-rust", "path": "/007: 10001st prime/10001st-prime2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cldfire/soundcloud-archive-site path: /backend/src/database.rs _id: Option<String>, /// A vector of ids for tracks that this user has liked on SoundCloud pub liked_track_ids: Vec<i64>, /// A vector of ids for playlists that this user has made or liked on /// SoundCloud pub pl...
code_fim
hard
{ "lang": "rust", "repo": "Cldfire/soundcloud-archive-site", "path": "/backend/src/database.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cldfire/soundcloud-archive-site path: /backend/src/database.rs .with_password(&rinfo.password) .with_secret_key(key) .hash() .unwrap(); // Needed to make types work out let empty_vec: Vec<i64> = vec![]; Ok(client.query_one( ...
code_fim
hard
{ "lang": "rust", "repo": "Cldfire/soundcloud-archive-site", "path": "/backend/src/database.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Set this user's liked_track_ids to the values produced by the given iterator. pub fn update_liked_track_ids<I: IntoIterator<Item = i64>>( &self, client: &mut Client, ids: I ) -> Result<(), Error> { Ok(client.execute( "UPDATE users SET liked_track...
code_fim
hard
{ "lang": "rust", "repo": "Cldfire/soundcloud-archive-site", "path": "/backend/src/database.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Canop/lapin path: /src/display/skin.rs use { crossterm::{ style::{ Attribute, Attributes, Color, }, }, termimad::{ ansi, CompoundStyle, gray, MadSkin, StyledChar, }, }; pub struct Skin { ...
code_fim
hard
{ "lang": "rust", "repo": "Canop/lapin", "path": "/src/display/skin.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// build a MadSkin which will be used to display the status /// when there's a error fn make_error_status_mad_skin() -> MadSkin { let mut mad_skin = MadSkin::default(); mad_skin.italic = CompoundStyle::new(Some(ansi(178)), None, Attributes::default()); mad_skin.bold = CompoundStyle::new(Some(...
code_fim
hard
{ "lang": "rust", "repo": "Canop/lapin", "path": "/src/display/skin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nakedtatsuya/rust-card-game path: /src/deck.rs use super::card::*; use super::{JokerCard, Mark}; #[derive(Debug, Clone)] pub struct Deck { cards: Vec<Card>, } impl Deck { pub fn new(joker: JokerCard) -> Self { let cards = Deck::deck_init(joker); Deck { cards } } ...
code_fim
hard
{ "lang": "rust", "repo": "nakedtatsuya/rust-card-game", "path": "/src/deck.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn make_deck() { let deck_not_in_joker_deck = Deck::new(JokerCard::Zero); let deck_in_joker_one_deck = Deck::new(JokerCard::One); let deck_in_joker_two_deck = Deck::new(JokerCard::Two); assert_eq!(deck_not_in_joker_deck.get_cards().len(), 52); asser...
code_fim
hard
{ "lang": "rust", "repo": "nakedtatsuya/rust-card-game", "path": "/src/deck.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn make_mark_set(mark: &'static Mark) -> Vec<Card> { let mut cards: Vec<Card> = vec![]; for i in 1..14 { let card = Card::new(i, mark); cards.push(card); } cards } } #[cfg(test)] mod tests { use super::Deck; use crate::card::*; u...
code_fim
hard
{ "lang": "rust", "repo": "nakedtatsuya/rust-card-game", "path": "/src/deck.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nyeogmi/moogle path: /src/shared_junctions/many_to_one/backward.rs use super::ManyToOne; use crate::id::IdLike; use crate::methods::{SharedAnyToMany, SharedAnySet}; use crate::methods::{ViewAnyToMany, AnyToMany}; use crate::methods::{ViewSet, AnySet}; use crate::raw_junctions::many_to_one::Ra...
code_fim
hard
{ "lang": "rust", "repo": "nyeogmi/moogle", "path": "/src/shared_junctions/many_to_one/backward.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.iter.next_back(|p| &p.bwd) } } struct BwdSetIterator<'a, A: IdLike, B: IdLike> { iter: ToManyKeyValueIterator<'a, RawManyToOne<A, B>, B, A>, } impl<'a, A: IdLike, B: IdLike> Iterator for BwdSetIterator<'a, A, B> { type Item = A; fn next(&mut self) -> Option<A> { sel...
code_fim
hard
{ "lang": "rust", "repo": "nyeogmi/moogle", "path": "/src/shared_junctions/many_to_one/backward.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let addr = config.bind.addr.parse()?; let (handle_tx, handle_rx) = oneshot::channel(); // Build a handle let handle = Some(Handle { close: handle_tx }); let server = async move { let incoming = udp::Server::bind(&addr).await?.build(); let mut close = handle_...
code_fim
hard
{ "lang": "rust", "repo": "larenelg/squiflog", "path": "/squiflog/src/server/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut close = handle_rx.fuse(); let mut ctrl_c = ctrl_c().boxed().fuse(); let mut incoming = incoming.fuse(); // NOTE: We don't use `?` here because we never want to carry results // We always want to match them and deal with error cases directly lo...
code_fim
hard
{ "lang": "rust", "repo": "larenelg/squiflog", "path": "/squiflog/src/server/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: larenelg/squiflog path: /squiflog/src/server/mod.rs use std::{marker::Unpin, str::FromStr}; use futures::{future::BoxFuture, select, FutureExt, StreamExt}; use tokio::{runtime::Runtime, signal::ctrl_c, sync::oneshot}; use bytes::Bytes; use crate::diagnostics::*; use crate::error::Er...
code_fim
hard
{ "lang": "rust", "repo": "larenelg/squiflog", "path": "/squiflog/src/server/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JohnTitor/diesel_full_text_search path: /src/lib.rs #[macro_use] extern crate diesel; mod types { #[allow(deprecated)] use diesel::sql_types::{HasSqlType, NotNull}; use diesel::pg::{Pg, PgTypeMetadata, PgMetadataLookup}; #[derive(Clone, Copy)] pub struct TsQuery; #[derive(C...
code_fim
hard
{ "lang": "rust", "repo": "JohnTitor/diesel_full_text_search", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn contains<T: AsExpression<TsQuery>>(self, other: T) -> Contains<Self, T::Expression> { Contains::new(self, other.as_expression()) } fn contained_by<T: AsExpression<TsQuery>>(self, other: T) -> ContainedBy<Self, T::Expression> { ContainedBy::new(self, othe...
code_fim
hard
{ "lang": "rust", "repo": "JohnTitor/diesel_full_text_search", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> App::build() .add_plugins(DefaultPlugins) .add_plugin(EguiPlugin) .add_plugin(AnimatorControllerPlugin) .add_plugin(AnimatorControllerEditorPlugin) .run(); }<|fim_prefix|>// repo: lassade/bevy_animagraph path: /editor/examples/main.rs use bevy::prelude::*; use ...
code_fim
easy
{ "lang": "rust", "repo": "lassade/bevy_animagraph", "path": "/editor/examples/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lassade/bevy_animagraph path: /editor/examples/main.rs use bevy::prelude::*; use bevy_animagraph::AnimatorControllerPlugin; use bevy_animagraph_editor::AnimatorControllerEditorPlugin; use bevy_egui::EguiPlugin; <|fim_suffix|> App::build() .add_plugins(DefaultPlugins) .add_plu...
code_fim
easy
{ "lang": "rust", "repo": "lassade/bevy_animagraph", "path": "/editor/examples/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// simplified blockchain objects, for faster python processing pub mod simple_proto;<|fim_prefix|>// repo: TrendingTechnology/BitcoinQueryPy path: /src/bitcoinparser/proto/mod.rs /// connect outpoints of inputs to previous outputs pub mod connected_proto; <|fim_middle|>/// add block hash, transaction i...
code_fim
medium
{ "lang": "rust", "repo": "TrendingTechnology/BitcoinQueryPy", "path": "/src/bitcoinparser/proto/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TrendingTechnology/BitcoinQueryPy path: /src/bitcoinparser/proto/mod.rs /// connect outpoints of inputs to previous outputs pub mod connected_proto; <|fim_suffix|>/// simplified blockchain objects, for faster python processing pub mod simple_proto;<|fim_middle|>/// add block hash, transaction i...
code_fim
medium
{ "lang": "rust", "repo": "TrendingTechnology/BitcoinQueryPy", "path": "/src/bitcoinparser/proto/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /src/sys/pkg/lib/pkgfs/src/lib.rs // Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. <|fim_suffix|>//! Typesafe wrappers around the /pkgfs filesystem. /// Re-...
code_fim
easy
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/sys/pkg/lib/pkgfs/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// Re-exports of wrapped types from io_util. pub use io_util::node::{Kind, OpenError}; pub mod control; pub mod install; pub mod needs; pub mod package; pub mod packages; pub mod system; pub mod versions;<|fim_prefix|>// repo: oshunter/fuchsia path: /src/sys/pkg/lib/pkgfs/src/lib.rs // Copyright 2019 T...
code_fim
medium
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/sys/pkg/lib/pkgfs/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>//! Typesafe wrappers around the /pkgfs filesystem. /// Re-exports of wrapped types from io_util. pub use io_util::node::{Kind, OpenError}; pub mod control; pub mod install; pub mod needs; pub mod package; pub mod packages; pub mod system; pub mod versions;<|fim_prefix|>// repo: oshunter/fuchsia path: ...
code_fim
easy
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/sys/pkg/lib/pkgfs/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn created(&self) -> Option<&DateTime<Utc>> { self.created.as_ref() } fn modified(&self) -> Option<&DateTime<Utc>> { self.modified.as_ref() } fn revoked(&self) -> bool { self.revoked } fn labels(&self) -> &BTreeSet<String> { &self.labels }...
code_fim
hard
{ "lang": "rust", "repo": "TedDriggs/cti", "path": "/stix/src/object.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.labels } fn object_marking_refs(&self) -> &BTreeSet<Id> { &self.object_marking_refs } fn confidence(&self) -> Option<Confidence> { self.confidence } } impl<T: AsRef<CommonProperties>> Object for T { fn id(&self) -> &Id { self.as_ref().id() ...
code_fim
hard
{ "lang": "rust", "repo": "TedDriggs/cti", "path": "/stix/src/object.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TedDriggs/cti path: /stix/src/object.rs use std::collections::BTreeSet; use chrono::{DateTime, Utc}; use serde::Deserialize; use crate::{reference::ExternalReference, Confidence, Id}; #[derive(Deserialize)] pub struct CommonProperties { id: Id, created_by_ref: Option<Id>, #[serde(...
code_fim
hard
{ "lang": "rust", "repo": "TedDriggs/cti", "path": "/stix/src/object.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<Error> for SendError { fn from(src: Error) -> SendError { match src { Error::Proto(reason) => SendError::Connection(reason), Error::Io(e) => SendError::Io(e), } } }<|fim_prefix|>// repo: nephele-rs/nephele path: /nephele/src/proto/h2/proto/error.r...
code_fim
hard
{ "lang": "rust", "repo": "nephele-rs/nephele", "path": "/nephele/src/proto/h2/proto/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match src { Error::Proto(reason) => RecvError::Connection(reason), Error::Io(e) => RecvError::Io(e), } } } impl From<Error> for SendError { fn from(src: Error) -> SendError { match src { Error::Proto(reason) => SendError::Connection(reas...
code_fim
medium
{ "lang": "rust", "repo": "nephele-rs/nephele", "path": "/nephele/src/proto/h2/proto/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nephele-rs/nephele path: /nephele/src/proto/h2/proto/error.rs use std::io; use crate::proto::h2::codec::{RecvError, SendError}; use crate::proto::h2::frame::Reason; #[derive(Debug)] pub enum Error { Proto(Reason), Io(io::Error), } impl Error { pub(super) fn shallow_clone(&self) ->...
code_fim
medium
{ "lang": "rust", "repo": "nephele-rs/nephele", "path": "/nephele/src/proto/h2/proto/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let row_near = row as f32 / 2.0; // If row_near's fractional is 0.0 we want row_far to be the previous row and if it's 0.5 we // want it to be the next row. let row_far = (row_near + row_near.fract() * 3.0 - 0.25).min((input_height - 1) as f32); let input_near = &i...
code_fim
hard
{ "lang": "rust", "repo": "Marwes/combine-jpeg", "path": "/src/upsampler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut t1 = 3 * u32::from(input_near[0]) + u32::from(input_far[0]); output[0] = ((t1 + 2) >> 2) as u8; for ((out, &near), &far) in output[1..] .chunks_exact_mut(2) .zip(&input_near[1..]) .zip(&input_far[1..]) { let t0 = t1; ...
code_fim
hard
{ "lang": "rust", "repo": "Marwes/combine-jpeg", "path": "/src/upsampler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Marwes/combine-jpeg path: /src/upsampler.rs use crate::{Component, ComponentVec, Dimensions, Error, Result, UnsupportedFeature}; use itertools::izip; pub(crate) struct Upsampler { components: ComponentVec<UpsamplerComponent>, } struct UpsamplerComponent { upsampler: Upsample, size...
code_fim
hard
{ "lang": "rust", "repo": "Marwes/combine-jpeg", "path": "/src/upsampler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Set authentication to certificate authority on the device pub fn authentication_using_certificate_authority(mut self) -> Self { self.authentication = Some(AuthenticationMechanism { authentication_type: AuthenticationType::Authority, x509_thumbprint: X509ThumbPri...
code_fim
hard
{ "lang": "rust", "repo": "kindlychung/azure-sdk-for-rust", "path": "/sdk/iothub/src/service/identity.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let https = HttpsConnector::new(); let client = Client::builder().build::<_, hyper::Body>(https); let mut request_builder = Request::builder() .uri(uri) .method(Method::PUT) .header("Authorization", &self.service_client.sas_token) .he...
code_fim
hard
{ "lang": "rust", "repo": "kindlychung/azure-sdk-for-rust", "path": "/sdk/iothub/src/service/identity.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kindlychung/azure-sdk-for-rust path: /sdk/iothub/src/service/identity.rs use azure_core::errors::{extract_status_headers_and_body, AzureError, UnexpectedHTTPResult}; use hyper::{Body, Client, Method, Request, StatusCode}; use hyper_tls::HttpsConnector; use serde::de::DeserializeOwned; use serd...
code_fim
hard
{ "lang": "rust", "repo": "kindlychung/azure-sdk-for-rust", "path": "/sdk/iothub/src/service/identity.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> math.force_set_function( "atan2", atan2, gc_context, DontDelete | ReadOnly | DontEnum, fn_proto, ); math.force_set_function( "pow", pow, gc_context, DontDelete | ReadOnly | DontEnum, fn_proto, ); math.force...
code_fim
hard
{ "lang": "rust", "repo": "acidburn0zzz/ruffle", "path": "/core/src/avm1/globals/math.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: acidburn0zzz/ruffle path: /core/src/avm1/globals/math.rs use crate::avm1::activation::Activation; use crate::avm1::error::Error; use crate::avm1::object::Object; use crate::avm1::property::Attribute::*; use crate::avm1::{ScriptObject, TObject, Value}; use gc_arena::MutationContext; use rand::Rng...
code_fim
hard
{ "lang": "rust", "repo": "acidburn0zzz/ruffle", "path": "/core/src/avm1/globals/math.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ngaut/grpc-rust path: /tests/http_server.rs extern crate solicit_fork as solicit; extern crate futures; extern crate tokio_core; extern crate grpc; use std::sync::mpsc; use std::net::ToSocketAddrs; use std::thread; use futures::Future; use futures::stream; use futures::stream::Stream; use toki...
code_fim
hard
{ "lang": "rust", "repo": "ngaut/grpc-rust", "path": "/tests/http_server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let http_server_future = HttpServerConnectionAsync::new(&lp.handle(), server_conn, F {}); lp.run(http_server_future).expect("server run"); }); let port = port_rx.recv().expect("recv port"); let (client_complete_tx, client_complete_rx) = mpsc::channel(); thread::spawn(mo...
code_fim
hard
{ "lang": "rust", "repo": "ngaut/grpc-rust", "path": "/tests/http_server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let is_edce = args.edce_path.is_some(); let search_cache = SearchCache::new(); let mut quit = false; 'route: while !quit { println!("wait:\tcalculating ..."); let universe_snapshot = universe.snapshot(); let mut search = SearchStation::new(player_state...
code_fim
hard
{ "lang": "rust", "repo": "austinjones/elitetrader", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn run_debug( universe: &mut Universe, state_in: &PlayerState, search_quality: SearchQuality, hops: usize, ) { let hop_width = search_quality.get_hop_width(); let depth = search_quality.get_depth(); let total_routes = hop_width.pow(depth as u32); println!( ...
code_fim
hard
{ "lang": "rust", "repo": "austinjones/elitetrader", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: austinjones/elitetrader path: /src/main.rs r station to a depth of {} hops ...", hop_width, depth ); println!("Total routes to examine: {}", total_routes); println!("{}", SEPARATOR); println!("\troute:\t\t\ttrade:"); println!( "option\tpft/min\tmins...
code_fim
hard
{ "lang": "rust", "repo": "austinjones/elitetrader", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // li second let li_second_dom = ol_dom.get_children().unwrap().get(1).unwrap().clone(); assert_eq!(DomType::Tag, li_second_dom.dom_type); let tag = li_second_dom.get_tag().unwrap(); assert_eq!("li".to_string(), tag.get_name()); assert_eq!("listItem".to_string(), tag.get_attr("clas...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/parsercher", "path": "/tests/parse_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/parsercher path: /tests/parse_test.rs extern crate parsercher; use parsercher::dom::DomType; #[test] fn parse() { let html = r#" <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>sample html</title> </head> <body> <h1>Hello, world!</h1> <div id="con...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/parsercher", "path": "/tests/parse_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TateKennington/rust-tracer path: /src/scene/camera.rs use crate::geometry::ray::Ray; use crate::geometry::vector3::Vector3; pub struct Camera { origin: Vector3, horizontal: Vector3, vertical: Vector3, forward: Vector3, side: Vector3, up: Vector3, lens_radius: f64, } ...
code_fim
hard
{ "lang": "rust", "repo": "TateKennington/rust-tracer", "path": "/src/scene/camera.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ray { origin: self.origin + offset, direction: u * self.horizontal + v * self.vertical + viewport_origin - self.origin - offset, } } }<|fim_prefix|>// repo: TateKennington/rust-tracer path: /src/scene/camera.rs use crate::geometr...
code_fim
hard
{ "lang": "rust", "repo": "TateKennington/rust-tracer", "path": "/src/scene/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// This is a helper function to convert a `std::error::Error` into a user failure. It's written in a // curried style so it can be used in a higher-order fashion, e.g., // `foo.map_err(failure::user("Error doing foo."))`. pub fn user<S: Into<String>, E: error::Error + 'static>(message: S) -> impl FnOnce(E...
code_fim
hard
{ "lang": "rust", "repo": "stepchowfun/toast", "path": "/src/failure.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { Self::System(_, source) => source.as_ref().map(|e| &**e), Self::User(_, source) => source.as_ref().map(|e| &**e), Self::Interrupted => None, } } } // This is a helper function to convert a `std::error::Error` into a system failure. It's...
code_fim
medium
{ "lang": "rust", "repo": "stepchowfun/toast", "path": "/src/failure.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stepchowfun/toast path: /src/failure.rs use std::{error, fmt}; // We distinguish between three kinds of failures: // 1. The user interrupted the program // 2. Some system operation (e.g., creating a container) failed // 3. There was a problem with the user's input (e.g., their task failed) #[de...
code_fim
hard
{ "lang": "rust", "repo": "stepchowfun/toast", "path": "/src/failure.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> - Port x configuration bits (y = 0..15)"] #[inline(always)] pub fn pupdr0(&self) -> PUPDR0_R { PUPDR0_R::new((self.bits & 0x03) as u8) } } impl W { #[doc = "Bits 6:7 - Port x configuration bits (y = 0..15)"] #[inline(always)] pub fn pupdr3(&mut self) -> PUPDR3_W { ...
code_fim
hard
{ "lang": "rust", "repo": "eupn/stm32wb-pac", "path": "/src/gpioh/pupdr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eupn/stm32wb-pac path: /src/gpioh/pupdr.rs #[doc = "Reader of register PUPDR"] pub type R = crate::R<u32, super::PUPDR>; #[doc = "Writer for register PUPDR"] pub type W = crate::W<u32, super::PUPDR>; #[doc = "Register PUPDR `reset()`'s with value 0"] impl crate::ResetValue for super::PUPDR { ...
code_fim
hard
{ "lang": "rust", "repo": "eupn/stm32wb-pac", "path": "/src/gpioh/pupdr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { let (destination_iter, destination_position) = destination.iter_position(); destination_iter .zip(mask_iter.zip(true_values_iter.zip(false_values_iter))) .for_each(|(dst, (m, (t, f)))| { let t = ...
code_fim
hard
{ "lang": "rust", "repo": "novacrazy/numeric-array", "path": "/src/simd.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: novacrazy/numeric-array path: /src/simd.rs //! Context-sensitive SIMD operations //! //! These aren't exactly numeric-specific, but they can make use of SIMD instructions. use super::*; use generic_array::{ArrayBuilder, ArrayConsumer}; /// Selects elements from one array or another using `sel...
code_fim
hard
{ "lang": "rust", "repo": "novacrazy/numeric-array", "path": "/src/simd.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spamwax/rusty-pin path: /src/pinboard/cached_data.rs #![allow(clippy::unicode_not_nfc)] #[allow(clippy::wildcard_imports)] use super::*; use env_logger; use std::fs; use std::io::Write; use std::io::{BufReader, BufWriter}; use crate::rmps; use serde::Serialize; use self::tag::Tag; use super::p...
code_fim
hard
{ "lang": "rust", "repo": "spamwax/rusty-pin", "path": "/src/pinboard/cached_data.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(self.pins.is_some()); // Fetch & write all tags // let f = File::create(&self.tags_cache_file)?; // Sort tags by frequency before writing api.tags_frequency() .map(|mut tags| { debug!(" sorting tags"); t...
code_fim
hard
{ "lang": "rust", "repo": "spamwax/rusty-pin", "path": "/src/pinboard/cached_data.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> debug!("read_cached_tags: starting"); let fp = File::open(&self.tags_cache_file)?; let reader = BufReader::with_capacity(FILE_BUF_SIZE, fp); self.tags = rmps::from_read(reader)?; Ok(()) } pub fn cache_ok(&self) -> bool { debug!("cache_ok: starting")...
code_fim
hard
{ "lang": "rust", "repo": "spamwax/rusty-pin", "path": "/src/pinboard/cached_data.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_ne!(a, b); }<|fim_prefix|>// repo: Box-of-Things/ockam path: /implementations/rust/crates/ockam/src/vault/test.rs use super::*; #[test] fn can_generate_random_number() { use rand::prelude::*; let mut vault = Vault::new().unwrap(); <|fim_middle|> let a: u32 = vault.gen(); let ...
code_fim
medium
{ "lang": "rust", "repo": "Box-of-Things/ockam", "path": "/implementations/rust/crates/ockam/src/vault/test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Box-of-Things/ockam path: /implementations/rust/crates/ockam/src/vault/test.rs use super::*; #[test] fn can_generate_random_number() { use rand::prelude::*; <|fim_suffix|> assert_ne!(a, b); }<|fim_middle|> let mut vault = Vault::new().unwrap(); let a: u32 = vault.gen(); let ...
code_fim
medium
{ "lang": "rust", "repo": "Box-of-Things/ockam", "path": "/implementations/rust/crates/ockam/src/vault/test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: embed-rs/stm32f7x6 path: /src/rcc/apb1lpenr/mod.rs s u32) << OFFSET); self.w.bits |= ((value & MASK) as u32) << OFFSET; self.w } } #[doc = "Values that can be written to the field `CECLPEN`"] pub type CECLPENW = TIM2LPENW; #[doc = r" Proxy"] pub struct _CECLPENW<'a> { w: ...
code_fim
hard
{ "lang": "rust", "repo": "embed-rs/stm32f7x6", "path": "/src/rcc/apb1lpenr/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const OFFSET: u8 = 16; self.w.bits &= !((MASK as u32) << OFFSET); self.w.bits |= ((value & MASK) as u32) << OFFSET; self.w } } #[doc = "Values that can be written to the field `CECLPEN`"] pub type CECLPENW = TIM2LPENW; #[doc = r" Proxy"] pub struct _CECLPENW<'a> { w: &'a ...
code_fim
hard
{ "lang": "rust", "repo": "embed-rs/stm32f7x6", "path": "/src/rcc/apb1lpenr/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: embed-rs/stm32f7x6 path: /src/rcc/apb1lpenr/mod.rs pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r" Clears the field bit"] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r" Writes raw bits to the field"] #[inline] pub ...
code_fim
hard
{ "lang": "rust", "repo": "embed-rs/stm32f7x6", "path": "/src/rcc/apb1lpenr/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: etaoins/arret path: /lsp-server/session.rs use std::collections::HashMap; use std::sync::Arc; use tokio::sync::mpsc; use crate::capabilities::server_capabilities; use crate::handler; use crate::json_rpc::{ClientMessage, ErrorCode, Response, ServerMessage}; use crate::model::{Document, Workspac...
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/lsp-server/session.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn expect_response(server_message: ServerMessage) -> Response { if let ServerMessage::Response(response) = server_message { response } else { panic!("Expected response, got {:?}", server_message); } } #[allow(deprecated)] #[tokio::test] ...
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/lsp-server/session.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abonander/gdk path: /src/widgets/window.rs pub fn get_fullscreen_mode(&self) -> ::FullscreenMode { unsafe { ffi::gdk_window_get_fullscreen_mode(self.pointer) } } #[cfg(feature = "gdk_3_8")] pub fn set_fullscreen_mode(&self, mode: ::FullscreenMode) { unsafe { ffi...
code_fim
hard
{ "lang": "rust", "repo": "abonander/gdk", "path": "/src/widgets/window.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_user_data<'a, T>(&'a self) -> &'a mut T { let mut pointer = ::std::ptr::null_mut(); unsafe { ffi::gdk_window_get_user_data(self.pointer, &mut pointer); ::std::mem::transmute(pointer) } } pub fn get_geometry(&self, x: &mut i32, y: &mu...
code_fim
hard
{ "lang": "rust", "repo": "abonander/gdk", "path": "/src/widgets/window.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_background_rgba(&self, rgba: &ffi::C_GdkRGBA) { unsafe { ffi::gdk_window_set_background_rgba(self.pointer, rgba) } } pub fn set_cursor(&self, cursor: &::Cursor) { unsafe { ffi::gdk_window_set_cursor(self.pointer, cursor.unwrap_pointer()) } } pub fn get_curs...
code_fim
hard
{ "lang": "rust", "repo": "abonander/gdk", "path": "/src/widgets/window.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: notdijon/hexavalent path: /src/pref.rs //! Global preferences. /// The value of a HexChat setting. /// /// Used with [`PluginHandle::get_pref`](crate::PluginHandle::get_pref). /// /// Note that this represents a global preference, not a plugin-specific preference. /// /// This trait is sealed a...
code_fim
hard
{ "lang": "rust", "repo": "notdijon/hexavalent", "path": "/src/pref.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl private::FromPrefValue for bool { fn from_pref_value(pref: private::PrefValue<'_>) -> Result<Self, ()> { match pref { private::PrefValue::Bool(x) => Ok(x), _ => Err(()), } } } macro_rules! pref { ($struct_name:ident, $pref_name:literal, $ty:ty) => ...
code_fim
hard
{ "lang": "rust", "repo": "notdijon/hexavalent", "path": "/src/pref.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MinaProtocol/mina path: /src/lib/crypto/kimchi_bindings/stubs/src/arkworks/bigint_256.rs use crate::caml::caml_bytes_string::CamlBytesString; use ark_ff::{BigInteger as ark_BigInteger, BigInteger256}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use num_bigint::BigUint; use std...
code_fim
hard
{ "lang": "rust", "repo": "MinaProtocol/mina", "path": "/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/bigint_256.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl TryFrom<&BigUint> for CamlBigInteger256 { type Error = String; fn try_from(x: &BigUint) -> Result<Self, Self::Error> { Ok(Self(BigInteger256::try_from(x.clone())?)) } } impl ToString for CamlBigInteger256 { fn to_string(&self) -> String { Into::<BigUint>::into(self)....
code_fim
hard
{ "lang": "rust", "repo": "MinaProtocol/mina", "path": "/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/bigint_256.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Self(BigInteger256::try_from(x.clone())?)) } } impl ToString for CamlBigInteger256 { fn to_string(&self) -> String { Into::<BigUint>::into(self).to_string() } } // // OCaml stuff // #[ocaml_gen::func] #[ocaml::func] pub fn caml_bigint_256_of_numeral( s: CamlBytesStrin...
code_fim
hard
{ "lang": "rust", "repo": "MinaProtocol/mina", "path": "/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/bigint_256.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: barabadzhi/rust-eos path: /chain/src/block_header.rs use crate::{ AccountName, bitutil, BlockTimestamp, Checksum256, Extension, NumBytes, ProducerSchedule, Read, Signature, Write, }; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; #[derive(De...
code_fim
hard
{ "lang": "rust", "repo": "barabadzhi/rust-eos", "path": "/chain/src/block_header.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl BlockHeader { pub fn new( timestamp: BlockTimestamp, producer: AccountName, confirmed: u16, previous: Checksum256, transaction_mroot: Checksum256, action_mroot: Checksum256, schedule_version: u32, new_producers: Option<ProducerSchedu...
code_fim
hard
{ "lang": "rust", "repo": "barabadzhi/rust-eos", "path": "/chain/src/block_header.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: placrosse/drogue-device path: /src/driver/sensor/hts221/register/who_am_i.rs use crate::hal::i2c::I2cAddress; use crate::prelude::Address; use embedded_hal::blocking::i2c::WriteRead; use crate::driver::i2c::I2cPeripheral; <|fim_suffix|>pub struct WhoAmI; impl WhoAmI { pub async fn read<I: ...
code_fim
medium
{ "lang": "rust", "repo": "placrosse/drogue-device", "path": "/src/driver/sensor/hts221/register/who_am_i.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl WhoAmI { pub async fn read<I: WriteRead>( address: I2cAddress, i2c: Address<I2cPeripheral<I>>, ) -> Result<I2cAddress, I::Error> { unsafe { // # Safety // The call to `.write_read` is properly awaited for completion before allowing the buffer to...
code_fim
medium
{ "lang": "rust", "repo": "placrosse/drogue-device", "path": "/src/driver/sensor/hts221/register/who_am_i.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut clients: ClientMap = HashMap::new(); let record_deposit = Record { r#type: Type::DEPOSIT, client: 1, tx: 1, amount: Some(10.0), status: None, }; let record_withdrawal = Record { r#type: Type::WI...
code_fim
hard
{ "lang": "rust", "repo": "jareddlc/invoice", "path": "/src/transction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jareddlc/invoice path: /src/transction.rs use crate::client::{Client, ClientMap}; use crate::csv_reader::{Record, RecordMap, Status, Type}; // process a single record pub fn process(record: &Record, clients: &ClientMap, records: &RecordMap) -> Client { // find client let client = Client...
code_fim
hard
{ "lang": "rust", "repo": "jareddlc/invoice", "path": "/src/transction.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_chargeback_withdrawal() { let mut clients: ClientMap = HashMap::new(); let record_deposit = Record { r#type: Type::DEPOSIT, client: 1, tx: 1, amount: Some(10.0), status: None, }; let record_...
code_fim
hard
{ "lang": "rust", "repo": "jareddlc/invoice", "path": "/src/transction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stefan-k/shepplogan-rs path: /examples/example.rs // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, o...
code_fim
hard
{ "lang": "rust", "repo": "stefan-k/shepplogan-rs", "path": "/examples/example.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Modified Shepp-Logan phantom let phantom = shepplogan::shepplogan_modified(nx, ny); let phantom: Vec<u8> = phantom.scale(255.0).into_vec_u8(); image::save_buffer( "shepp_logan_modified.png", &phantom, nx, ny, image::ColorType::L8, ) .unwr...
code_fim
hard
{ "lang": "rust", "repo": "stefan-k/shepplogan-rs", "path": "/examples/example.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let phantom: Vec<u8> = phantom.scale(255.0 / 2.0).into_vec_u8(); image::save_buffer("shepp_logan.png", &phantom, nx, ny, image::ColorType::L8).unwrap(); // Modified Shepp-Logan phantom let phantom = shepplogan::shepplogan_modified(nx, ny); let phantom: Vec<u8> = phantom.scale(255.0)....
code_fim
hard
{ "lang": "rust", "repo": "stefan-k/shepplogan-rs", "path": "/examples/example.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: codyd51/axle path: /rust_programs/libgui_derive/src/lib.rs extern crate proc_macro; use proc_macro::TokenStream; use quote::quote; use syn; #[proc_macro_derive(NestedLayerSlice)] pub fn nested_layer_slice_derive(input: TokenStream) -> TokenStream { let ast = syn::parse(input).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "codyd51/axle", "path": "/rust_programs/libgui_derive/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.view.frame() } fn content_frame(&self) -> Rect { Bordered::content_frame(self) } fn draw(&self) -> Vec<Rect> { Bordered::draw(self) } } }; gen.into() } #[proc_macro_derive(Bo...
code_fim
hard
{ "lang": "rust", "repo": "codyd51/axle", "path": "/rust_programs/libgui_derive/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rylev/rust path: /tests/ui/object-safety/assoc_type_bounds_sized.rs trait Foo { type Bar where Self: Sized; } fn foo(_: &dyn Foo) {} //~ ERROR<|fim_suffix|>m trait `Foo`) must be specified fn main() {}<|fim_middle|>: the value of the associated type `Bar` (fro
code_fim
easy
{ "lang": "rust", "repo": "rylev/rust", "path": "/tests/ui/object-safety/assoc_type_bounds_sized.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>m trait `Foo`) must be specified fn main() {}<|fim_prefix|>// repo: rylev/rust path: /tests/ui/object-safety/assoc_type_bounds_sized.rs trait Foo { type Bar where Se<|fim_middle|>lf: Sized; } fn foo(_: &dyn Foo) {} //~ ERROR: the value of the associated type `Bar` (fro
code_fim
medium
{ "lang": "rust", "repo": "rylev/rust", "path": "/tests/ui/object-safety/assoc_type_bounds_sized.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dentosal/rust_os path: /src/driver/acpi/tables/rsdt.rs //! This module is only used to retrieve XSDT address from RSDT. //! More info: http://wiki.osdev.org/RSDP const RSDP_SIGNATURE: &[u8; 8] = b"RSD PTR "; #[repr(C, packed)] pub struct RSDPDescriptor { signature: [u8; 8], checksum: u...
code_fim
hard
{ "lang": "rust", "repo": "Dentosal/rust_os", "path": "/src/driver/acpi/tables/rsdt.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub enum ParseResult { RSDT(u32), XSDT(u64), } /// Addtional info: http://wiki.osdev.org/RSDP#Validating_the_RSDP pub unsafe fn get_rsdp_and_parse() -> Result<ParseResult, RSDPParseError> { // TODO: Check hard-coded points before looping, at least: 0x000fa6a0 (bochs) // Scan EBDA // ...
code_fim
hard
{ "lang": "rust", "repo": "Dentosal/rust_os", "path": "/src/driver/acpi/tables/rsdt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robertdigital/fix-rust path: /fixclient/src/connector/session.rs use std::io; use std::borrow::Cow; // use std::rc::Rc; use std::sync::Arc; use std::sync::Mutex; use super::SessionState; use chrono::{Utc, DateTime}; use mio::{Token}; use mio_more::timer; use fix::fixmessagegen::*; use fix::fra...
code_fim
hard
{ "lang": "rust", "repo": "robertdigital/fix-rust", "path": "/fixclient/src/connector/session.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.is_operational() == false { warn!("on_timeout called but not operational: {}", self.state_machine); } if event_kind == EVKIND_HEARTBEAT && self.is_operational() { let threshold = (self.config.heart_beat as f32 * 0.75) as i64; if let Som...
code_fim
hard
{ "lang": "rust", "repo": "robertdigital/fix-rust", "path": "/fixclient/src/connector/session.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for it in data { *it = self.get(); } } } }<|fim_prefix|>// repo: moonmile/rust-sample path: /src/ch11/sample-11-03/src/lib.rs pub mod random { use rand::prelude::*; pub struct Dice { pub max: i32, } impl Dice { pub fn ge...
code_fim
medium
{ "lang": "rust", "repo": "moonmile/rust-sample", "path": "/src/ch11/sample-11-03/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: moonmile/rust-sample path: /src/ch11/sample-11-03/src/lib.rs pub mod random { use rand::prelude::*; pub struct Dice { pub max: i32, } <|fim_suffix|> rng.gen_range(1, self.max) } pub fn fill(&self, data: &mut Vec<i32>) { for it in data { ...
code_fim
medium
{ "lang": "rust", "repo": "moonmile/rust-sample", "path": "/src/ch11/sample-11-03/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }