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
ab286eceb66375f4e1a8d7c0467a455860f0cfbb
Rust
rune-rs/rune
/crates/rune/src/tests/capture.rs
UTF-8
642
2.65625
3
[ "MIT", "Apache-2.0" ]
permissive
prelude!(); #[test] fn test_closure() { let number: i64 = rune! { pub async fn main() { let a = 1; let b = 2; let closure = { let c = 4; |d, e| |f| a + b + c + d + e + f }; closure(8, 16)(32) } }; assert_eq!(number, 1 + 2 + 4 + 8 + 16 + 32); ...
true
6cdccc602f0913135c5b486021aa5e2a932d4f62
Rust
mr1sunshine/mapbox-maps-rs
/src/style_spec/expression/zoom.rs
UTF-8
1,391
3.171875
3
[ "BSD-3-Clause" ]
permissive
use serde::de::{self, Deserialize, Deserializer, SeqAccess, Visitor}; use std::fmt; #[derive(Debug, PartialEq)] pub(crate) struct Zoom {} impl<'de> Deserialize<'de> for Zoom { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { struct ZoomVisitor; ...
true
5ad328a30c407ee96e69e25840e6348d7a8c725e
Rust
gitter-badger/rsrl
/src/experiment.rs
UTF-8
4,343
2.984375
3
[ "MIT" ]
permissive
use agents::ControlAgent; use domains::{Domain, Observation}; use geometry::{Space, ActionSpace}; use policies::Greedy; use slog::{Record, Serializer, Result as LogResult, Logger, KV}; /// Container for episodic statistics. #[derive(Debug)] pub struct Episode { /// The number of steps taken to reach the termina...
true
6de2f607fdeebeb658d41c4279e8de8549635c49
Rust
grakshith/crust
/src/rs/src/rc_pointer.rs
UTF-8
116
2.71875
3
[ "MIT" ]
permissive
// test the implementation of rc use std::rc::Rc; fn main() { let a = Rc::new(5); println!("result: {:?}", *a); }
true
1918d9f6ff011fb544bfabbd2b1f9906c79bfa7c
Rust
jbchouinard/rust-book
/liff/src/main.rs
UTF-8
180
3.328125
3
[]
no_license
fn to_owned_str(str_ref: &String) -> String { str_ref.clone() } fn main() { let s = String::from("foobar"); let s2 = to_owned_str(&s); println!("{}, {}", s, s2) }
true
37c66fc851c269d7406da48b9ecd0edc92dfa986
Rust
wansenai/chassis
/chassis/src/key.rs
UTF-8
10,634
2.734375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use core::fmt; use core::hash::{Hash, Hasher}; use std::fmt::Write; use quote::ToTokens; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::{GenericArgument, TraitBoundModifier, TypeParamBound}; use crate::errors::{ChassisError, ChassisResult}; /// Key to something to inject. /// /// Used to refere...
true
976a3f9ce87bd358514e5ef0401cf781b9afcfa0
Rust
alifarrokh/socks5-async
/socks5-async/src/socks.rs
UTF-8
4,964
2.75
3
[ "MIT" ]
permissive
#[allow(dead_code)] use std::{ error::Error, fmt, net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs}, }; use tokio::{ io::{AsyncReadExt, AsyncRead, AsyncWrite}, // net::TcpStream }; // Const bytes pub const VERSION5: u8 = 0x05; pub const RESERVED: u8 = 0x00; // Reques...
true
d9b2f6fc642aa24ccf7f91669c1f89c2353eafd1
Rust
revsic/AlphaZero-Connect6
/Connect6/libconnect6/src/agent/async_agent/mod.rs
UTF-8
4,340
3.15625
3
[ "MIT" ]
permissive
//! Agent for playing multiple games asynchronously. //! //! `AsyncAgent` play multiple games on tokio thread-pool. //! It pass the policy generator and return the vector of game result. //! //! # Examples //! ```rust //! # extern crate connect6; //! # use connect6::{agent::AsyncAgent, policy::RandomPolicy}; //! let po...
true
99543b96520d513ade02d3f0b57c19b8581cf38a
Rust
FrozenDroid/nrf91-rs
/src/saadc_ns/intenset.rs
UTF-8
66,216
2.90625
3
[ "0BSD" ]
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::INTENSET { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w ...
true
e42189ed820cd32b1e75071b91c58e1ae39554fe
Rust
moisutsu/AOJ-study
/src/bin/7c.rs
UTF-8
782
3.03125
3
[]
no_license
#[macro_use] mod input; fn main() { input! { r: usize, c: usize, input_table: [[i32; c]; r], } let mut output_table = vec![vec![0; c]; r + 1]; for y in 0..r { for x in 0..c { output_table[y][x] = input_table[y][x]; } } for x in 0..c { ...
true
8a5c9a78e0010324ca198388e230eb9e6d527bc3
Rust
ZcashFoundation/zebra
/zebra-chain/src/chain_tip/network_chain_tip_height_estimator.rs
UTF-8
6,256
3.359375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! A module with helper code to estimate the network chain tip's height. use std::vec; use chrono::{DateTime, Duration, Utc}; use crate::{ block::{self, HeightDiff}, parameters::{Network, NetworkUpgrade}, }; /// A type used to estimate the chain tip height at a given time. /// /// The estimation is based o...
true
d1fbc8beacf778f979fca824d172bde74d076fbc
Rust
wujinderead/MyGoProjects
/gotest/leet_rust/tests/leet1793_maximum_score_of_a_good_subarray.rs
UTF-8
2,206
3.4375
3
[]
no_license
// https://leetcode.com/problems/maximum-score-of-a-good-subarray/ // You are given an array of integers nums (0-indexed) and an integer k. // The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ...,nums[j]) * (j - i + 1). // A good subarray is a subarray where i <= k <= j. // Return the maximum possi...
true
bc3c400bb8d9426c342e6dc0f94f113c3340b15c
Rust
denoland/deno
/cli/tests/integration/init_tests.rs
UTF-8
3,098
2.515625
3
[ "MIT" ]
permissive
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use test_util as util; use util::assert_contains; use util::TestContextBuilder; #[test] fn init_subcommand_without_dir() { let context = TestContextBuilder::new().use_temp_cwd().build(); let cwd = context.temp_dir().path(); let output =...
true
32a62f2d4574de33fdea9fc24e5f7f0a5bd2e328
Rust
rapzo/prisma-engine
/migration-engine/connectors/sql-migration-connector/src/sql_renderer/postgres_renderer.rs
UTF-8
2,119
2.890625
3
[ "Apache-2.0" ]
permissive
use super::common::*; use sql_schema_describer::*; pub struct PostgresRenderer {} impl super::SqlRenderer for PostgresRenderer { fn quote(&self, name: &str) -> String { format!("\"{}\"", name) } fn render_column(&self, schema_name: &str, table: &Table, column: &Column, _add_fk_prefix: bool) -> Str...
true
df92deb823d32af33d9f60247c573e35db81294b
Rust
thebinarymutant/AOC-2019
/day-03-crossed-wires/src/main.rs
UTF-8
2,290
3.203125
3
[]
no_license
use std::collections::{HashMap, HashSet}; use std::env; use std::fs; pub struct Config { filename: String, } fn main() { let args: Vec<String> = env::args().collect(); let config = Config::new(&args).unwrap_or_else(|err| { println!("Problem parsing arguments: {}", err); Config { ...
true
829066b53f4e8d607a5b34b62a0b9a906c4f6ad5
Rust
fugashy/load_to_rustacean
/pattern_matching/src/lib.rs
UTF-8
12,517
3.71875
4
[ "MIT", "Apache-2.0" ]
permissive
// まとめ // - あらゆるところでパターンは使用されている // - ちゃんと,あり得る可能性をカバーしよう // // python 3.10あたりで,pythonにも導入されるかも? // (rustのsubprocessはpythonから影響を受けていたりなど,インスパイアされあっているような雰囲気) // // // この章は辞書的な感じで,いろんなパターンとそのマッチング方法を列挙している感じ // まずは6章の軽い復習+α enum Coin { Penny, Nickel, Dime, Quarter, } pub fn simple_matching() { l...
true
6220ce24c62787342ede1b7cc2f02ce97ad64b52
Rust
agemor/sage
/src/tensor/iter.rs
UTF-8
631
2.890625
3
[ "Apache-2.0" ]
permissive
use crate::tensor::Tensor; pub struct AlongAxisIter<'a> { t: &'a Tensor, axis: usize, index: usize, } impl<'a> AlongAxisIter<'a> { pub fn new(t: &'a Tensor, axis: usize) -> Self { AlongAxisIter { t, axis, index: 0 } } } impl<'a> Iterator for AlongAxisIter<'a> { type Item = Tensor; ...
true
70b400fee34cbdc78cc20d219b864487bdf8530f
Rust
jearos/aoc2020
/day6/src/main.rs
UTF-8
1,499
2.71875
3
[]
no_license
#[path = "../../common/aoc2020.rs"] mod aoc2020; use std::collections::HashMap; fn part1(filename: &str) -> u32 { let mut lines = aoc2020::lines_from_file(filename); lines.push("".to_string()); let mut ans = HashMap::new(); let mut nof_yes = 0; for l in lines { if l.len() == 0 { ...
true
9a7d0b6b2ec75bf50d913a8544e7931f6deb21ef
Rust
jonscanzi/music-master
/src/main.rs
UTF-8
10,903
2.671875
3
[]
no_license
//! # Basic Subclass example //! //! This file creates a `GtkApplication` and a `GtkApplicationWindow` subclass //! and showcases how you can override virtual funcitons such as `startup` //! and `activate` and how to interact with the GObjects and their private //! structs. extern crate gstreamer as gst; extern crate ...
true
783d2554db40110fd8f99db7eaf866de03418eeb
Rust
mazalet/SlmpClient
/src/dual_port_memory.rs
UTF-8
5,636
3.3125
3
[ "BSD-3-Clause" ]
permissive
use crate::enums::SLMPCommand; use crate::SLMPConnectionInfo; /// 自局のデュアルポートメモリのデータに対する読み取り要求の送信 /// # 引数 /// * `connection_info` - SLMP接続情報 /// * `timeout` - SLMPコマンドのタイムアウト /// * `start_addr` - 先頭アドレス /// * `word_length` - ワード長 /// # 返値 /// 発行したコマンドのシリアル pub fn send_read_memory( connection_info: &mut SLMPConnect...
true
c820daedbc0910b2044ed029ced1534238ecaa9d
Rust
JP-Ellis/coding-problems
/src/lib.rs
UTF-8
2,897
2.703125
3
[]
no_license
// coding-problems // Copyright (C) 2019 Joshua Ellis <josh@jpellis.me> // // This program is free software: you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation, either version 3 of the License, or (at your option) any later // v...
true
e55a77403072dfc032a7627e57cd9525028b3994
Rust
lvcq/rust-leetcode
/src/solutions/861.翻转矩阵后的得分.rs
UTF-8
970
2.578125
3
[]
no_license
/* * @lc app=leetcode.cn id=861 lang=rust * * [861] 翻转矩阵后的得分 */ // @lc code=start impl Solution { pub fn matrix_score(a: Vec<Vec<i32>>) -> i32 { let row: usize = a.len(); let col: usize = a[0].len(); let mut col_index: usize = 0; let mut row_index: usize = 0; let mut res...
true
3bcf3e935443f9d0a807dd71eb7073637159ded2
Rust
jean-airoldie/serde-owned
/serde-owned/src/lib.rs
UTF-8
3,591
3.140625
3
[ "MIT", "Apache-2.0" ]
permissive
use { serde::{de::DeserializeOwned, ser, Deserialize, Deserializer, Serialize, Serializer}, thiserror::Error, }; #[cfg(feature = "derive")] pub use serde_owned_derive::SerdeOwned; use std::fmt; pub use serde; /// A serialization error. /// /// Returns ownership of the `T`. #[derive(Error)] #[error("serializ...
true
1dcd0a7a8a072f8fcafd4cee464f81457856fa69
Rust
rust-common/tbe
/src/lib.rs
UTF-8
2,883
2.96875
3
[ "Apache-2.0" ]
permissive
extern crate base2; extern crate int; extern crate bitrw; pub struct TbeStruct<T: Copy> { k: u8, u: T, } impl<T: Copy> TbeStruct<T> { pub fn get_k(&self) -> u8 { self.k } pub fn get_u(&self) -> T { self.u } } pub trait Tbe: int::UInt + base2::Base2 { fn tbe(self) -> TbeStruct<Self> { let ...
true
56248b36ffa81347a83b7c9c02f58dec1e86c934
Rust
darshanparajuli/jobpool
/examples/runnable.rs
UTF-8
576
3.09375
3
[ "MIT" ]
permissive
extern crate jobpool; use jobpool::{JobPool, Runnable}; use std::thread; use std::time::Duration; struct SomeStruct { some_val: usize, } impl Runnable for SomeStruct { fn run(self: Box<Self>) { thread::sleep(Duration::from_millis(self.some_val as u64)); println!("some_val: {}", self.some_val)...
true
4b3c92085bd89335f51277d095b03e17618d6ffa
Rust
supython-coder/leetcode-rust
/S0976-largest-perimeter-triangle/src/main.rs
UTF-8
612
3.40625
3
[]
no_license
struct Solution; impl Solution { pub fn largest_perimeter(a: Vec<i32>) -> i32 { let mut a = a.clone(); a.sort_by(|x, y| y.cmp(x)); //println!("{:?}", a); for i in 2..a.len() { if Solution::is_valid(a[i], a[i - 1], a[i - 2]) { return a[i] + a[i - 1] + a[i ...
true
bbe88736a5a3c25b5c6a686f7ac9145c134d5cf5
Rust
IThawk/rust-project
/rust-master/src/test/run-pass/numbers-arithmetic/float2.rs
UTF-8
477
2.53125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass pub fn main() { let a = 1.5e6f64; let b = 1.5E6f64; let c = 1e6f64; let d = 1E6f64; let e = 3.0f32; let f = 5.9f64; let g = 1e6f32; let h = 1.0e7f64; let i = 1.0E7f64; let j = 3.1e+9f64; let k = 3.2e-10f64; assert_eq!(a, b); assert!((c < b)); assert...
true
f6084eb15ba485aa091acd9c3089ba245dc6a953
Rust
GraCosPA/rustcmb
/src/fourier/fft_1d.rs
UTF-8
3,361
2.59375
3
[ "MIT" ]
permissive
extern crate rustfft; use self::rustfft::algorithm::Radix4; use self::rustfft::FFT; use self::rustfft::num_complex::Complex; use self::rustfft::num_traits::Zero; use std::f64::consts::PI; pub fn first_realization(field: &mut Vec<f64>, a_mods: &Vec<f64>, b_mods: &Vec<f64>) { let size = field.len() - 1; asser...
true
7221495f6989735b5de06941798112e18546c7dc
Rust
open-dx/llvm-ir-analysis
/src/call_graph.rs
UTF-8
5,561
3.0625
3
[ "MIT" ]
permissive
use crate::functions_by_type::FunctionsByType; use either::Either; use llvm_ir::{Constant, Instruction, Module, Name, Operand, Type}; use petgraph::prelude::*; /// The call graph for the analyzed `Module`(s): which functions may call which /// other functions. /// /// To construct a `CallGraph`, use [`ModuleAnalysis`]...
true
238a280c3d96284430dfdde146342e626f213d61
Rust
mimblewimble/grin-wallet
/impls/src/tor/proxy.rs
UTF-8
5,426
2.625
3
[ "Apache-2.0" ]
permissive
// Copyright 2022 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
true
c4c7521e3b228a34ac07aed2a7f487b74e094ae2
Rust
ThePuffin/rustudemy
/introduction/second part/twopoint4.rs
UTF-8
213
3.78125
4
[]
no_license
//if else numero 16 fn main(){ let a = 100; let b = 20; let c = 500; if a>b && a>c { println!("A is greatest") }else if b>a && b>c { println!("B is greatest") } else { println!("C is greatest") } }
true
82038fdce92ee268c35443051daf0c6dae5a04b0
Rust
cypressf/learning-rust
/traits/src/main.rs
UTF-8
330
3.3125
3
[]
no_license
fn find_largest<T: PartialOrd>(list: &[T]) -> &T { let mut largest = &list[0]; for item in list.iter() { if item > largest { largest = item; } } largest } fn main() { print!( "{}", find_largest(&[String::from("a"), String::from("b"), String::from("c")])...
true
bceb7f05ce135048e8aac1bf24a6c898393ebbc7
Rust
romankoblov/gpu-compute
/src/program.rs
UTF-8
6,218
2.5625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use ansi_term::Colour; use crate::enums::{CompilerOpt}; use crate::backend::generic::{ComputeDevice}; // TODO: a lot of allocations, fix. struct LegacyIncludeProvider { name: String, map: HashMap<String, String>, } impl LegacyIncludeProvider { fn new(headers: Vec<String>, ...
true
a0d9991d720545710aed82fc2c407fc63c2a5284
Rust
rodrigocfd/winsafe
/src/gui/events/window_events_traits.rs
UTF-8
29,338
2.96875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::rc::Rc; use crate::co; use crate::decl::*; use crate::msg::*; use crate::prelude::*; /// Exposes methods to handle the basic window messages, plus timer and native /// control notifications. pub trait GuiEventsAll: GuiEvents { /// [`WM_TIMER`](https://learn.microsoft.com/en-us/windows/win32/winmsg...
true
535d9e907bde0dce819aa66a9a2e56de52a32b47
Rust
barzilouik/flowbetween
/animation/src/traits/frame.rs
UTF-8
1,540
2.8125
3
[ "Apache-2.0" ]
permissive
use super::edit::*; use super::vector::*; use super::brush_definition::*; use super::brush_properties::*; use super::brush_drawing_style::*; use canvas::*; use std::time::Duration; /// /// Represents a single frame in a layer of an animation /// pub trait Frame : Send+Sync { /// /// Time index of this frame ...
true
ab6de17a73ec51bb81ab0b302018796262267c3a
Rust
danlin604/rust
/slice-type/src/main.rs
UTF-8
980
4.0625
4
[ "MIT" ]
permissive
fn main() { // brittle example // let mut s = String::from("hello world"); // let word = first_word(&s); // s.clear(); // word and s is out of sync // String slice: reference to part of a string let s = String::from("hello world"); let hello = &s[..=4]; let world = &s[6..]; // Using slice let my_s...
true
7d41bb85e218fda9e6cb7d1410a54a1dc9ac9e69
Rust
cz-jcode/trow
/src/registry_interface/metrics.rs
UTF-8
481
2.890625
3
[ "Apache-2.0" ]
permissive
use thiserror::Error; #[derive(Error, Debug)] pub enum MetricsError { #[error("Internal metrics error")] Internal, } /* Could just use a string here, but later on we probably want more structure. */ #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct MetricsResponse { pub metrics: String...
true
5d06a75e1e672ed163ddea3985fc828692ac5fdb
Rust
fur-gan/chipmunk
/application/apps/indexer/merging/src/merger_async.rs
UTF-8
6,552
2.53125
3
[ "Apache-2.0" ]
permissive
use crate::merger::{FileLogEntryProducer, FileMergeOptions, IndexOutput}; use anyhow::Result; use crossbeam_channel as cc; use futures::{ pin_mut, stream::{Peekable, StreamExt}, }; use indexer_base::{ chunks::ChunkResults, error_reporter::*, progress::IndexingProgress, timedline::*, utils, }; use processor:...
true
7d6fa41a8138a048c0902d2d75fb50e2646e7b7a
Rust
adevore/ruma-api
/src/lib.rs
UTF-8
7,737
2.875
3
[ "MIT" ]
permissive
//! Crate `ruma_api` contains core types used to define the requests and responses for each endpoint //! in the various [Matrix](https://matrix.org) API specifications. //! These types can be shared by client and server code for all Matrix APIs. //! //! When implementing a new Matrix API, each endpoint has a request ty...
true
880f4b2013d1a6aa6c5169750b59526331ab2e0d
Rust
iwillspeak/ullage
/src/sem/binder.rs
UTF-8
37,724
3.671875
4
[ "MIT" ]
permissive
//! Expression Binder //! //! This module contains the syntax binder. It's job is to walk the //! incoming syntax tree and bind each part to produce the semantic //! tree. //! //! At any given level the bind consists of two main steps. First the //! list of expressions is walked to define any items that need to be //! ...
true
139d5f310e67b37d7910de22f21f3ce17a988e0d
Rust
koehlma/momba
/engine/crates/clock-zones/src/bounds.rs
UTF-8
11,199
3.59375
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::constants::*; /// Represents a bound. pub trait Bound: Clone { /// The type of the bounding constant. type Constant: Constant; /// The maximal value of the bounding constant if it exists. fn max_constant() -> Option<Self::Constant>; /// The minimal value of the bounding constant if it e...
true
8159ceb75bd61ec682895e077e5ca596dd15705c
Rust
zeamador/rust-evo
/evo_glium/src/bond_drawing.rs
UTF-8
3,387
2.9375
3
[]
no_license
use glium::{implement_vertex, uniform, Surface}; #[derive(Clone, Copy)] pub struct BondSprite { pub end1: [f32; 2], pub end2: [f32; 2], pub radius1: f32, pub radius2: f32, pub color: [f32; 3], } implement_vertex!(BondSprite, end1, end2, radius1, radius2, color); pub struct BondDrawing { pub s...
true
ea8e69e3731446939746a1604a6b84975def5454
Rust
mateuszgiza/Rusty
/src/systems/update_position.rs
UTF-8
1,236
2.828125
3
[ "MIT" ]
permissive
use specs::{ System, Read, WriteStorage, ReadStorage }; use resources::{ DeltaTime, WindowSize }; use components::{ Position, Velocity, Size }; use extensions::*; pub struct UpdatePos; impl<'a> System<'a> for UpdatePos { type SystemData = ( Read<'a, DeltaTime>, Read<'a, WindowSize>, WriteS...
true
6ab996d43b6cc705b9171c5a56e601790fd1adec
Rust
chromium/chromium
/third_party/rust/hashbrown/v0_11/crate/tests/serde.rs
UTF-8
1,487
2.796875
3
[ "BSD-3-Clause", "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "GPL-1.0-or-later", "LGPL-2.0-or-later" ]
permissive
#![cfg(feature = "serde")] use core::hash::BuildHasherDefault; use fnv::FnvHasher; use hashbrown::{HashMap, HashSet}; use serde_test::{assert_tokens, Token}; // We use FnvHash for this test because we rely on the ordering type FnvHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FnvHasher>>; type FnvHashSet<T> = HashS...
true
598e6a8e290910d0fad5b174c0729404a9b07a4b
Rust
dashed/between
/src/lib.rs
UTF-8
7,308
3.421875
3
[ "MIT" ]
permissive
use std::cmp; use std::cmp::Ordering; use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use std::iter::FromIterator; use itertools::Itertools; #[derive(Debug, Clone)] pub struct Between { chars: Vec<char>, chars_set: HashSet<char>, chars_lookup: HashMap<char, usize>, high: char, low: ...
true
57236a9020c1306d0cf17dcf41072389d85d6e55
Rust
sbaldwin621/adventofcode2020
/day13/shuttle/src/lib.rs
UTF-8
2,861
3.296875
3
[]
no_license
use std::error::Error; use std::fmt::Display; use std::fs::{File}; use std::io::{self, BufRead}; use std::path::Path; use config::Config; pub mod config; pub fn run(config: Config) -> Result<usize, Box<dyn Error>> { let filename = config.filename; let lines = read_lines(filename)?; if lines.len() != 2 {...
true
f7abd2fcc1bcde8824fd5da2bc17396e5a4f8c15
Rust
eagletmt/misc
/rust/dockerhub-login/src/cdp.rs
UTF-8
1,193
2.90625
3
[ "CC0-1.0" ]
permissive
pub type SessionId = String; #[derive(Debug, serde::Serialize)] #[serde(rename_all = "camelCase")] pub struct Request<'a, T> { pub id: u64, #[serde(skip_serializing_if = "Option::is_none")] pub session_id: Option<&'a SessionId>, pub method: &'static str, pub params: T, } #[derive(Debug, serde::Des...
true
baa1c5dffb14ec920ef1de0d6cb4af211f33e767
Rust
sblundy/dedup-cli
/src/lib.rs
UTF-8
1,364
2.765625
3
[ "MIT" ]
permissive
use crate::deduplication::dedup; use std::fs::File; use std::io; pub fn dedup_with_params( input: Option<&str>, output: Option<&str>, stdin: &mut io::Read, stdout: &mut io::Write, ) -> io::Result<()> { match (input, output) { (None, None) => dedup(stdin, stdout), (Some(input_file_na...
true
0839b67993b6359b551c00b0bfd046e4d651e69f
Rust
mongodb/mongo-odbc-driver
/integration_test/tests/connection_tests.rs
UTF-8
2,969
2.609375
3
[ "Apache-2.0" ]
permissive
mod common; mod integration { use crate::common::{allocate_env, connect_with_conn_string}; #[test] fn test_invalid_connection() { let env_handle = allocate_env().unwrap(); // Missing PWD let conn_str = "Driver=MongoDB Atlas SQL ODBC Driver;USER=N_A;SERVER=N_A"; let result ...
true
8a55fd427b932c643a691138b77047e9fb8b97ae
Rust
astral-sh/ruff
/crates/ruff/src/rules/pydocstyle/helpers.rs
UTF-8
2,658
3.0625
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-free-unknown", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
use std::collections::BTreeSet; use ruff_python_ast::call_path::from_qualified_name; use ruff_python_ast::cast; use ruff_python_ast::helpers::map_callable; use ruff_python_ast::str::is_implicit_concatenation; use ruff_python_semantic::{Definition, Member, MemberKind, SemanticModel}; use ruff_source_file::UniversalNewl...
true
01eb48b8e0de8c196f42c591120bb6868d338d66
Rust
nestordemeure/paretoFront
/tests/concurrent_pareto_front.rs
UTF-8
2,453
3.234375
3
[ "Apache-2.0" ]
permissive
mod pareto_element; use pareto_element::ParetoElement; use pareto_front::ParetoFront; /// adds 1000 elements to a ParetoFront and a simulated ConcurrentParetoFront /// check the result to ensure they are the same /// in practice this tests the push and merge operation, reducing the list of potential culprits in case o...
true
15d61e30218a4af631147ff253c040f7170a855a
Rust
bcomb/hello-rust-raytracer
/src/core/hitable.rs
UTF-8
893
3.0625
3
[]
no_license
#![allow(dead_code)] use crate::core::*; #[derive(Debug)] pub struct HitRecord<'a> { pub t: f32, // distance pub p: Vec3, // intersection point pub normal: Vec3, pub material: &'a Material // material of the hit surface } pub trait Hitable { fn hit(&self...
true
7e81ab93294ec020a9648ed555c8535c597bdccc
Rust
dragonrider7225/verbose_hkts
/src/meltdown/mod.rs
UTF-8
539
2.96875
3
[ "MIT" ]
permissive
use applicative::Applicative; use core::Concrete; use functor::Functor; #[test] fn main() { let xs = Concrete::of(vec![1, 2, 3i32]); // Concrete::of helps the compiler infer the types through constraint manipulation; // simply using the naked constructor might fail to resolve the types // let fv = Conc...
true
0fba5b3ea3f0b09940fac736b62269534b12d543
Rust
EvoTeamDevelop/arcana
/src/prefab.rs
UTF-8
2,705
2.984375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use { crate::{graphics::Graphics, resources::Res}, flume::{unbounded, Receiver, Sender}, goods::{Asset, AssetResult, Loader}, hecs::{Entity, World}, tracing::Instrument, uuid::Uuid, }; /// An prefab type that can be spawned in the [`World`]. /// /// Typical prefab would load assets and construc...
true
38d2230a73ffa6e6898fd778c456cd4e16fb7064
Rust
ennis/autograph-ng
/api-gl/src/sync.rs
UTF-8
5,432
3.171875
3
[]
no_license
use crate::{ api as gl, api::{types::*, Gl}, }; use std::{collections::vec_deque::VecDeque, time::Duration}; /// A synchronization primitive for objects used by the GPU. /// /// This wrapper around OpenGL sync objects (fences) can be used to wait until the GPU has finished /// using a particular object. pub st...
true
02bd71c8d8abe73901f62aa8bcfd0f5949a04e8a
Rust
whatalnk/cpsubmissions
/atcoder/rust/abc064/abc064_a/3547270.rs
UTF-8
747
2.9375
3
[]
no_license
// Contest ID: abc064 // Problem ID: abc064_a ( https://atcoder.jp/contests/abc064/tasks/abc064_a ) // Title: A. RGB Cards // Language: Rust (1.15.1) // Submitted: 2018-11-05 08:43:50 +0000 UTC ( https://atcoder.jp/contests/abc064/submissions/3547270 ) use std::io; fn gets() -> String { let mut buf = String::new...
true
39ac03fafe2d6af71dd6005194408e388c634bc4
Rust
SilvanCodes/novel-set-neat
/src/genes/id/id_iter.rs
UTF-8
1,217
3.328125
3
[]
no_license
use std::ops::RangeFrom; use super::Id; pub struct IdIter<'a> { index: usize, ids: &'a mut Vec<Id>, gen: &'a mut RangeFrom<usize>, } impl<'a> Iterator for IdIter<'a> { type Item = Id; fn next(&mut self) -> Option<Self::Item> { if self.index < self.ids.len() { let index = self...
true
98f538fd811f7bdd10b94078e906091e25e59a36
Rust
provable-things/ptokens-core
/src/chains/eth/eth_receipt_type.rs
UTF-8
1,987
3.421875
3
[]
no_license
use std::fmt; use serde::Deserialize; use strum_macros::EnumIter; use crate::types::{Byte, Bytes}; #[derive(Clone, Debug, EnumIter, Eq, PartialEq, Deserialize)] pub enum EthReceiptType { Legacy, EIP2718, } impl EthReceiptType { pub fn from_byte(byte: &Byte) -> Self { match byte { 0x0...
true
0649da4613564be8b0cb6c3cff18c7d8674e74f7
Rust
SolarLiner/rs-logik
/bin/repl.rs
UTF-8
1,389
3.0625
3
[ "MIT" ]
permissive
use clap::App; use logik::eval; use std::io::{self, Write}; fn main() -> io::Result<()> { let matches = App::new("Évaluateur Logik") .version("0.1") .author("Arthur & Nathan G.") .about("Évalue des propositions logiques") .arg_from_usage( "-e, --eval [EXPR] 'Évalue une e...
true
46668863dffd9cf215314efc9c71282af5d107cd
Rust
manpat/rogue-lewis
/src/view/text_view/util.rs
UTF-8
3,067
2.796875
3
[]
no_license
use super::render_buffer::*; use crate::prelude::*; use crate::gamestate::GameState; use crate::item::Item; use crate::room::{Room, EncounterType}; // https://en.wikipedia.org/wiki/Box_Drawing_(Unicode_block) // https://en.wikipedia.org/wiki/Unicode_symbols // const EMPTY_CHAR: char = '░'; // '\u{2591}'; const EMPT...
true
8df59b25db29dadd492657287868eafd92222467
Rust
Detegr/gameboy-rs
/src/cartridge.rs
UTF-8
1,061
3.5625
4
[]
no_license
pub trait Cartridge { fn write_u8(&mut self, addr: u16, value: u8); fn read_u8(&self, addr: u16) -> u8; } // Defaults to 16Mbit rom/8KByte ram mode pub struct MBC1 { memory: Box<[u8]>, } impl MBC1 { pub fn new(ram: &[u8]) -> MBC1 { info!("Cartridge type is MBC1"); let mut memory = vec![...
true
78824b3538ec36f92e1d4256cad0d5469452424a
Rust
AprliRainkun/rua
/src/ir_generator/resource_allocator/mod.rs
UTF-8
7,570
2.953125
3
[ "Unlicense" ]
permissive
use std::collections::HashMap; use std::ptr; use super::types::*; #[derive(Debug)] pub struct RegisterAlloc { name_indexer: HashMap<String, u32>, counter: u32, } // TODO: add register pool for nameless varibles // so that temporary register can be reused impl RegisterAlloc { pub fn new() -> Register...
true
feb230df6adf6a64cd51385e1a5b23374a35b5e8
Rust
ikysil/rust99
/graphs/P85/src/lib.rs
UTF-8
3,698
2.875
3
[]
no_license
use graph::Graph; use std::collections::{HashMap, HashSet}; use std::hash::Hash; pub fn is_isomorphic_to<T: Hash + Copy + Eq + Ord, U: Hash + Copy + Eq + Ord>( g1: &Graph<T>, g2: &Graph<U>, ) -> bool { fn is_isonorphic_to_rec<T: Hash + Copy + Eq + Ord, U: Hash + Copy + Eq + Ord>( g1: &Graph<T>, ...
true
ab67409b4302262972d4d1c5564aca98494efa1e
Rust
cynecx/docs.rs
/src/db/delete_crate.rs
UTF-8
6,040
2.546875
3
[ "MIT" ]
permissive
use super::file::{s3_client, S3_BUCKET_NAME}; use failure::Error; use postgres::Connection; use rusoto_s3::{DeleteObjectsRequest, ListObjectsV2Request, ObjectIdentifier, S3Client, S3}; /// List of directories in docs.rs's underlying storage (either the database or S3) containing a /// subdirectory named after the crat...
true
79cfa848fd84405677e53bd818591c664cf1e9f3
Rust
jk983294/CommonScript
/rust_learn/learn/topics/flow.rs
UTF-8
1,583
4
4
[]
no_license
enum CarType { Hatch, Sedan, SUV, } fn main() { let num: i32 = 5; if num > 0 { println!("number is positive"); } else if num < 0 { println!("number is negative"); } else { println!("number == 0"); } let state_code = "MH"; let state = match state_code { ...
true
978e7b2f43843aa1feed6b1a6e9ede18fd1a3f5e
Rust
0xbadcoffe/ctap-hid-fido2
/src/get_assertion_params.rs
UTF-8
2,561
2.5625
3
[ "MIT" ]
permissive
/*! get_assertion API parameters */ use crate::util; /// Assertion Object #[derive(Debug, Default, Clone)] pub struct Assertion { pub rpid_hash: Vec<u8>, pub flags_user_present_result: bool, pub flags_user_verified_result: bool, pub flags_attested_credential_data_included: bool, pub flags_extensi...
true
56d941c928d7378c6495fa8f6e8140e739a8ba86
Rust
coolreader18/flatpak-alias
/src/main.rs
UTF-8
1,559
2.84375
3
[ "MIT" ]
permissive
extern crate toml; fn main() -> Result<(), String> { let action = std::env::args().nth(1).ok_or("Missing first parameter")?; match action.as_ref() { "sh" => get_aliases(), _ => Err("Invalid first parameter".to_string()), } } fn get_aliases() -> Result<(), String> { let config_file = std::env::home_dir...
true
f5f7af1093ce944c2b7a3acab51d36101fa6ca90
Rust
lalbuild/lal
/src/storage/local.rs
UTF-8
4,274
2.859375
3
[ "MIT" ]
permissive
#![allow(missing_docs)] use std::{ fs, io::ErrorKind, path::{Path, PathBuf}, str::FromStr, vec::Vec, }; use crate::core::{config_dir, ensure_dir_exists_fresh, CliError, LalResult}; /// LocalBackend configuration options (currently none) #[derive(Serialize, Deserialize, Clone, Default)] pub struc...
true
c7d0aa6ed99e6ac32a34edc9d4a638d7cbcb1c3e
Rust
bznein/AoC-2019
/Day21/src/main.rs
UTF-8
2,263
3.125
3
[]
no_license
use intcode::IntcodeMachine; use intcode::State; use std::io::{self, Read}; fn string_to_command(s: String) -> Vec<i64> { s.chars().map(|x| x as u8 as i64).collect() } fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); if input.ends_with('\n') { input....
true
b53bcd7c8fb4d05c9ef85be48efe3be6aaf556b2
Rust
Snopx/RustLearnRepo
/src/enum_learn.rs
UTF-8
1,187
3.765625
4
[]
no_license
pub fn enum_learn() { let four = IpAddrKind::V4; let six = IpAddrKind::V6; route(four); route(six); route(IpAddrKind::V4); let ipa = Ipaddr { kind: IpAddrKind::V4, address: String::from("127.0.0.1"), }; let ip4 = IpAddrKind2::V4(127, 0, 0, 1); let ip6 = IpAddrKind2:...
true
c903c748ab734f971ed7640c19cb65970d37d6f6
Rust
pola-rs/polars
/crates/polars/tests/it/lazy/expressions/filter.rs
UTF-8
1,011
2.640625
3
[ "MIT" ]
permissive
use super::*; #[test] fn test_filter_in_group_by_agg() -> PolarsResult<()> { // This tests if the filter is correctly handled by the binary expression. // This could lead to UB if it were not the case. The filter creates an empty column. // but the group tuples could still be untouched leading to out of bo...
true
1ee9603863c7d66c9b608c02cf5fa9c6bd47df22
Rust
iCodeIN/libpart
/src/bin/gptdump.rs
UTF-8
727
2.546875
3
[]
no_license
extern crate libpart; use libpart::gpt; use std::env; use std::fs::File; fn main() { let args = env::args().collect::<Vec<_>>(); println!("{:?}", args); let file_name = &args[1]; println!("Reading GPT of {}", file_name); let mut file = File::open(file_name).unwrap(); let table = gpt::GPT...
true
714a8f3a97797ef16ea566d377f15304f995636f
Rust
lesurp/OptionalStruct
/tests/nested.rs
UTF-8
864
3.03125
3
[ "Apache-2.0" ]
permissive
use optional_struct::*; #[optional_struct] struct Config { timeout: Option<u32>, #[optional_rename(OptionalLogConfig)] log_config: LogConfig, } #[optional_struct] struct LogConfig { log_file: String, log_level: usize, } #[test] fn test_apply_options() { let mut config = Config { time...
true
c955f45bc4adbd75c1745bc60a01f4d950d566e6
Rust
rafaelcaricio/duktape-rs
/examples/basic.rs
UTF-8
241
3.09375
3
[ "MIT" ]
permissive
use duktape::Context; fn main() { // Create a new context let ctx = Context::new().unwrap(); // Eval 5+5 let val = ctx.eval_string("5 + 5").unwrap(); // Get resulting value as an i64 println!("Result is: {}", val) }
true
fcf35358b8c5413bc7ad8d02edca7f261fbf5895
Rust
Vanille-N/ray_tracer
/pytrace/src/external/interaction.rs
UTF-8
7,535
2.75
3
[ "MIT" ]
permissive
use crate::internal; use pyo3::prelude::*; use pyo3::{PyNumberProtocol, PyObjectProtocol}; use std::fmt; use std::sync::Arc; use std::vec; pub trait ToInternal: Send + Sync { fn to_internal(&self) -> internal::Primitive; fn display(&self) -> String; } #[pyclass] #[derive(Clone)] pub struct Construct { pub...
true
5660b6ae22c7f0e7127fcb5f19de48a657bbd6e7
Rust
AravindVasudev/datastructures-and-algorithms
/problems/leetcode/build-array-from-permutation.rs
UTF-8
302
2.90625
3
[ "MIT" ]
permissive
// https://leetcode.com/problems/build-array-from-permutation/ impl Solution { pub fn build_array(nums: Vec<i32>) -> Vec<i32> { let mut ans = vec![0; nums.len()]; for (idx, num) in nums.iter().enumerate() { ans[idx] = nums[*num as usize]; } ans } }
true
3408d876bfd6de815079d17d089518223c83435a
Rust
LordSentox/3d_playground
/src/graphics/window.rs
UTF-8
4,428
2.625
3
[]
no_license
use gl; use sdl2; // use super::error::WindowError as Error; use sdl2::video::{GLProfile, WindowBuildError as BuildError}; use sdl2::EventPump; use cgmath; use cgmath::prelude::*; use cgmath::{Deg, Rad, Matrix4}; use std::mem; use std::ffi::CString; use super::{Camera, GLId, Program}; pub struct Window { sdl_contex...
true
6aa305b1dd8b2d99910aefcfda6c259efda93b4e
Rust
markov-chain/mcpat
/src/lib.rs
UTF-8
2,925
2.65625
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate libc; extern crate mcpat_sys as raw; #[cfg(feature = "caching")] extern crate hiredis; use std::fmt::{self, Display, Formatter}; use std::marker::PhantomData; use std::path::Path; /// An error. #[derive(Clone, Debug)] pub struct Error { pub kind: ErrorKind, pub message: Option<String>, } /// An...
true
00e2d447908669c83750c448f0ccf09ba2358023
Rust
iCodeIN/proc-blocks
/modulo/src/lib.rs
UTF-8
1,279
2.890625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![no_std] use hotg_rune_proc_blocks::{ProcBlock, Tensor, Transform}; use num_traits::{FromPrimitive, ToPrimitive}; pub fn modulo<T>(modulus: f32, values: &mut [T]) where T: ToPrimitive + FromPrimitive, { for item in values { let float = item.to_f32().unwrap(); *item = T::from_f32(float % modu...
true
c2e7d9ad7f8b0a6028ef5f6f494030bd1d52de15
Rust
guywaldman/azure-sdk-for-rust
/azure_sdk_cosmos/src/database.rs
UTF-8
722
2.5625
3
[ "LicenseRef-scancode-generic-cla", "MIT" ]
permissive
#[derive(Serialize, Clone, PartialEq, PartialOrd, Deserialize, Debug)] pub struct Database { pub id: String, #[serde(rename = "_rid")] pub rid: String, #[serde(rename = "_ts")] pub ts: u64, #[serde(rename = "_self")] pub _self: String, #[serde(rename = "_etag")] pub etag: String, ...
true
8c5f0de0b56749ffebfb138989a9ee7423558478
Rust
rrybarczyk/intermodal
/src/test_env_builder.rs
UTF-8
1,656
2.890625
3
[ "CC0-1.0" ]
permissive
use crate::common::*; pub(crate) struct TestEnvBuilder { args: Vec<OsString>, current_dir: Option<PathBuf>, out_is_term: bool, tempdir: Option<TempDir>, use_color: bool, } impl TestEnvBuilder { pub(crate) fn new() -> TestEnvBuilder { TestEnvBuilder { args: Vec::new(), current_dir: None, ...
true
7da11bc550262fd347e5984791fe8e12598334d6
Rust
marco-c/gecko-dev-wordified
/third_party/rust/derive_more/tests/generics.rs
UTF-8
1,963
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# ! [ allow ( dead_code non_camel_case_types ) ] # [ macro_use ] extern crate derive_more ; # [ derive ( From FromStr Display Index Not Add Mul Sum IndexMut AddAssign MulAssign Deref DerefMut IntoIterator Constructor ) ] # [ deref ( forward ) ] # [ deref_mut ( forward ) ] # [ into_iterator ( owned ref ref_mut ) ] struc...
true
f295106afef80a0cb56829d4342211919817ba3e
Rust
SonicFrog/thesis
/code/entry.rs
UTF-8
189
2.875
3
[]
no_license
struct BucketEntry<K, V> { key: K, value: V, } impl<K, V> BucketEntry<K, V> { fn key_matches(&self, key: &K) -> bool; fn value_ref(&self) -> &V; fn value(self) -> V; }
true
72af82ed103d86d05782a37fdc918d713be0c06c
Rust
lprib/browncode
/src/ast.rs
UTF-8
1,897
3.171875
3
[]
no_license
//! AST definitions used by PEG and interpreter pub type Block<'a> = Vec<LineData<'a>>; pub type DataBlock<'a> = Vec<DataDef<'a>>; type E<'a> = Box<Expr<'a>>; #[derive(Debug)] pub enum Expr<'a> { Literal(u32), Deref(E<'a>), DerefByte(E<'a>), Var(&'a str), VarAddress(&'a str), Invert(E<'a>), ...
true
5b8d360ffc0d91754b0891ceabdc2c27dd0638e3
Rust
abatkin/assume-role
/src/credential_file.rs
UTF-8
1,141
2.953125
3
[ "MIT" ]
permissive
use std::path::Path; use anyhow::{Context, Result}; use aws_sdk_sts::types::Credentials; use ini::Ini; pub struct CredentialFile { ini: Ini, } impl CredentialFile { pub fn load<P: AsRef<Path>>(filename: P) -> Result<CredentialFile> { let path = filename.as_ref(); let ini = Ini::load_from_file...
true
4886e980813ad22d2a5906f4e8ffbefb03bb1776
Rust
Hilldrupca/LeetCode
/rust/Monthly/April2021/minimum_ops_equal_array/src/lib.rs
UTF-8
1,558
3.90625
4
[]
no_license
/// LeetCode Monthly Challenge problem for April 6th, 2021. pub struct Solution {} impl Solution { /// Given an array length n where arr[i] = 2 * i + 1, returns the minimum /// operations to make all elements equal. /// /// At each operation two indices are chosen, x and y. Then 1 is subtracted //...
true
d44337a7c58c3a7c60a60306c7d26b46aae0bd4c
Rust
Zion-007/weather-rs
/src/main.rs
UTF-8
20,198
2.640625
3
[ "ISC" ]
permissive
#![allow(non_snake_case, non_upper_case_globals)] extern crate time; extern crate term; extern crate rustc_serialize; extern crate hyper; extern crate getopts; use std::env; use std::io::Error; use std::io::prelude::*; use std::iter; use std::iter::FromIterator; use time::{strftime, strptime}; use rustc_serialize::js...
true
2322406f509d3f677a03323e83d4a0038251bfc9
Rust
ric2b/Vivaldi-browser
/chromium/third_party/rust/minimal_lexical/v0_2/crate/src/fpu.rs
UTF-8
3,890
3.4375
3
[ "Apache-2.0", "BSD-3-Clause", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Platform-specific, assembly instructions to avoid //! intermediate rounding on architectures with FPUs. //! //! This is adapted from the implementation in the Rust core library, //! the original implementation can be [here](https://github.com/rust-lang/rust/blob/master/library/core/src/num/dec2flt/fpu.rs). //! //! ...
true
d031409dd5afe8224392c97e3f0d3199fee1f22d
Rust
oli-obk/playform
/client/lib/src/shaders/world_fragment.rs
UTF-8
813
2.6875
3
[ "MIT" ]
permissive
pub fn to_string() -> String { r#" vec4 world_fragment( vec3 light_direction, vec3 intensity, vec3 view_direction, vec3 ambient_light, vec4 material_color, float shininess, vec3 normal, vec4 fog_color, float frag_distance ) {{ float diffuse = dot(nor...
true
12a534020d3cd221bf8d87d7147f00e6cdfea473
Rust
brl/pH
/src/io/busdata.rs
UTF-8
3,166
3.3125
3
[]
no_license
use std::convert::TryInto; use std::fmt::{Debug, Formatter}; /* pub enum IoInt { Byte(u8, [u8; 1]), Word(u16, [u8; 2]), DWord(u32, [u8; 4]), QWord(u64, [u8; 8]), Data(Vec<u8>), } impl IoInt { pub fn new_byte(n: u8) -> Self { Self::Byte(n, [n]) } pub fn new_word(n: u16) -> Self ...
true
bf0e1af29cefcd230bbb8129835b61ec7a2be08c
Rust
travistrue2008/zensen.rs
/src/style.rs
UTF-8
29,470
2.875
3
[ "MIT" ]
permissive
use std::ops::Add; #[derive(Debug, Copy, Clone)] pub enum Scalar { Auto, Zero, Pc(i32), Px(i32), } impl Default for Scalar { fn default() -> Self { Scalar::Auto } } #[derive(Debug, Copy, Clone)] pub struct Color { r: u8, g: u8, b: u8, a: u8, } impl Color { pub con...
true
926a0e96349e9bfb61fbb65443acf2055ea7656f
Rust
nushell/nushell
/crates/nu-json/tests/main.rs
UTF-8
6,992
2.8125
3
[ "MIT" ]
permissive
// FIXME: re-enable tests /* use nu_json::Value; use fancy_regex::Regex; use std::fs; use std::io; use std::path::{Path, PathBuf}; fn txt(text: &str) -> String { let out = String::from_utf8_lossy(text.as_bytes()); #[cfg(windows)] { out.replace("\r\n", "").replace("\n", "") } #[cfg(not(win...
true
e6d07faade82a14816d3128323a6fc71e971e860
Rust
estokes/rusty-driver
/src/lib.rs
UTF-8
16,256
2.671875
3
[ "MIT" ]
permissive
//! A high-level API for programmatically interacting with web pages //! through WebDriver. //! //! [WebDriver protocol]: https://www.w3.org/TR/webdriver/ //! [CSS selectors]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors //! [powerful]: https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes /...
true
94ef2638874d8e99c58891fb93dd39b12d33639b
Rust
katharostech/raui
/raui-tesselate-renderer/src/tesselation.rs
UTF-8
4,314
2.796875
3
[ "MIT" ]
permissive
use crate::Index; use raui_core::{widget::WidgetId, Scalar}; use serde::{Deserialize, Serialize}; use std::ops::Range; use vek::Vec2; #[repr(C)] #[derive(Debug, Default, Copy, Clone, Serialize, Deserialize)] pub struct Position(pub Scalar, pub Scalar); impl From<Vec2<Scalar>> for Position { fn from(v: Vec2<Scalar...
true
a183d2824c5e84a49792ac0abf94321d02069cff
Rust
yishn/adventofcode
/2018/12.rs
UTF-8
2,841
3.375
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::prelude::*; use std::collections::{HashSet, HashMap}; fn get_input() -> std::io::Result<String> { let mut file = File::open("12.txt")?; let mut contents = String::new(); file.read_to_string(&mut contents)?; Ok(contents) } type State = HashSet<isize>; type Instructions ...
true
368eaf173a68427ed06dc7fa0c677eb970aca80b
Rust
DavidBM/acteur-rs
/src/facade.rs
UTF-8
9,237
2.9375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate::actors::proxy::ActorReport; use crate::services::handle::{Listen, Serve}; use crate::services::service::Service; use crate::system_director::SystemDirector; use crate::{Actor, Receive, Respond}; use async_std::task; use lazy_static::lazy_static; use std::any::TypeId; use std::fmt::Debug; // We do this in or...
true
3521b1aca51137ed62fe47b1f4372f790358de9f
Rust
jpace121/rstscm
/src/main.rs
UTF-8
3,087
3.421875
3
[ "Apache-2.0", "LicenseRef-scancode-other-permissive" ]
permissive
extern crate regex; use std::collections::HashMap; use regex::Regex; enum SchmAtom { Int(i32), Float(f32), String(String), Symb(String), Vec(Vec<SchmAtom>), Func(Box<Fn(SchmAtom) -> SchmAtom>) } fn main() { } fn tokenize(input: String) -> Vec<String>{ // Split input string into smaller t...
true
4b78322edc9fab089503d887a0835e736d4ca1f6
Rust
bschiela/cis198-final-project
/src/action/ecs_action.rs
UTF-8
1,236
3.265625
3
[]
no_license
//! This module contains types which are useful for describing actions that the ECSClient //! can perform on your behalf. use std::fmt::{Display, Formatter, Error}; use serde::ser::Serialize; use serde::de::Deserialize; /// An enum defining the possible actions which can be sent to Amazon ECS. #[derive(Clone, Copy, D...
true
f6814e72e4fd80e6accda0c66b623c009cdde831
Rust
H-M-H/fltk-rs
/src/draw.rs
UTF-8
5,554
2.875
3
[ "MIT" ]
permissive
use crate::image::RgbImage; pub use crate::prelude::*; use fltk_sys::draw::*; use std::os::raw; /// Draws a line pub fn draw_line(x1: i32, y1: i32, x2: i32, y2: i32) { unsafe { cfl_line(x1, y1, x2, y2); } } /// Draws a point pub fn draw_point(x: i32, y: i32) { unsafe { cfl_point(x, y) } } /// Dra...
true
8d2e8684c77261f7d026e055d27ae78139ba4f35
Rust
forgeyao/rust-learning
/TyrChen-Lesson-One/02/shape/main.rs
UTF-8
2,229
4.1875
4
[ "Apache-2.0" ]
permissive
// 思考题 // 要构造一个数据结构 Shape,可以是 Rectangle、Circle 或是 Triangle,这三种结构如下代码。请问 Shape // 类型该用什么数据结构实现?怎么实现? // 对于上面的三种结构,如果我们要定义一个接口,可以计算周长和面积,怎么计算? // 解题思路 // 考虑用继承,Shape 做基类,其他继承 Shape。实现时发现 Rust 不支持继承,就放弃这方案了 // 参考评论区解答,发现可以用枚举 enum Shape { Rec(Rectangle), Cir(Circle), Tri(Triangle), } impl Shape { fn are...
true