blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
82867c757316096b28899a7aae663b274cb822b5 | Rust | redtankd/project-euler | /src/bin/00006.rs | UTF-8 | 155 | 3.09375 | 3 | [] | no_license | fn main() {
let number = 1..101;
let sum = number.fold((0, 0), |(x1, x2), y| (x1 + y * y, x2 + y));
println!("{}", sum.1 * sum.1 - sum.0);
}
| true |
5b468cc6b88b81b026845bb01ef35cddeba636c5 | Rust | gimli-rs/findshlibs | /src/unsupported.rs | UTF-8 | 1,846 | 2.703125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! The fallback implementation of the [SharedLibrary
//! trait](../trait.SharedLibrary.html) that does nothing.
use crate::Segment as SegmentTrait;
use crate::SharedLibrary as SharedLibraryTrait;
use crate::{Bias, IterationControl, SharedLibraryId, Svma};
use std::ffi::OsStr;
use std::marker::PhantomData;
use std::u... | true |
096aab66c9258fd95cde71f97b53391fa23b74b7 | Rust | seandewar/challenge-solutions | /leetcode/medium/deepest-leaves-sum.rs | UTF-8 | 998 | 3 | 3 | [] | no_license | // https://leetcode.com/problems/deepest-leaves-sum
//
// Complexity: runtime O(n), space O(n) [O(logn) if balanced].
use std::cell::RefCell;
use std::rc::Rc;
impl Solution {
pub fn deepest_leaves_sum(root: Option<Rc<RefCell<TreeNode>>>) -> i32 {
fn dfs(
node: Option<Rc<RefCell<TreeNode>>>,
... | true |
d9f192efa5c45089091870b0449653add2178c6a | Rust | Psychedelic/candid | /rust/candid/src/parser/token.rs | UTF-8 | 9,130 | 2.953125 | 3 | [
"Apache-2.0",
"LLVM-exception"
] | permissive | use lalrpop_util::ParseError;
use logos::{Lexer, Logos};
#[derive(Logos, Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
pub enum Token {
#[regex(r"[ \t\r\n]+", logos::skip)]
// line comment
#[regex("//[^\n]*", logos::skip)]
#[token("/*")]
StartComment,
#[error]
UnexpectedToken,
#[token(... | true |
849b315a0fcd69956707d77957f34b1d37b6d9f1 | Rust | defvar/toy | /pkg/toy-core/tests/value.rs | UTF-8 | 6,861 | 2.984375 | 3 | [
"MIT"
] | permissive | use chrono::{DateTime, Utc};
use toy_core::data::Value;
use toy_core::prelude::*;
#[test]
fn path() {
let v = map_value! {
"a" => 1,
"b" => 2,
"c" => map_value! {
"ca" => 31,
"cb" => 32,
},
"d" => seq_value![41,42,43]
};
assert_eq!(v.path("xx... | true |
e1d4098d7dab4f264a779b7a1511c48958f5e896 | Rust | bigkraig/opentelemetry-rust | /examples/async_fn.rs | UTF-8 | 2,728 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | //! Demonstrates using OpenTelemetry to instrument `async` functions.
//!
//! This is based on the [`hello_world`] example from `tokio`. and implements a
//! simple client that opens a TCP stream, writes "hello world\n", and closes
//! the connection.
//!
//! You can test this out by running:
//!
//! ncat -l 6142
/... | true |
72f38a3f4db73c8d3a1a27917f0c76312204e692 | Rust | Candunc/roosterteeth-rs | /src/lib.rs | UTF-8 | 1,389 | 3.453125 | 3 | [
"Apache-2.0"
] | permissive | /*!
RoosterTeeth-rs is a rust wrapper for the RoosterTeeth VOD api. All requests are done through the [requests](./requests/struct.Requests.html) object.
There are usually optional parameters to restrict to a certain channel or to change how it is sorted.
In the following example, we grab the first page of episodes, w... | true |
240c483e8af5620d9f5f4d2491b34e019947bceb | Rust | othelarian/candelabre | /candelabre-examples/src/luminance.rs | UTF-8 | 7,049 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | //! Example to show the usage of `CandlSurface` and `CandlManager` with
//! luminance as OpenGL backend. 'ESC' to close a window.
use candelabre_windowing::{
CandlCurrentWrapper, CandlDimension, CandlElement, CandlError,
CandlManager, CandlOptions, CandlWindow
};
use candelabre_windowing::glutin::event::{
... | true |
7e1c356839477d107cad8f36ca450bd30b8c15e9 | Rust | fplust/rlox | /src/ast_printer.rs | UTF-8 | 1,781 | 3.421875 | 3 | [] | no_license | use crate::expr::{
Expr, Visitor, Binary, Grouping, Literal, Unary
};
use crate::tokentype::Literals;
pub struct AstPrinter;
impl AstPrinter {
pub fn print(&self, expr: &Expr) -> String {
expr.accept(self)
}
}
impl Visitor<String> for AstPrinter {
fn visit_binary_expr(&self, expr: &Binary) -> ... | true |
22252cf4fa5247e6aeb1c92249770beebffead71 | Rust | oxidecomputer/third-party-api-clients | /slack/src/rtm.rs | UTF-8 | 1,809 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::Client;
use crate::ClientResult;
pub struct Rtm {
pub client: Client,
}
impl Rtm {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
Rtm { client }
}
/**
* This function performs a `GET` to the `/rtm.connect` endpoint.
*
* Starts a Real Time Messaging session.
... | true |
c9efdfedd0a43c96cdc292d9e77652efaab3a134 | Rust | slagroom/aoc-2019 | /05/rust/main.rs | UTF-8 | 6,514 | 3.21875 | 3 | [] | no_license | use std::collections::HashMap;
use std::error::Error;
use std::fmt;
use std::io;
use std::io::BufRead;
#[derive(Debug)]
struct MemoryAccessError {
address: usize,
}
impl MemoryAccessError {
fn new(address: &usize) -> MemoryAccessError {
return MemoryAccessError { address: *address };
}
}
impl fm... | true |
a128dae736f916dacaa2b6bda7d8f437bcac7cdd | Rust | flegac/advent-2020 | /src/day1.rs | UTF-8 | 3,002 | 3.171875 | 3 | [] | no_license | use std::cmp::{max, min, Ordering};
use itertools::{Itertools, sorted};
use crate::utils::read_lines;
type Int = u32;
type Int2 = u64;
struct Input<'a> {
filename: &'a str,
target: Int,
}
const BASIC: Input = Input {
filename: "src/day1.txt",
target: 2020,
};
const HARD1: Input = Input {
filen... | true |
b40a330eaf9ccafa1f908c7c89c477fa9db76568 | Rust | stackcats/leetcode | /algorithms/easy/maximum_product_of_two_elements_in_an_array.rs | UTF-8 | 360 | 2.765625 | 3 | [
"MIT"
] | permissive | impl Solution {
pub fn max_product(nums: Vec<i32>) -> i32 {
let mut h1 = -1;
let mut h2 = -2;
for i in 0..nums.len() {
if nums[i] >= h1 {
h2 = h1;
h1 = nums[i];
} else if nums[i] > h2 {
h2 = nums[i];
}
... | true |
be4f8b2a22252f61ccd8d8f3f28c929c0afd9a0b | Rust | xiyan128/codewar_archive | /6-kyu/a-rule-of-divisibility-by-13/rust/solution.rs | UTF-8 | 495 | 3.5 | 4 | [] | no_license | fn thirt(n: i64) -> i64{
let mut cache = n;
while cache != r_13(cache) {
cache = r_13(cache);
}
cache
}
fn digits(n: i64) -> Vec<i64> {
let (mut d, mut num) = (vec![], n.clone());
while num>0 {
d.push(num%10);
num /= 10;
}
d
}
fn r_13(n: i64) -> i64 {... | true |
6b9f81031cca010b3b902df6619eba6e9ea60225 | Rust | LucasPickering/gdlk | /crates/wasm/tests/test_wasm.rs | UTF-8 | 10,153 | 2.796875 | 3 | [
"MIT"
] | permissive | //! Integration tests for the GDLK Wasm API
#![deny(clippy::all)]
// Needed for the macro
#![allow(clippy::bool_assert_comparison)]
use gdlk_wasm::{
compile, HardwareSpec, LangValue, ProgramSpec, SourceElement, Span,
};
use maplit::hashmap;
use std::collections::HashMap;
use wasm_bindgen_test::wasm_bindgen_test;
... | true |
d26ad714ef6cc1b65960ee33c1dd6f9eb9a547d6 | Rust | dowlandaiello/notedly | /modules/web/server/src/api/wrapper.rs | UTF-8 | 6,167 | 3.078125 | 3 | [
"MIT"
] | permissive | use actix_web::{client::Client, error, Error};
use serde::{Deserialize, Serialize};
use std::{default::Default, io};
/// A wrapper for each of the respective oauth provider APIs (Google, GitHub).
pub struct User {
/// The access token associated with the user
access_token: String,
/// Cached results for t... | true |
929f6b1e6881e2bdcc8db9747019211f982bee3f | Rust | zhaoshenglong/Leetcode | /dynamic_programming_practice/740_medimum_delete_and_earn.rs | UTF-8 | 989 | 3.140625 | 3 | [] | no_license | use std::collections::HashMap;
struct Solution;
impl Solution {
pub fn delete_and_earn(nums: Vec<i32>) -> i32 {
let mut num_cnt = HashMap::new();
for &num in &nums {
*num_cnt.entry(num).or_insert(0) += 1;
}
let mut uni_nums = Vec::new();
for &k in num_cnt.keys(... | true |
fb13570c908226bec2e3e64668ec94104872f7df | Rust | dobrite/dood-rs | /src/pixset.rs | UTF-8 | 3,771 | 3.359375 | 3 | [] | no_license |
use std::collections::HashMap;
pub type TexCoords = [[f32; 2]; 4];
#[derive(Debug, Eq, PartialEq, Hash)]
pub enum Pix {
Dood,
Food,
UpArrow,
DownArrow,
RightArrow,
LeftArrow,
Wall,
Period,
Comma,
Quotes,
Apostrophe,
Colon,
SemiColon,
Empty,
}
pub struct Pixset... | true |
2240ef2622cb444df82383b68d9d82baf266d696 | Rust | sno2/unilang | /src/models/statement.rs | UTF-8 | 4,205 | 3.4375 | 3 | [
"MIT"
] | permissive | pub use crate::{Language, ToCode};
#[derive(Debug)]
pub struct VariableInit {
pub name: Box<dyn ToCode>,
pub mutable: Option<bool>,
pub typ: Option<Box<dyn ToCode>>,
pub value: Box<dyn ToCode>,
}
impl std::default::Default for VariableInit {
fn default() -> Self {
Self {
name: Box::new("foo"),
mutable: N... | true |
66144fd8aad274ea269ce9bedf1e19d076b1c919 | Rust | theshortcut/advent-of-code | /2021/src/day3.rs | UTF-8 | 2,800 | 3.140625 | 3 | [] | no_license | use aoc_runner_derive::{aoc, aoc_generator};
#[derive(Clone)]
struct BinaryList(Vec<u32>);
impl BinaryList {
fn new() -> Self {
BinaryList(vec![])
}
fn digit_at(&self, position: usize) -> u32 {
self.0[position]
}
fn push(&mut self, i: u32) {
self.0.push(i)
}
}
impl Into<u32> for BinaryList ... | true |
52717cd4a106cd65ace2e4baab180c5b23b2a57b | Rust | Azure/iot-identity-service | /mini-sntp/src/error.rs | UTF-8 | 3,437 | 2.625 | 3 | [
"MIT"
] | permissive | // Copyright (c) Microsoft. All rights reserved.
#[derive(Debug)]
pub enum Error {
BadServerResponse(BadServerResponseReason),
BindLocalSocket(std::io::Error),
ReceiveServerResponse(std::io::Error),
ResolveNtpPoolHostname(Option<std::io::Error>),
SendClientRequest(std::io::Error),
SetReadTimeou... | true |
b52d1ab45a441e181b4541da2348a883666b5212 | Rust | ryandbair/associatedtypes | /src/main.rs | UTF-8 | 1,219 | 3.3125 | 3 | [] | no_license | pub trait Request<'a> {
fn new(msg: &'a str) -> Self;
}
pub trait Response<'a> {
type Request: Request<'a>;
fn new(msg: &'a str, req: &'a Self::Request) -> Self;
}
pub trait Sink<'a> {
type Response: Response<'a>;
fn write(&self, &Self::Response);
}
struct ARequest<'a> {
msg: &'a str,
}
impl... | true |
a52d07e731d6f9c54e01982a5b3e835a4ee1ed75 | Rust | aero530/fpapp | /src-tauri/src/accounts/src/inputs/expense.rs | UTF-8 | 908 | 2.640625 | 3 | [] | no_license | //! User input expense values
use serde::{Deserialize, Serialize};
use ts_rs::TS;
// use super::fixed_with_inflation;
/// used to populate account dropdown for expense type selection
#[derive(TS, Debug, Copy, Clone, Deserialize, Serialize, PartialEq)]
#[ts(export)]
#[serde(rename_all = "snake_case")]
pub enum Expens... | true |
514a9391fa1dce19559bcab6d6495761e9cd94fb | Rust | thundergolfer/goodreads-sh | /src/models.rs | UTF-8 | 7,093 | 3.296875 | 3 | [
"MIT"
] | permissive | use regex::Regex;
use std::fmt::{self, Display, Formatter};
use roxmltree::Node;
const MAX_DESC_LEN: usize = 20;
pub struct Shelf {
pub books: Vec<Book>,
}
#[derive(Clone, Debug)]
pub struct Book {
pub id: u32,
pub description: String,
pub title: String,
// Sometimes num_pages is missing from XM... | true |
87a4195e8d19f79a858d43836dc1685396ec2879 | Rust | tlebrize/LearnRust | /chat/src/main.rs | UTF-8 | 2,981 | 2.84375 | 3 | [] | no_license | use std::collections::HashMap;
use std::sync::{Arc, Mutex, RwLock};
use tokio::{
io::{AsyncBufReadExt, AsyncWriteExt, BufReader},
net::TcpListener,
sync::broadcast,
};
#[tokio::main]
async fn main() {
// listen for new connections
let listener = TcpListener::bind("localhost:8000").await.unwrap();
... | true |
64aeb3129d718ba6a2dc47da98a2c098c2732bae | Rust | surma/osci | /src/memory/readonlymemory.rs | UTF-8 | 1,244 | 3.75 | 4 | [] | no_license | //! Make a memory read-only.
use memory::Memory;
/// Wraps another `Memory` and discards all writes.
pub struct ReadOnlyMemory(Box<Memory>);
impl ReadOnlyMemory {
pub fn new(m: Box<Memory>) -> ReadOnlyMemory {
ReadOnlyMemory(m)
}
}
impl Memory for ReadOnlyMemory {
fn get(&self, addr: usize) -> i3... | true |
61ec88568f8796640f5ce8152386579acc241a46 | Rust | arrayfire/arrayfire-rust | /examples/acoustic_wave.rs | UTF-8 | 2,369 | 2.671875 | 3 | [] | permissive | use arrayfire::*;
use std::f64::consts::*;
fn main() {
set_device(0);
info();
acoustic_wave_simulation();
}
fn normalise(a: &Array<f32>) -> Array<f32> {
(a / (max_all(&abs(a)).0 as f32 * 2.0f32)) + 0.5f32
}
fn acoustic_wave_simulation() {
// Speed of sound
let c: f32 = 0.1;
// Distance st... | true |
5f1bdd1e56ba02e3e614e7bd27b910af97586285 | Rust | ericlass/xtracer | /src/random.rs | UTF-8 | 3,390 | 3.40625 | 3 | [] | no_license | use linear::Vector4F;
use rand::Rng;
const PI: f64 = 3.1415926535897932384626433;
pub struct Random {
}
impl Random {
pub fn new() -> Random {
Random {}
}
//Crete random number in range 0...u32.MAX
pub fn random(&mut self) -> u32 {
rand::thread_rng().gen()
}
//Create random ... | true |
7eb9a00e132c47cf0c86c18d3206953b7bccb91b | Rust | CasperLabs/clarity | /packages/sdk/test/keys-manager/contract/src/lib.rs | UTF-8 | 3,143 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | use casper_contract::{
contract_api::{account},
unwrap_or_revert::UnwrapOrRevert
};
use casper_types::{
account::{
AccountHash, Weight, ActionType, AddKeyFailure, RemoveKeyFailure, SetThresholdFailure, UpdateKeyFailure
}
};
mod errors;
mod api;
use errors::Error;
use api::Api;
pub fn execute(... | true |
09d6f0d347f7f4d48df547044fb1c7004e90c7af | Rust | robohouse-delft/show-image-rs | /src/backend/util/gpu_image.rs | UTF-8 | 2,791 | 3.125 | 3 | [
"BSD-2-Clause"
] | permissive | use crate::ImageInfo;
use crate::ImageView;
use crate::{Alpha, PixelFormat};
use super::buffer::create_buffer_with_value;
/// A GPU image buffer ready to be used with the rendering pipeline.
pub struct GpuImage {
name: String,
info: ImageInfo,
bind_group: wgpu::BindGroup,
_uniforms: wgpu::Buffer,
_data: wgpu::Buf... | true |
77a290f9adae5af84a6d1d54f1d4d4befc8a18f7 | Rust | viing937/codeforces | /src/1327C.rs | UTF-8 | 1,241 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::io::{self, BufRead, BufReader, BufWriter, Write};
fn main() {
let mut stdin = BufReader::new(io::stdin());
let mut stdout = BufWriter::new(io::stdout());
let mut buffer = String::new();
stdin.read_line(&mut buffer).unwrap();
let buffer: Vec<i32> = buffer
.trim()
.split_asc... | true |
c084903b2062266d9baa76a91f5f7ae183aa0732 | Rust | seeseemelk/gpg-tui | /src/widget/table.rs | UTF-8 | 5,055 | 3.109375 | 3 | [
"MIT"
] | permissive | use crate::widget::row::{ScrollAmount, ScrollDirection};
use tui::widgets::TableState as TuiState;
/// Table size mode.
#[derive(Clone, Debug, PartialEq)]
pub enum TableSize {
/// Normal sized table.
Normal,
/// Compact table with some rows truncated.
Compact,
/// Minimized table with all rows truncated.
Minimiz... | true |
3a4d4c8bbf0344238f582e3427a839b03ddb2ea8 | Rust | brandonedens/stm32l4x6 | /src/adc1/sqr1.rs | UTF-8 | 6,547 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::SQR1 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce... | true |
9ba9e26fce503f8338726b0e3d8aff2c6ce411d5 | Rust | benjione/iot_webhook_server | /src/server.rs | UTF-8 | 3,253 | 3.25 | 3 | [
"MIT"
] | permissive | //! `ChatServer` is an actor. It maintains list of connection client session.
//! And manages available rooms. Peers send messages to other peers in same
//! room through `ChatServer`.
use actix::prelude::*;
use std::collections::HashMap;
use serde::Deserialize;
use diesel::r2d2;
use diesel::SqliteConnection;
use c... | true |
52f1d4149b5c887b842de926cec42e2f363cd4d1 | Rust | IvanPleshkov/RustExperiments | /render/src/gpu_texture.rs | UTF-8 | 4,113 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | use crate::command_buffer::CommandBuffer;
use crate::gpu_texture_format::GpuTextureFormat;
use std::sync::Arc;
pub struct GpuTexture {
pub id: GpuTextureIndex,
pub info: GpuTextureInfo,
}
pub struct GpuTextureIndex {
pub id: u64,
}
pub struct GpuTextureInfo {
pub name: String,
pub width: u64,
... | true |
13ff24b6fb1199431e077d273a982dabc79d5339 | Rust | PBertinJohannet/Siro | /src/equation.rs | UTF-8 | 19,069 | 3.140625 | 3 | [] | no_license | use lexer::EqLexer;
use parser::EqParser;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::mem;
use rand::random;
use std::iter::FromIterator;
use mccluskey::PrimeImplicant;
use mccluskey::mccluskey;
#[derive(Debug, Clone, PartialEq)]
pub enum Equation {
Sum(Box<Sum>),
Prod(Box<Prod>),
Not(... | true |
dda692deda14b883e254f799381656438d4be1fa | Rust | benzcash/zcash-android-wallet-sdk | /src/main/rust/utils.rs | UTF-8 | 1,198 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | use jni::{
descriptors::Desc,
errors::Result as JNIResult,
objects::{JClass, JObject, JString},
sys::{jobjectArray, jsize},
JNIEnv,
};
use std::ops::Deref;
pub(crate) mod exception;
pub(crate) fn java_string_to_rust(env: &JNIEnv<'_>, jstring: JString<'_>) -> String {
env.get_string(jstring)
... | true |
2000c5ca3d0d4d100d53ceecd1ffbc2a00d1dce4 | Rust | SolarLiner/gargantua | /gargantua/src/raytrace.rs | UTF-8 | 9,449 | 2.84375 | 3 | [] | no_license | use color::Color;
use image::{DynamicImage, Pixel, Rgb};
use nalgebra::{
Isometry3, Perspective3, Point2, Point3, Translation3, Unit, UnitQuaternion, Vector2, Vector3,
};
use std::f64;
use crate::texture::{Texture, TextureFiltering, TextureMode};
use crate::utils::cartesian_to_spherical;
pub type Point = Point3<f64>... | true |
0f913eea2a5e408077595fbfdcd708a8903463f8 | Rust | rust-chainblock/blockchain0 | /src/world.rs | UTF-8 | 688 | 3.015625 | 3 | [] | no_license | use crate::account::Account;
use crate::id::Id;
use crate::Error;
/// Snapshot of the world, not to have to rebuild it every time we query it.
pub trait WorldState {
/// Return an account that exists in the world, by its ID.
fn get_account_by_id(&self, id: &Id) -> Result<&Account, Error>;
/// Return a muta... | true |
89fd751ae0dff1e765db14d2f58d631fcd13d6e5 | Rust | ddimaria/rust-actix-starter | /src/handlers/health.rs | UTF-8 | 702 | 2.6875 | 3 | [
"MIT"
] | permissive | use crate::errors::ApiError;
use crate::helpers::respond_json;
use actix_web::web::Json;
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct HealthResponse {
pub status: String,
pub version: String,
}
/// Handler to get the liveness of the service
pub fn get_health() -> Result<Json<HealthResponse>,... | true |
0c34615e2157f7ac00fcc030799af90599ad5283 | Rust | shizonic/onefetch | /src/onefetch/cli_utils.rs | UTF-8 | 2,917 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::onefetch::{ascii_art::AsciiArt, error::*, info::Info, language::Language};
use colored::Color;
use std::env;
use std::io::Write;
use strum::IntoEnumIterator;
pub struct Printer<W> {
writer: W,
info: Info,
}
impl<W: Write> Printer<W> {
pub fn new(writer: W, info: Info) -> Self {
Self { w... | true |
8e311265441287552c651fe7c73a14bbb3c55705 | Rust | Defelo/AdventOfCode | /2022/01.rs | UTF-8 | 874 | 2.8125 | 3 | [
"MIT"
] | permissive | type Input = Vec<Vec<u32>>;
fn setup(input: &str) -> Input {
input
.trim()
.split("\n\n")
.map(|elf| elf.split_whitespace().map(|x| x.parse().unwrap()).collect())
.collect()
}
fn part1(input: &Input) -> u32 {
input.iter().map(|elf| elf.iter().sum()).max().unwrap()
}
fn part2(i... | true |
d2c40d0e1ed450d4743c4584965f730a7be2b7cb | Rust | vaind/objectbox-rust | /src/model.rs | UTF-8 | 6,292 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{c, error::Error};
use std::{ffi, ptr};
pub type SchemaID = u32;
pub type SchemaUID = u64;
/// Model is used to define a database model. Use as a fluent interface (builder pattern)
pub struct Model {
c_ptr: *mut c::OBX_model,
error: Option<Error>,
}
pub struct Entity {
model: Model,
}
impl Mo... | true |
9e9f567822a1f352ecd6da534f25e8df811ddb18 | Rust | jackmott/advent2019 | /day_13/src/main.rs | UTF-8 | 2,765 | 3.328125 | 3 | [
"MIT"
] | permissive | use intcomputer::*;
use std::collections::HashMap;
use std::fs;
use std::sync::mpsc::channel;
use std::sync::mpsc::SendError;
use std::thread;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
struct Pos {
x: i64,
y: i64,
}
use Tile::*;
#[derive(PartialEq, Copy, Debug, Clone)]
enum Tile {
Empty,
Wall... | true |
d32b5286b459f43e259001c880647a3eb790c7d9 | Rust | jeroenvervaeke/adventofcode-2019 | /day_02/src/main.rs | UTF-8 | 5,545 | 3.609375 | 4 | [] | no_license | use std::error::Error;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() -> Result<(), Box<dyn Error>> {
let file = File::open("day_02/input.txt")?;
let mut reader = BufReader::new(file);
let mut line = String::new();
reader.read_line(&mut line)?;
let intcode: Vec<u32> = line
... | true |
b2e426c99ebb5112acca24d605da4fbde2885c36 | Rust | ElementsProject/rust-elements | /src/dynafed.rs | UTF-8 | 28,993 | 2.5625 | 3 | [
"CC0-1.0"
] | permissive | // Rust Elements Library
// Written in 2019 by
// Andrew Poelstra <apoelstra@blockstream.com>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warrant... | true |
26ce2e58ebd616131c061cb279bba60256b0a61b | Rust | OrangeBacon/adventofcode2019 | /src/intcode/instruction.rs | UTF-8 | 6,372 | 3.1875 | 3 | [
"MIT"
] | permissive | use std::process::exit;
use std::fmt;
use std::collections::HashMap;
use indexmap::map::IndexMap;
#[derive(Copy, Clone, Debug)]
pub enum ParameterMode {
Position,
Literal,
Relative,
Any,
Address,
}
#[derive(Debug)]
pub struct Environment {
pub variables: IndexMap<String, i64>,
pub labels: ... | true |
c2a832bf9a13de5c532ae559f1c5e88bbe03829d | Rust | Sgt-Forge/Interview-Studying | /1. Sorting/rust/selection_sort.rs | UTF-8 | 487 | 3.5 | 4 | [] | no_license | pub fn selection_sort(array: &mut [i32]){
let len = array.len();
for sorted_ind in 0..len {
let mut smallest = sorted_ind;
for unsorted_ind in (sorted_ind + 1)..len {
if array[unsorted_ind] < array[smallest]{
smallest = unsorted_ind
}
}
arr... | true |
4cfd9ef81ece26e70c09dae4afc7d27452a2ffc4 | Rust | baitcenter/routing | /src/main.rs | UTF-8 | 1,195 | 2.59375 | 3 | [
"MIT"
] | permissive | #[macro_use] extern crate log;
// #[macro_use] extern crate serde_derive;
#[macro_use] extern crate serenity;
extern crate dotenv;
extern crate pretty_env_logger;
// extern crate serde;
// extern crate serde_json;
use serenity::{
framework::StandardFramework,
model::{
channel::*,
event::*,
gateway::Ready
},... | true |
44578c8480faa63502f3772cdf0884ca536feb35 | Rust | wfraser/parallel_reader | /src/lib.rs | UTF-8 | 7,961 | 3.359375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![deny(missing_docs, rust_2018_idioms)]
//! A utility for reading from a stream and processing it by chunks in parallel.
//!
//! See [`read_stream_and_process_chunks_in_parallel`]() for details.
use std::io::{self, Read};
use std::sync::{Arc, Mutex};
use std::sync::mpsc;
use std::thread;
/// An error during reading... | true |
8bb4a18e000cb9bafb55bc22be757a41bc43bf45 | Rust | boogerlad/rust-book2-exercises | /twelve_days_of_Christmas/src/main.rs | UTF-8 | 1,572 | 3.390625 | 3 | [] | no_license | fn main()
{
let days_gifts =
[
("first", "partridge in a pear tree"),
("second", "turtle doves"),
("third", "French hens"),
("fourth", "calling birds"),
("fifth", "golden rings"),
("sixth", "geese a-laying"),
("seventh", "swans a-swimming"),
("eighth", "maids a-milking"),
("ninth", "ladies dancing")... | true |
81748e0a3336b9568a40912fdd09c41cf632a810 | Rust | mcclellanmj/top-down | /src/main.rs | UTF-8 | 7,362 | 2.6875 | 3 | [] | no_license | // TODO: Make an input module that will allow code based input configuration
// FIXME: Figure out how to find the shortest path for rotation, currently in some quadrants it rotates the long
// way around
// TODO: Clean up the update code, at the minimum it needs to be seperate functions possibly separate mods
// TODO: ... | true |
8faa93e585ffd15eeffb7da7c7a29ae6e745d4a0 | Rust | rjsberry/nano | /nano-oneshot/tests/tests.rs | UTF-8 | 3,647 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::sync::{Arc, Barrier};
use std::thread;
use std::time::Duration;
use nano_oneshot::{self, RecvError, RecvTimeoutError, SendError};
#[test]
fn oneshot() {
let (s, r) = nano_oneshot::channel();
s.send(128).expect("send");
assert_eq!(r.recv().expect("recv"), 128);
}
#[test]
fn oneshot_send_drop_rece... | true |
5472d5aeb6cb716518f4311c0750b2a8c9bef1ae | Rust | Cassin01/rubyst | /src/is/mod.rs | UTF-8 | 2,903 | 3.15625 | 3 | [
"MIT"
] | permissive | use std::iter::Peekable;
use std::str::Chars;
pub fn is_this(cs: &mut Peekable<Chars>, f: &Fn(&char)->bool) -> bool {
match cs.peek() {
Some(c) => f(&c),
None => false,
}
}
pub fn is_num(c: &char) -> bool {
match c {
'0' ... '9' => true,
_ => false
}
}
pub fn... | true |
7614c7adf3a9d0c3a59c2a9333fc4bc40e0519d2 | Rust | delneg/bitcoin-address-generator-api | /src/accounts/jobs/odd_registration_attempt.rs | UTF-8 | 1,900 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::env::var;
use std::pin::Pin;
use std::future::Future;
use jelly::serde::{Deserialize, Serialize};
use jelly::anyhow::{anyhow, Error};
use jelly::email::Email;
use jelly::jobs::{DEFAULT_QUEUE, Job, JobState};
use crate::accounts::Account;
/// An email that gets sent if a user a... | true |
5553fd8415812b8ef862f9418c85e0e03dbed4e0 | Rust | dalarson/2fa_attack | /otpgen/src/server.rs | UTF-8 | 1,982 | 2.5625 | 3 | [] | no_license | #![feature(proc_macro_hygiene)]
#![feature(decl_macro)]
#[macro_use]
extern crate rocket;
extern crate rocket_contrib;
use otpgen::AuthRequest;
use rocket::State;
use otpgen::otp_now;
use rocket_contrib::json::Json;
use std::sync::Mutex;
use crypto::aessafe::AesSafe256Decryptor;
use crypto::symmetriccipher::BlockDec... | true |
9baeb7e548294f04126148fd371c952d1f0be1fb | Rust | galacticfungus/Egg | /egg/src/error/underlying.rs | UTF-8 | 1,781 | 3.109375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fmt;
use std::io;
use std::string;
#[derive(Debug)]
pub enum UnderlyingError {
Io(io::Error),
InvalidString(string::FromUtf8Error),
FailedConversion(std::num::TryFromIntError),
// TODO: Path fail may need to be more generic than this
PathFail(std::path::StripPrefixError),
}
impl Underlyin... | true |
1fce706821158bbf316ae4a0680a17dba06141b4 | Rust | orgarten/ndarray-linalg | /lax/src/tridiagonal.rs | UTF-8 | 8,313 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Implement linear solver using LU decomposition
//! for tridiagonal matrix
use crate::{error::*, layout::*, *};
use cauchy::*;
use num_traits::Zero;
use std::ops::{Index, IndexMut};
/// Represents a tridiagonal matrix as 3 one-dimensional vectors.
///
/// ```text
/// [d0, u1, 0, ..., 0,
/// l1, d1, u2, ... | true |
a69f7632f7a58ae33f28f2e43b0514dce610b8da | Rust | geom3trik/tuix_baseview | /examples/gain_widget.rs | UTF-8 | 993 | 2.515625 | 3 | [] | no_license |
use tuix_baseview::Application;
use tuix::{Entity, Event, State, BuildHandler, EventHandler};
use tuix::style::{Length, Color};
use tuix::widgets::value_knob::*;
use tuix::widgets::control_knob::*;
static THEME: &str = include_str!("theme.css");
struct GainWidget {
control: Entity,
}
impl GainWidget {
... | true |
37123aad056a947d741711fa8d5e136fbe688bea | Rust | luxrck/raytrace | /src/main.rs | UTF-8 | 9,911 | 2.890625 | 3 | [
"MIT"
] | permissive | #![feature(box_syntax)]
use std::env;
use std::f64;
use image::RgbImage;
use nalgebra::Vector3;
use rand::prelude::*;
use rayon::prelude::*;
#[derive(Copy, Clone, Debug)]
struct Ray {
origin: Vector3<f64>,
direction: Vector3<f64>,
color: Vector3<f64>,
}
impl Ray {
fn new(o: Vector3<f64>, d: Vector3<... | true |
b154feeda5f57a53490fe1205f4e3f43aaa4cce2 | Rust | JosefBertolini/RustTicTacToe | /src/gameboard.rs | UTF-8 | 1,922 | 3.1875 | 3 | [] | no_license | use crate::space::{Space};
pub struct Gameboard {
pub board: [[Space; 3]; 3],
}
impl Gameboard {
pub fn new() -> [[Space; 3]; 3] {
[[Space::EMPTY; 3]; 3]
}
pub fn place(&mut self, player_move: Space, row: i32, col: i32) -> bool {
if self.board[row as usize][col as usize] == Space::EM... | true |
a08490e059ba798c0b3f226ff8beb11dfbdb5502 | Rust | technetos/catalyst | /src/response.rs | UTF-8 | 814 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | use crate::error::Error;
use bytes::Bytes;
pub struct Response {
res: http::response::Builder,
data: Bytes,
}
impl Response {
pub(crate) fn into_inner(mut self) -> Result<(http::Response<()>, Bytes), Error> {
let response = self.res.body(())?;
Ok((response, self.data))
}
pub fn ne... | true |
096d1ea1baafe759ec96babe4119ed22ccfcbeca | Rust | afonsolage/craft-world | /src/states/world.rs | UTF-8 | 1,568 | 2.65625 | 3 | [] | no_license | use crate::{
components::Player,
resources::{MainPlayer, PlayerSpriteAsset, TerrainSpriteAsset, TerrainData},
};
use amethyst::{
core::{math::Vector3, Transform},
prelude::*,
renderer::{camera::Projection, Camera},
SimpleState,
};
pub struct WorldState;
impl SimpleState for WorldState {
fn... | true |
00b88fb560408485b07c023696c81e806153ae78 | Rust | yytian/bignum | /src/types.rs | UTF-8 | 8,354 | 3.375 | 3 | [
"MIT"
] | permissive | use std::cmp;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum Sign {
Nonnegative = 1,
Negative = -1,
}
use self::Sign::*;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Bignum {
pub parts: Vec<u32>, // Least significant digit at leftmost index
pub sign: Sign,
}
#[derive(Debug)]
p... | true |
5094ddb662408de1e2dfb2723275f333b09cf9fc | Rust | ArtemAstakhov/yew-ui | /src/components/table/table_row/table_row.rs | UTF-8 | 2,617 | 2.84375 | 3 | [
"MIT"
] | permissive | use css_in_rust::Style;
use yew::{
html, Component, ShouldRender, Html, ComponentLink, Properties, Classes, NodeRef,
html::{
ChildrenRenderer,
},
virtual_dom::{
VComp, VChild,
}
};
use crate::components::table::TableSize;
use crate::components::table::table_cell::table_cell::{
TableCell,
Props as ... | true |
d7c08c83ca608ef267c786cb2c186f2d0770363d | Rust | yamash723/pixelast | /src/response.rs | UTF-8 | 1,250 | 2.84375 | 3 | [
"MIT"
] | permissive | use super::PixelaClientError;
use serde_json;
use failure::Error;
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ApiRequestResult {
pub message: String,
pub is_success: bool,
}
pub fn build_result(json: &str) -> Result<(), Error> {
let res: ApiRequestResult = serde... | true |
3113cb3afd5870b5f890589942447d7c5d30046a | Rust | stry-rs/attrouter | /src/parser.rs | UTF-8 | 8,713 | 2.78125 | 3 | [] | no_license | use {
crate::models::{FnParam, FnParamKind, GuardParam, Route, Triplet, UrlParam, UrlParams},
proc_macro2::TokenStream,
syn::{
punctuated::Punctuated, Attribute, FnArg, Generics, Ident, ItemFn, LitStr, Pat, PatIdent,
PatType, Signature, Type, TypePath,
},
};
pub fn parse<'i>(
path: ... | true |
adb653dcd05b70a496ac46c9e35f7531e8407849 | Rust | h-michael/save_analysis_example | /src/hir.rs | UTF-8 | 374 | 2.609375 | 3 | [] | no_license | #[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
fn main() {
<Person>::new("not_bind", 18);
let kiske = <Person>::new("kiske", 18);
}
struct Person {
pub name: String,
pub age: u32,
}
impl Person {
fn new(name: &str, age: u32) -> Person {
Person {
name:... | true |
1d16634a5567464d66c660f54212fcc5d1d55492 | Rust | jlgerber/pbgui | /pbgui/src/messaging/incoming/imain_toolbar.rs | UTF-8 | 513 | 2.59375 | 3 | [] | no_license | use super::*;
/// Responses returning to the main ui thread from the secondary thread
/// for the main toolbar element.
pub enum IMainToolbar {
/// Provides a vector of show names
Shows(Vec<String>),
/// Provides a vector of role names
Roles(Vec<String>),
/// Provides a vector of platform names
... | true |
9700e64d50b5b6698ac9fd2134e984634ef50f83 | Rust | cc14514/rust-exercise | /src/sortdemo/insert.rs | UTF-8 | 442 | 2.890625 | 3 | [] | no_license | pub fn sort(arr: Vec<u32>) -> Vec<u32> {
let mut i = 0;
let mut ret = Vec::new();
while i < arr.len() {
let mut j = 0;
let vi = arr.get(i).unwrap();
while j < ret.len() {
if let Some(vj) = ret.get(j) {
if vi < vj {
break;
... | true |
6f9f1ee73086a114d579086088aa2fdd898fc94f | Rust | Chopinsky/Rusty_Express | /examples/simple.rs | UTF-8 | 771 | 2.953125 | 3 | [
"MIT"
] | permissive | extern crate rusty_express;
use rusty_express::prelude::*;
fn main() {
// define http server now
let mut server = HttpServer::new();
//define router directly
server.get(RequestPath::WildCard(r"/\w*"), simple_response);
server.listen(8080);
}
pub fn simple_response(req: &Box<Request>, resp: &mut... | true |
1b9306928b477f19be67270cca9c664393022ece | Rust | rust-lang/rust-analyzer | /crates/base-db/src/input.rs | UTF-8 | 28,853 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! This module specifies the input to rust-analyzer. In some sense, this is
//! **the** most important module, because all other fancy stuff is strictly
//! derived from this input.
//!
//! Note that neither this module, nor any other part of the analyzer's core do
//! actual IO. See `vfs` and `project_model` in the `... | true |
2e4b6a205a8f00665d9183ca84050395bec82e5d | Rust | Connicpu/AoC2019 | /src/parse.rs | UTF-8 | 1,669 | 3.359375 | 3 | [] | no_license | use num::PrimInt;
pub fn parse<T: PrimInt>(data: &[u8]) -> ParseIter<T> {
ParseIter {
state: State::new(),
data: data.iter(),
}
}
pub fn parse_i64_vec(data: &str) -> Vec<i64> {
parse(data.as_bytes()).collect()
}
pub struct ParseIter<'a, T: PrimInt> {
state: State<T>,
data: std::sl... | true |
5af55fe882dfdf4b6d95c7480a744245e62fce11 | Rust | KFtygy4AquzoI/OpenZKP | /algebra/primefield/src/prime_field.rs | UTF-8 | 19,357 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | // False positive: attribute has a use
#[allow(clippy::useless_attribute)]
// False positive: Importing preludes is allowed
#[allow(clippy::wildcard_imports)]
use std::{fmt, prelude::v1::*};
use crate::{Root, SquareRoot, UInt as FieldUInt};
use std::{
hash::{Hash, Hasher},
marker::PhantomData,
ops::Shr,
};... | true |
1d7029de0e2652b239448cc96894047a18898bff | Rust | irandms/riscv-phone | /firmware/src/eeprom.rs | UTF-8 | 4,189 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #![allow(dead_code)]
extern crate embedded_hal as hal;
use hal::blocking::spi;
use hal::digital::OutputPin;
use hal::spi::Mode;
use hal::spi::MODE_0;
#[derive(Debug, Clone, Copy)]
pub enum Error<E> {
// A write is currently happening, and subsequent writes will fail
WriteInProgress,
// The BP bits in the... | true |
bf47ddf398fe5440649465d89d883a6eb077fdfb | Rust | aelred/nes-rust | /src/lib.rs | UTF-8 | 4,721 | 2.734375 | 3 | [] | no_license | use std::fmt::{Debug, Formatter};
pub use crate::address::Address;
pub use crate::cartridge::Cartridge;
use crate::cartridge::CHR;
use crate::cartridge::PRG;
pub use crate::cpu::CPU;
pub use crate::cpu::Instruction;
pub use crate::cpu::instructions;
use crate::cpu::NESCPUMemory;
pub use crate::i_nes::INes;
pub use cra... | true |
8d89b324152c91a212dbbfdf21e96e70588dfb04 | Rust | IThawk/rust-project | /rust-master/src/librustc_mir/transform/dump_mir.rs | UTF-8 | 1,581 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | //! This pass just dumps MIR at a specified point.
use std::borrow::Cow;
use std::fmt;
use std::fs::File;
use std::io;
use rustc::mir::Body;
use rustc::session::config::{OutputFilenames, OutputType};
use rustc::ty::TyCtxt;
use crate::transform::{MirPass, MirSource};
use crate::util as mir_util;
pub struct Marker(pub... | true |
ddfc697329eb496c1a8fed5e01e4ae039a720ccd | Rust | gs-akhan/learning-rust | /src/highscore.rs | UTF-8 | 986 | 3.03125 | 3 | [
"MIT"
] | permissive | #[derive(Debug)]
pub struct HighScores {
all_scores: Vec<u32>,
}
impl HighScores {
pub fn new(scores: &[u32]) -> Self {
Self {
all_scores: scores.to_vec(),
}
}
pub fn scores(&self) -> &[u32] {
&self.all_scores
}
pub fn latest(&self) -> Option<u32> {
... | true |
dc7cd71b6ea96d3413471a4da5f4eaf91ae35935 | Rust | ajunlonglive/compiler-1 | /src/runtimelib.rs | UTF-8 | 484 | 2.796875 | 3 | [
"MIT"
] | permissive | pub fn runtime_function(name: &str) -> Option<usize> {
Some(match name {
"print" => print as usize,
_ => return None,
})
}
unsafe extern "win64" fn print(buffer: *const u8) {
let mut size = 0;
loop {
if *buffer.add(size) == 0 {
break;
}
size +... | true |
db7899732d3ab9979e5dd3c2e8c971f6d114b79a | Rust | leo60228/upd8r | /src/hs2.rs | UTF-8 | 4,102 | 2.84375 | 3 | [] | no_license | use super::*;
use anyhow::{anyhow, bail, Context, Result};
use chrono::naive::NaiveDate;
use rss::{Channel, Item};
use scraper::{Html, Selector};
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use url::Url;
impl IntoUpdate for Item {
fn into_update(&self, media: &Media) -> Result<Upd... | true |
cf77991ed23b989d40029d331db38122b59a8d3a | Rust | mateusfg7/rust-lang-study | /rust-programmin-tutorial/42/parsing-json/src/main.rs | UTF-8 | 1,169 | 3.84375 | 4 | [] | no_license | // FIRST METHOD
// extern crate serde_json;
// use serde_json::Value as JsonValue;
// fn main() {
// let json_srt = r#"
// {
// "name": "Domenic",
// "age": 65,
// "is_male": true
// }
// "#;
// let res = serde_json::from_str(json_srt);
// if res.i... | true |
20840521fea9d5ddabb37601fc5cc327ab036f06 | Rust | ralphtheninja/eyros | /src/staging.rs | UTF-8 | 3,341 | 2.859375 | 3 | [] | no_license | use ::{Row,Point,Value};
use failure::{Error,bail,format_err};
use random_access_storage::RandomAccess;
use std::mem::size_of;
use bincode::{serialize,deserialize};
use write_cache::WriteCache;
pub struct StagingIterator<'a,'b,P,V> where P: Point, V: Value {
rows: &'a Vec<Row<P,V>>,
bbox: &'b P::Bounds,
index: u... | true |
f63e98caf367b066ca5c69ccf5bc49629e8de753 | Rust | SabrinaJewson/statrs.rs | /src/statistics/slice_statistics.rs | UTF-8 | 16,165 | 3 | 3 | [
"MIT"
] | permissive | use crate::statistics::*;
use core::ops::{Index, IndexMut};
use rand::prelude::SliceRandom;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Data<D>(D);
impl<D: AsRef<[f64]>> Index<usize> for Data<D> {
type Output = f64;
fn index(&self, i: usize) -> &f64 {
&self.0.as_ref()[i]
}
}
impl<D: AsMut<[... | true |
2a5a012586b568e26842c5a3cc6fe2ebae1ccaa2 | Rust | imorph/vector | /src/config/component.rs | UTF-8 | 1,976 | 2.921875 | 3 | [
"MPL-2.0"
] | permissive | use snafu::Snafu;
use std::marker::PhantomData;
use toml::Value;
use super::GenerateConfig;
#[derive(Debug, Snafu, Clone, PartialEq)]
pub enum ExampleError {
#[snafu(display("unable to create an example for this component"))]
MissingExample,
#[snafu(display("type '{}' does not exist", type_str))]
Does... | true |
d1ba78c0623af3a7a144132ff180e049411dafb1 | Rust | ia7ck/competitive-programming | /AtCoder/abc280/src/bin/f/main.rs | UTF-8 | 1,543 | 2.765625 | 3 | [] | no_license | use std::collections::{HashSet, VecDeque};
use proconio::{input, marker::Usize1};
use union_find::UnionFind;
fn main() {
input! {
n: usize,
m: usize,
q: usize,
edges: [(Usize1, Usize1, i64); m],
};
let mut uf = UnionFind::new(n);
for &(a, b, _) in &edges {
uf.u... | true |
d8e5ca2c106a5ba56953f8279245e89e88eb10b9 | Rust | prove-rs/z3.rs | /z3/src/params.rs | UTF-8 | 3,452 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::ffi::{CStr, CString};
use std::fmt;
use z3_sys::*;
use Context;
use Params;
use Symbol;
impl<'ctx> Params<'ctx> {
unsafe fn wrap(ctx: &'ctx Context, z3_params: Z3_params) -> Params<'ctx> {
Z3_params_inc_ref(ctx.z3_ctx, z3_params);
Params { ctx, z3_params }
}
pub fn new(ctx: &'ctx ... | true |
a122c069f238cc6a898517ccf33f6b9d87919a5e | Rust | davidsteiner/seq-rs | /src/error.rs | UTF-8 | 678 | 3 | 3 | [
"MIT"
] | permissive | use crate::parser::Rule;
use pest::error::Error as PestError;
#[derive(Debug)]
pub enum Error {
PestError(PestError<Rule>),
ModelError { message: String },
}
impl From<PestError<Rule>> for Error {
fn from(err: PestError<Rule>) -> Self {
Error::PestError(err)
}
}
impl std::fmt::Display for Err... | true |
3af97e4710874139b17cf9a3f47db1006381489a | Rust | clap-rs/clap | /tests/derive/options.rs | UTF-8 | 13,250 | 2.578125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>,
// Kevin Knapp (@kbknapp) <kbknapp@gmail.com>, and
// Ana Hobden (@hoverbear) <operator@hoverbear.org>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-... | true |
77281197d6114fb404094ae719bf1784401af755 | Rust | Champii/rsrpc | /src/timer.rs | UTF-8 | 430 | 2.703125 | 3 | [
"MIT"
] | permissive | use super::oneshot::{channel, Receiver};
use std::fmt::Debug;
use std::thread;
use std::time::Duration;
pub struct Timer {}
impl Timer {
pub fn new<T: 'static + Send + Sync + Debug>(wait_time: Duration, err: T) -> Receiver<T> {
let (tx, rx) = channel::<T>();
thread::spawn(move || {
thread::sleep(wait... | true |
ca482724274310404d20f9d500cd0bd018ff8aed | Rust | bottlerocket-os/bottlerocket | /sources/bloodhound/src/results.rs | UTF-8 | 5,535 | 3.140625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, fmt, usize};
#[derive(Debug, Serialize, Deserialize)]
pub struct ReportMetadata {
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
... | true |
3c2a06652966dfa14d31f9feab39fe073c39d212 | Rust | phip1611/libbruteforce | /src/parameter/target_hash.rs | UTF-8 | 5,698 | 3.234375 | 3 | [
"MIT"
] | permissive | /*
MIT License
Copyright (c) 2022 Philipp Schuster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publis... | true |
d2011a940e9bd9125bc7a20c24f734d085585e08 | Rust | wormtql/rusty-parser | /src/bin/fa.rs | UTF-8 | 1,609 | 2.734375 | 3 | [] | no_license | use grammar::automaton::dfa::DFA;
use grammar::automaton::nfa::NFA;
use clap::{Arg, App};
fn main() {
let matches = App::new("Exam Cheater: Automaton")
.version("0.1.0")
.author("wormtql <584130248@qq.com>")
.arg(Arg::with_name("file")
.short("f")
.long("fil... | true |
b274e4cfafb9af528ebb1d34db0586629b9b804a | Rust | Techno-coder/example_os | /kernel/src/task/schedulers/round_robin.rs | UTF-8 | 548 | 3.46875 | 3 | [
"MIT"
] | permissive | use alloc::VecDeque;
use super::Thread;
// The simplest scheduler possible
// The next thread is the thread pushed on earliest
// New threads are pushed to the back of the queue
pub struct RoundRobin {
threads: VecDeque<Thread>,
}
impl RoundRobin {
pub fn new() -> RoundRobin {
RoundRobin {
threads: VecDeque::... | true |
43ee448ba14fc8f34b3962830fb8de68b8f7f093 | Rust | bwestlin/advent-of-code-2016-retro | /rust/src/day03.rs | UTF-8 | 1,806 | 3.28125 | 3 | [
"MIT"
] | permissive | extern crate utils;
use std::env;
use std::num::ParseIntError;
use std::io::{self, BufReader};
use std::io::prelude::*;
use std::fs::File;
use utils::*;
type Input = Vec<TSides>;
type TSides = [u32; 3];
fn valid_triangle(s1: u32, s2: u32, s3: u32) -> bool {
(s1 + s2 > s3) && (s1 + s3 > s2) && (s2 + s3 > s1)
}
f... | true |
74a9d6a2f8da7186aa9d03a1c8a15fd81016f3db | Rust | pyigyli/JRPG-engine | /src/battle/enemy.rs | UTF-8 | 8,231 | 2.65625 | 3 | [] | no_license | use ggez::graphics::{spritebatch, Image, DrawParam, draw, Color};
use ggez::nalgebra::Point2;
use ggez::{Context, GameResult};
use ggez::timer::ticks;
use crate::battle::action::{ActionParameters, DamageType};
use crate::battle::state::BattleState;
use crate::party::{Party, InventoryElement};
use crate::party::characte... | true |
13d03f8b5585a26af95bcf2724dfea1d62e928a5 | Rust | dicej/ordmap_performance | /src/lib.rs | UTF-8 | 3,988 | 3.015625 | 3 | [] | no_license | #![feature(test)]
extern crate im;
extern crate rand;
extern crate test;
use std::iter;
use im::OrdMap;
use im::nodes::btree::{Insert, Node, OrdValue, Remove};
use rand::{Rng, SeedableRng, StdRng};
use test::Bencher;
#[derive(Clone)]
struct Raw<K, V>(K, V);
impl<K: Ord + Clone, V: Eq + Clone> OrdValue for Raw<K, V>... | true |
51d974a6ca1ce79666b792f55fd6786eb776e4f5 | Rust | jazlalli/getting-started-with-rust | /fib/src/main.rs | UTF-8 | 970 | 3.84375 | 4 | [] | no_license | use std::io;
fn fib(n: u32) -> u32 {
// starting values for fib numbers and iteration idx
let mut prev_1: u32 = 1;
let mut prev_2: u32 = 1;
let mut iteration: u32 = 2;
let mut tmp: u32;
let mut next: u32 = prev_1;
let mut result: String = format!("{}, {}, ", prev_1, prev_2);
while iteration <= n {
... | true |
9a2215490f6fe9e6a802bb4366e70933f0cf25f9 | Rust | thibautRe/rustrogueliketutorial | /chapter-60-caverns3/src/ai/visible_ai_system.rs | UTF-8 | 2,833 | 2.5625 | 3 | [
"MIT"
] | permissive | extern crate specs;
use specs::prelude::*;
use crate::{MyTurn, Faction, Position, Map, raws::Reaction, Viewshed, WantsToFlee,
WantsToApproach, Chasing};
pub struct VisibleAI {}
impl<'a> System<'a> for VisibleAI {
#[allow(clippy::type_complexity)]
type SystemData = (
ReadStorage<'a, MyTurn>,
... | true |
2eb084a142a26ae9be18cc7074d93516583fc5c5 | Rust | aoc2020/day4_rust | /src/main.rs | UTF-8 | 3,587 | 2.984375 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, Lines, BufReader, BufRead};
use std::path::Path;
use regex::Regex;
use std::collections::{HashMap, HashSet};
// const regex : Regex = Regex::new(r"(\d+)-(\d+) (.): (.*)").unwrap();
fn main() {
let pws = read_passports();
let pws_with_all_fields: Vec<&Passport> = pws.iter... | true |
d2259a93377a49246e0a9695ba9132b2dbc2aaf4 | Rust | thominspace/aoc_2020 | /day_17/src/main.rs | UTF-8 | 26,487 | 3.1875 | 3 | [] | no_license | use std::time::{Instant};
use std::io::{Error};
use std::fs;
#[derive(Debug)]
struct Grid3 {
flat_grid: Vec<usize>,
grid_width: usize,
total_grid_cells: usize,
expansion: usize
}
impl Grid3 {
// if we ever hit a point where we need to expand the grid, handle that here
// this includes a full ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.