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
44036f5f6957f7f2a7f1431f2ea87411ad065176
Rust
tafia/quick-xml
/src/reader/parser.rs
UTF-8
10,724
3.03125
3
[ "MIT" ]
permissive
#[cfg(feature = "encoding")] use encoding_rs::UTF_8; use crate::encoding::Decoder; use crate::errors::{Error, Result}; use crate::events::{BytesCData, BytesDecl, BytesEnd, BytesStart, BytesText, Event}; #[cfg(feature = "encoding")] use crate::reader::EncodingRef; use crate::reader::{is_whitespace, BangType, ParseState...
true
41066b9658c46abf154b40853f6ffda60e0d4a5c
Rust
nickel-org/nickel.rs
/src/responder.rs
UTF-8
5,152
3.09375
3
[ "MIT" ]
permissive
//! Blanket impls for Middleware. //! This is pre-implemented for any function which takes a //! `Request` and `Response` parameter and returns anything //! implementing the `Responder` trait. It is also //! implemented for a tuple of a function and a type `T`. //! The function must take a `Request`, a `Response` and a...
true
3b2074086d279043ef48f16afe1dce7ad533a8bd
Rust
brianjiang2200/grade_tracker
/src/main.rs
UTF-8
2,263
3
3
[]
no_license
//GradeTracker //Author: Brian Jiang //Date Created: 12/6/2019 //Commands: //addcourse [coursename] //rmcourse [coursename] (if it exists) //view [coursename] //list //gpa //add [summative name][coursename][score (percentage or raw)][weight] //try [summative name][coursename][score(percentage or raw)][weight] //hide...
true
02973a97bc87dac9c3fad76f8b62a9c8b4483f4e
Rust
polachok/unshare
/src/stdio.rs
UTF-8
2,738
3.015625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::os::unix::io::{RawFd, FromRawFd, AsRawFd}; use libc; /// An enumeration that is used to configure stdio file descritors /// /// The enumeration members might be non-stable, it's better to use /// one of the constructors to create an instance pub enum Stdio { Pipe, Inherit, Null, Fd(Closing),...
true
fac922d5fab14930c7bb7d8ecf55c59324b4938e
Rust
wangchao0502/rust-leetcode
/src/p5545_best_team_score.rs
UTF-8
1,541
3.203125
3
[]
no_license
#![allow(dead_code)] // use mods pub struct Solution {} // add structs // answers // dp -> 哨兵问题,最长上升子序列 // 对ages和scores排序 // dp[i] -> 选择第i个队员的最大分数 // i ages scores max // 0 1 5 5 // 1 1 5 10 // 2 2 4 4 // 3 2 6 16 // 转移方程 dp[i] = max{ dp[0..i - 1] if not...
true
04bd36872f266b8a56616033d74d0b8363c62add
Rust
josephglanville/roaring-rs
/tests/treemap_intersect_with.rs
UTF-8
2,541
3.109375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate roaring; use roaring::RoaringTreemap; use std::iter::FromIterator; #[test] fn array() { let mut bitmap1 = RoaringTreemap::from_iter(0..2000); let bitmap2 = RoaringTreemap::from_iter(1000..3000); let bitmap3 = RoaringTreemap::from_iter(1000..2000); bitmap1.intersect_with(&bitmap2); a...
true
12f1881132d0a407d3a4de6036eb43cefb23fa76
Rust
jeenuv/aoc2020
/src/aoc07.rs
UTF-8
3,469
3.078125
3
[]
no_license
use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::{BufRead, BufReader}; #[derive(Debug)] struct Rules { ascending: HashMap<String, HashSet<(usize, String)>>, descending: HashMap<String, HashSet<(usize, String)>>, } fn pick_bag_color(iter: &mut dyn Iterator<Item ...
true
b4625e4e0ab580f69ca290bcda7df91ced4aa885
Rust
Andimeo/exercism
/rust/minesweeper/src/lib.rs
UTF-8
1,138
2.796875
3
[]
no_license
pub fn annotate(minefield: &[&str]) -> Vec<String> { if minefield.len() == 0 || minefield[0].len() == 0 { (0..minefield.len()).map(|_| String::from("")).collect() } else { let (n, m) = (minefield.len() as i32, minefield[0].len() as i32); let is_mine = |x, y| { minefield[x as usize].chars...
true
dc86a26dbbe785a9fdbaec6143313412f16e6b3d
Rust
archer884/geopuzzle
/src/lib.rs
UTF-8
1,493
4
4
[]
no_license
// So, the rust code below is broken. You can fix it. You'll need to know basic arithmetic and // maybe a little bit about how to make conditional statements and expressions in rust. I'll give // you an example of those. // // Here's a conditional that changes your name if it happens to be the wrong name: // // if...
true
53123cb26167ecfaeacefb252fdb371da2678493
Rust
jedisct1/wasi-crypto-preview
/implementations/bindings/rust/src/asymmetric_common/keypair.rs
UTF-8
2,827
2.546875
3
[]
no_license
use super::publickey::*; use crate::common::*; use crate::error::*; use crate::raw; #[derive(Debug)] pub(crate) struct KeyPair { pub handle: raw::Keypair, pub alg: &'static str, } impl Drop for KeyPair { fn drop(&mut self) { unsafe { raw::keypair_close(self.handle) }.unwrap() } } impl KeyPair...
true
b0bdf304228ce338de52500f53602a096e29450a
Rust
waonder-rs/magma
/src/mem/buffer/mod.rs
UTF-8
2,344
2.515625
3
[]
no_license
use std::vec::Vec as StdVec; use ash::vk; use crate::resource::Proxy; mod usage; mod unbound; mod bound; mod typed; mod index; pub mod vec; pub use usage::*; pub use unbound::*; pub use bound::*; pub use typed::*; pub use index::*; pub use vec::Vec; /// Buffer. pub unsafe trait Buffer: crate::Resource<Handle=vk::Buf...
true
5a27cf866e7e67a5d9b575e072277f4332b5cb91
Rust
FlorianWilhelm/polars
/polars/polars-lazy/src/physical_plan/expressions/binary_function.rs
UTF-8
1,304
2.515625
3
[ "MIT" ]
permissive
use crate::logical_plan::Context; use crate::physical_plan::state::ExecutionState; use crate::physical_plan::PhysicalAggregation; use crate::prelude::*; use polars_core::prelude::*; use std::sync::Arc; pub(crate) struct BinaryFunctionExpr { pub(crate) input_a: Arc<dyn PhysicalExpr>, pub(crate) input_b: Arc<dyn...
true
371c5ecfd957d2cf51733e66c2502891f1d95744
Rust
Kaikallon/stm32-hal
/src/rtc.rs
UTF-8
32,449
2.90625
3
[ "MIT" ]
permissive
//! Support for the Real Time Clock (RTC) peripheral. //! For more details, see //! [ST AN4759](https:/www.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00226326-using-the-hardware-realtime-clock-rtc-and-the-tamper-management-unit-tamp-with-stm32-microcontrollers-stmicroelectronics.pdf&usg=AOvVaw3PzvL2TfYtwS32fw-Uv37h)...
true
6418ef64fd870bea4ae0cbaafec419be98e139f8
Rust
gcx11/RustyTetris
/src/shapes.rs
UTF-8
5,537
3.1875
3
[]
no_license
use crate::enums::Shape; use num::FromPrimitive; use rand::distributions::Distribution; use rand::distributions::Standard; use rand::Rng; impl Distribution<Shape> for Standard { fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Shape { let shape_variant = rng.gen_range(0, Shape::variant_count()); ...
true
2698648ca6d303d69fd0167652e7ca101f9c9cf5
Rust
nikita-skobov/text-steg
/src/encode.rs
UTF-8
22,416
3.125
3
[ "MIT" ]
permissive
use std::fs; use std::io::{Cursor}; use std::collections::HashMap; use clap::ArgMatches; use rand::{Rng, prelude::StdRng}; use bitstream_io::{BigEndian, BitReader}; use ngrams::Ngram; use rpassword; use super::utils; pub fn generate_ngrams<'a>(text: &'a String, n: usize) -> (HashMap<Vec<&str>, usize>, Vec<&str>, usi...
true
60961136849f4605ac8a92397c698fde70598c97
Rust
wmeints/observatory
/src/server.rs
UTF-8
1,303
2.96875
3
[ "MIT" ]
permissive
use axum::{http::StatusCode, response::IntoResponse, routing::get, Json, Router}; use log::info; use serde::Serialize; #[derive(Serialize)] struct VersionInformation { version: String, } pub async fn run_server(address: &String, port: &i32) -> Result<(), String> { let app = Router::new().route("/version", get...
true
81cd7a736267c26353a5b6b93989712a21bee332
Rust
cmyr/tokio
/examples/udp-codec.rs
UTF-8
2,358
3.15625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! This is a basic example of leveraging `BytesCodec` to create a simple UDP //! client and server which speak a custom protocol. //! //! Here we're using the codec from tokio-io to convert a UDP socket to a stream of //! client messages. These messages are then processed and returned back as a //! new message with a ...
true
ad01b233164e6a5a76a7d0bf635a8526e55cbf47
Rust
arsnazarenko/Rust
/src/collections.rs
UTF-8
6,842
3.5
4
[]
no_license
use core::mem; use std::cmp::max; use std::collections::HashMap; pub fn main() { // VECTOR // Создание, доабвление элементов { let mut c: Vec<i32> = Vec::new(); c.push(1); c.push(2); c.push(3); c.push(4); // Макрос для задания начальных значений вектора ...
true
3bfe4b445d763dcc7d99ca94032fbd332942a737
Rust
kSDOT/automata
/src/tests/create_automata_tests.rs
UTF-8
8,991
2.71875
3
[ "Apache-2.0", "MIT" ]
permissive
#[cfg(test)] pub mod tests { use crate::automata_nfa::*; use crate::connection::*; use crate::automata::*; use std::fs::File; use std::io::Read; pub fn create_automata_1() -> AutomataNFA { let mut automata = AutomataNFA::new(AutomataType::AutomataEClosure); let state0 = aut...
true
240612ead6ae0883df199491da8c0730f4f27317
Rust
Traverse-Research/ash
/ash/src/extensions/khr/ray_tracing_maintenance1.rs
UTF-8
1,348
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::vk; use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_ray_tracing_maintenance1.html> #[derive(Clone)] pub struct RayTracingMaintenance1 { fp: vk::KhrRayTracingMaintenance1Fn, } impl RayTracingMaintenance1 {...
true
932a0c3dd58558d220585ff70c66cdf1c7195286
Rust
gabrielesvelto/api-daemon
/third-party/async-global-executor/src/lib.rs
UTF-8
7,479
3.4375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A global executor built on top of async-executor and async_io //! //! The global executor is lazily spawned on first use. It spawns as many threads //! as the number of cpus by default. You can override this using the //! `ASYNC_GLOBAL_EXECUTOR_THREADS` environment variable. //! //! # Examples //! //! ``` //! # use...
true
b8fcca5e0413ba08aeb8edbcf8bd6e9b4093553e
Rust
robjtede/async-graphql
/src/validation/rules/no_undefined_variables.rs
UTF-8
11,190
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::parser::types::{ ExecutableDocument, FragmentDefinition, FragmentSpread, Name, OperationDefinition, Value, VariableDefinition, }; use crate::validation::utils::{referenced_variables, Scope}; use crate::validation::visitor::{Visitor, VisitorContext}; use crate::{Pos, Positioned}; use std::collections:...
true
3e48f599b17f030bacd048310b83d5cda49be5b9
Rust
mcginty/RustySecrets
/tests/recovery_errors.rs
UTF-8
2,626
2.59375
3
[ "BSD-3-Clause" ]
permissive
extern crate rusty_secrets; use rusty_secrets::{recover_secret}; #[test] #[should_panic(expected = "Not enough shares provided!")] fn test_recover_sellibitze_no_shares() { let shares = vec![]; recover_secret(shares).unwrap(); } #[test] #[should_panic(expected = "Share parse error: Expected 3 parts separated ...
true
c0b170910e33a11301b8ab3f9d5692210d027ac6
Rust
N-SQL/n-sql
/tests/not_expression.rs
UTF-8
370
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) YISH. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. mod common; use common::*; #[test] fn not_equal_comparison(){ test_predicate("nOt(a = 'abc')", "not(a = 'abc')"); } #[test] fn not_logical(){ test_predicate("nOt(a = 'a...
true
346950389d07b0604b02c060f8de7bbb96163077
Rust
wcbeard/alga
/alga/src/general/real.rs
UTF-8
9,432
2.921875
3
[ "Apache-2.0" ]
permissive
use std::any::Any; use num::{Bounded, FromPrimitive, Num, Signed}; use std::{f32, f64}; use std::fmt::{Debug, Display}; use std::ops::{AddAssign, DivAssign, MulAssign, Neg, SubAssign}; use approx::ApproxEq; use general::{Field, Lattice, SubsetOf, SupersetOf}; #[allow(missing_docs)] /// Trait shared by all reals. //...
true
de1eae4bfff4baf589e487499993168f27d9a19b
Rust
marco-c/gecko-dev-wordified
/third_party/rust/tokio/src/io/util/sink.rs
UTF-8
2,196
2.78125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate : : io : : AsyncWrite ; use std : : fmt ; use std : : io ; use std : : pin : : Pin ; use std : : task : : { Context Poll } ; cfg_io_util ! { / / / An async writer which will move data into the void . / / / / / / This struct is generally created by calling [ sink ] [ sink ] . Please / / / see the documentation...
true
dca34d05228975ace62af36c5f2d706ba3e3d93e
Rust
kodsnack/advent_of_code_2019
/tomasskare-rust/day10/src/main.rs
UTF-8
3,973
3.265625
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::collections::HashSet; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; #[derive(Hash, Eq, PartialEq, Debug, Clone)] struct Point { x: i32, y: i32, } fn calc_gcd(m: i32, n: i32) -> i32 { if m == 0 { n.abs() } else { calc_gcd(n %...
true
918809f4991b2ad77df3070723e20573b0ecd3a6
Rust
nisarhassan12/materialize
/src/compute-client/src/plan/interpret/physically_monotonic.rs
UTF-8
10,105
2.515625
3
[ "Apache-2.0", "BSD-2-Clause", "CC0-1.0", "BSD-3-Clause", "MPL-2.0", "0BSD", "PostgreSQL", "GPL-1.0-or-later", "GPL-2.0-only", "MIT", "BUSL-1.1" ]
permissive
// Copyright Materialize, Inc. and contributors. All rights reserved. // // Use of this software is governed by the Business Source License // included in the LICENSE file. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by ...
true
91bf933f5502f8b0252412336ae0256b06f20958
Rust
Magic-zhu/leetcode
/Rust/704.rs
UTF-8
90
2.96875
3
[]
no_license
fn main() { let arr = [1,3,5,7,9]; let left = arr[0]; println!("{}", left); }
true
a3cfad8a4b88b4e4b2b96146bc7e0ea954fe37ad
Rust
alexweav/raytracer
/src/render.rs
UTF-8
2,244
2.609375
3
[ "MIT" ]
permissive
use indicatif::{ProgressBar, ProgressStyle}; use rand::Rng; use crate::camera::Camera; use crate::color::to_color; use crate::hittable::Hittable; use crate::io::Image; use crate::ray::Ray; use crate::scenery::Scenery; use crate::vector::Vector; pub fn render_scenery( scene: Scenery, camera: &Camera, image...
true
54e6e4f5b9241a5950b9581e9d47d21f3b7e308f
Rust
1Password/typeshare
/core/data/tests/can_apply_prefix_correctly/input.rs
UTF-8
376
2.578125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-free-unknown", "MIT" ]
permissive
#[typeshare] pub struct ItemDetailsFieldValue { hello: String, } #[typeshare] #[serde(tag = "t", content = "c")] pub enum AdvancedColors { String(String), Number(i32), NumberArray(Vec<i32>), ReallyCoolType(ItemDetailsFieldValue), ArrayReallyCoolType(Vec<ItemDetailsFieldValue>), DictionaryRe...
true
612543146e5404554ede1d6e4eab5a8e44241c52
Rust
untoldwind/t-rust-less
/lib/src/secrets_store/padding/random_front_back.rs
UTF-8
4,481
3.0625
3
[ "MIT" ]
permissive
use crate::memguard::SecretBytes; use crate::secrets_store::padding::Padding; use crate::secrets_store::{SecretStoreError, SecretStoreResult}; use rand::{thread_rng, RngCore}; use std::io::Write; /// Padding scheme similar to NonZeroPadding without any requirements to the padded /// data. /// /// The outcome of the pa...
true
34386190e46afd16b8c0b5ca6757073f9cf74b60
Rust
inghamn/asteroids
/src/components/renderable.rs
UTF-8
2,802
3.140625
3
[]
no_license
use sdl2::rect::Point; use sdl2::render::{WindowCanvas}; pub const COORD_SCALE: f32 = 1.0; // Ration of arena size to window size pub struct Renderable<'a> { pub direction: f32, // Radians pub shape: &'a [(i8, i8)], pub scale: f32, pub radius: u8 // Arena units } /** * Draw a renderable ont...
true
26d775e66923063533bb0bbc6dc07409212202df
Rust
fantamp/mkrep
/src/read.rs
UTF-8
6,810
2.75
3
[]
no_license
use crate::data::*; use std::cmp::min; use std::collections::HashMap; use std::io::{BufRead, BufReader, Read}; type RawRecord = HashMap<String, String>; type RawFields = Vec<String>; pub fn load_report_from_table<'a, I>( raw_fileds: I, year: u32, week: u8, rcpt: &str, ) -> Result<Report, String> where...
true
a6ebf2bf86b0e217d668d4b8f43ec71b6316742b
Rust
exercism/rust
/exercises/practice/clock/.meta/example.rs
UTF-8
726
3.53125
4
[ "MIT" ]
permissive
use std::fmt; #[derive(Eq, PartialEq, Debug)] pub struct Clock { minutes: i32, } impl fmt::Display for Clock { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let hours = self.minutes / 60; let mins = self.minutes % 60; write!(f, "{:02}:{:02}", hours, mins) } } impl Clock {...
true
50497e77dd6b48b809ef1e513b581e5e770861ad
Rust
tsurai/usbd-audio
/src/channels.rs
UTF-8
4,323
3.328125
3
[]
no_license
use crate::descriptors::*; pub enum SpatialChannel { FrontLeft, FrontRight, FrontCenter, LowFrequencyEffects, BackLeft, BackRight, FrontLeftOfCenter, FrontRightOfCenter, BackCenter, SideLeft, SideRight, TopCenter, TopFrontLeft, TopFrontCenter, TopFrontRight, ...
true
45b82282c8e90004b702e7bd9d690a829e5809c7
Rust
Felerius/findminhs
/src/lower_bound.rs
UTF-8
14,359
2.703125
3
[ "MIT" ]
permissive
use crate::{ create_idx_struct, data_structures::subset_trie::SubsetTrie, instance::{EdgeIdx, Instance, NodeIdx}, report::Settings, small_indices::{IdxHashSet, SmallIdx}, }; use std::iter::Peekable; create_idx_struct!(PackingIdx); pub fn calc_max_degree_bound(instance: &Instance) -> Option<usize> ...
true
6e0d615d83bd356f7d0387e7836d837632ed75a5
Rust
lskatz/fasten
/src/bin/fasten_mutate.rs
UTF-8
3,778
3.21875
3
[ "MIT" ]
permissive
//! Mutates reads. There is no mutation model; only randomness. //! //! # Examples //! //! ``` bash //! cat testdata/four_reads.fastq | fasten_mutate > out.fastq //! ``` //! //! ## Usage //! //! ```text //! //! Usage: fasten_mutate [-h] [-n INT] [-p] [-v] [-s INT] [-m] //! //! Options: //! -h, --help ...
true
36e3031c02b7f7c92150c83d6eca41b0b3ec92b3
Rust
willthames/application-controller
/src/main.rs
UTF-8
6,271
2.671875
3
[]
no_license
use futures::{StreamExt, TryStreamExt, executor::block_on}; use handlebars::Handlebars; use std::path::PathBuf; use std::error::Error; use std::fs; use std::collections::HashMap; use serde::{ Serialize, Deserialize }; use serde_yaml; use kube::{ api::{Api, WatchEvent, PostParams}, Client, runtime::...
true
881f2c83a214e27dcc10c897c3547761e8e8cd3e
Rust
vitiral/strfmt
/src/formatter.rs
UTF-8
11,378
3.1875
3
[ "MIT" ]
permissive
use std::fmt; use std::fmt::Write; use std::iter::Iterator; use std::str; use std::string::String; use types::*; #[derive(Debug, PartialEq)] pub struct Formatter<'a, 'b> { pub key: &'a str, fill: char, align: Alignment, // default Right for numbers, Left for strings sign: Sign, alternate: bool, ...
true
f6441f1d2c5139a6ec11f5186eda7f2aed289417
Rust
harre-orz/rust_ios
/src/lib.rs
UTF-8
2,577
3.296875
3
[]
no_license
use std::io::{Result, Read,Write}; use std::mem; use std::marker::PhantomData; use std::cell::RefCell; use std::rc::Rc; pub trait Sink<Ch: Copy> { fn write(sink: &mut Self, buf: &[Ch]) -> Result<usize>; fn put(sink: &mut Self, ch: Ch) -> Result<()> { let buf = [ch]; let _ = Sink::write(sink, ...
true
cd7522e8522aee8f6f5ee43113abfc3986955a11
Rust
venil7/quotes_api
/src/handlers.rs
UTF-8
1,429
2.734375
3
[]
no_license
use crate::api::Api; use crate::auth_api::ApiClaims; use crate::auth_api::AuthApi; use crate::domain::about::About; use crate::domain::login::{Login, LoginToken}; use crate::domain::period::Period; use actix_web::{web, HttpRequest, HttpResponse, Result}; use serde::Deserialize; use std::convert::TryFrom; #[derive(Dese...
true
20dc1e36dffd79c9169c7dc00eec297e0af489f2
Rust
alex-700/exercism-rust-solutions
/two-bucket/src/lib.rs
UTF-8
2,078
3.4375
3
[]
no_license
use std::collections::hash_map::Entry; use std::collections::{HashMap, VecDeque}; #[derive(PartialEq, Eq, Debug, Clone, Copy)] pub enum Bucket { One, Two, } /// A struct to hold your results in. #[derive(PartialEq, Eq, Debug)] pub struct BucketStats { /// The total number of "moves" it should take to reac...
true
649cfe561334f753ea473e7cfaa1593c1ad96b03
Rust
austinschwartz/rust-rosetta
/src/read_file_specific_line.rs
UTF-8
1,175
3.046875
3
[ "Unlicense", "LicenseRef-scancode-public-domain" ]
permissive
// Implements http://rosettacode.org/wiki/Read_a_specific_line_from_a_file #![feature(old_io)] #![feature(old_path)] use std::old_io::fs::File; use std::old_io::BufferedReader; use std::env::args; use std::borrow::ToOwned; fn main() { let mut args = args(); let filename = { if let Some(o_s) = args.n...
true
8421ad25b05a06aecea03c8326b8e85e31856d9e
Rust
jlajoie/multer-rs
/src/multipart.rs
UTF-8
17,028
2.8125
3
[ "MIT" ]
permissive
use std::sync::Arc; use std::task::{Context, Poll}; use bytes::Bytes; use futures_util::future; use futures_util::stream::{Stream, TryStreamExt}; use spin::mutex::spin::SpinMutex as Mutex; #[cfg(feature = "tokio-io")] use {tokio::io::AsyncRead, tokio_util::io::ReaderStream}; use crate::buffer::StreamBuffer; use crate...
true
832e7d4ac795aeaa25ef9dc6694a88d690bad8f2
Rust
oshunter/fuchsia
/third_party/rust_crates/vendor/async-task/src/lib.rs
UTF-8
4,758
4.21875
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
//! Task abstraction for building executors. //! //! # Spawning //! //! To spawn a future onto an executor, we first need to allocate it on the heap and keep some //! state alongside it. The state indicates whether the future is ready for polling, waiting to be //! woken up, or completed. Such a future is called a *tas...
true
b07143c902685ae6a88bbd919b6857f3e0d3a630
Rust
cdbfoster/saoleile
/saoleile/src/timer/timing_thread.rs
UTF-8
1,813
2.734375
3
[]
no_license
use std::cmp; use std::collections::HashMap; use std::sync::{Arc, mpsc, Mutex}; use std::time::{Duration, Instant}; use crate::timer::TimerData; use crate::timer::timer::{Timer, Wakeup}; pub(super) fn timer_manager_timing_thread( timers: Arc<Mutex<HashMap<usize, TimerData>>>, update_sender: Arc<Mutex<mpsc::Se...
true
583180fd16250776a5c5c83448b3eb34118974b2
Rust
pmaxhogan/rust-learning
/src/main.rs
UTF-8
8,943
3.1875
3
[ "MIT" ]
permissive
use sfml::{ graphics::{Color, RenderTarget, RenderWindow, Shape}, window::{Event, Key, Style}, }; use sfml::graphics::{RectangleShape, Transformable, Text, Font}; use rand::{Rng, SeedableRng}; use rand::rngs::StdRng; use std::collections::HashMap; #[derive(Debug, Copy, Clone)] struct Block{ x: i32, y: ...
true
f583cb1c2337dd903cf3d04429939958e01a91d9
Rust
selatotal/rust-playground
/pickledb_dump/src/structs.rs
UTF-8
955
2.53125
3
[ "MIT" ]
permissive
use serde::{Serialize, Deserialize}; #[derive(Debug, Deserialize, Serialize)] pub struct TakePictureRequest { pub command_id: String, pub device_code: String, pub expiration_datetime: u128, } #[derive(Debug, Clone, Deserialize, Serialize)] pub enum Message { Event(String), Shadow { payload...
true
e6097a877c5ca816a05efeed89de39f84e1d58ef
Rust
archer884/srand
/src/main.rs
UTF-8
2,665
2.734375
3
[ "MIT" ]
permissive
#![feature(box_syntax, io)] extern crate iron; extern crate rand; extern crate "rustc-serialize" as rustc_serialize; use iron::middleware::Handler; use iron::prelude::*; use iron::status; use rand::{ OsRng, Rng }; use rand::distributions::{ IndependentSample, Range }; use rustc_serialize::json; use std::collections::...
true
65237bde1844cf133b8c16f0cf55eb0a61d73711
Rust
rodrigocfd/winsafe
/src/gui/native_controls/tree_view_item.rs
UTF-8
5,499
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::co; use crate::decl::*; use crate::gui::{*, privs::*}; use crate::kernel::privs::*; use crate::msg::*; use crate::prelude::*; /// A single item of a [`TreeView`](crate::gui::TreeView) control. /// /// Each object keeps an unique [`HTREEITEM`](crate::HTREEITEM) handle. /// /// You cannot directly ...
true
c4b944c45111ee5fa8f267557c36c7a81a20fc7b
Rust
Lemon-main/reception
/src/multicore.rs
UTF-8
5,183
2.921875
3
[]
no_license
//! This is an interface for dealing with the kinds of //! parallel computations involved in bellman. It's //! currently just a thin wrapper around CpuPool and //! crossbeam but may be extended in the future to //! allow for various parallelism strategies. extern crate num_cpus; extern crate futures; extern crate cros...
true
b2fd61dd269122d21dd5b0d1be194726ee3d7850
Rust
IThawk/rust-project
/rust-master/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs
UTF-8
608
2.5625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// Test that we are able to introduce a negative constraint that // `MyType: !MyTrait` along with other "fundamental" wrappers. // check-pass // aux-build:coherence_copy_like_lib.rs // revisions: old re #![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_copy_like_lib as lib; struct MyType { x:...
true
fad080019f94b9b9c83b8f39df573a190f7ac329
Rust
bobi-petrov/spiky
/src/resources/map.rs
UTF-8
6,815
2.5625
3
[]
no_license
use amethyst::{ assets::{Asset, Handle, ProcessingState}, core::{math::Vector3, Transform, WithNamed}, ecs::{prelude::World, VecStorage}, error::Error, prelude::{Builder, WorldExt}, renderer::{sprite::SpriteRender, transparent::Transparent}, }; use serde::{Deserialize, Serialize}; use crate::{...
true
9b84312e1b2ec445d8a388f5beee6b3bbc7769dc
Rust
raygon-renderer/SPTiR
/src/sampling/samplers/independent.rs
UTF-8
1,027
3.046875
3
[]
no_license
//! Independent Random Sampler use rand::{Rng, SeedableRng}; use crate::sampling::{Sample1D, Sample2D, SampleDimension1D, SampleDimension2D, Sampler}; /// Independent Random Sampler pub struct IndependentSampler { sample: usize, x: usize, y: usize, rng: rand_xoshiro::Xoroshiro128Plus, } impl Indepen...
true
e25f0b47665843e2f4ed0ef2b1c0590da9f1c0e3
Rust
koehlma/momba
/engine/crates/momba-explore/src/explore/actions.rs
UTF-8
3,464
3.578125
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use serde::{Deserialize, Serialize}; use super::model::*; /// An *action* which is either [*silent*][Action::Silent] or [*labeled*][Action::Labeled]. /// /// An action is either the *silent action* or a *labeled action* instantiated with /// a sequence of values coined *arguments*. /// While action labels are general...
true
bee0eef9746360600e081b58a10d3cc2d97803eb
Rust
leogtzr/rustlearning
/string_slices_1/src/main.rs
UTF-8
341
2.859375
3
[]
no_license
fn main() { let s = String::from("hello world"); let hello = &s[0..5]; let world = &s[6..11]; println!("{}", s); println!("{}", hello); println!("{}", world); let x = String::from("hello"); let slice = &x[..2]; println!("{}", slice); let name = String::from("Leonardo"); let last_3 = &name[3..]; print...
true
d887d088c12edcd7bbb34f03623c56235c97ce30
Rust
MikkelPaulson/advent-of-code-2019
/src/day21/mod.rs
UTF-8
1,672
3.203125
3
[ "MIT" ]
permissive
use super::intcode::Intcode; pub fn part1(input: &str) -> Result<u64, String> { let mut intcode: Intcode = input.parse()?; intcode.input_str( " NOT A J NOT B T OR T J NOT C T OR T J AND D J WALK " .trim_start(), ); intcode.run(); println!("{}", intcode.output_string()); matc...
true
23ad6507bc7a0bf8a9e67c6762955466e6f1b426
Rust
kngwyu/rogue-gym
/core/src/dungeon/field.rs
UTF-8
5,603
3.15625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! General field representation use super::{X, Y}; use num_traits::ToPrimitive; use rect_iter::{Get2D, GetMut2D, IndexError, RectRange}; use std::fmt; use tile::{Drawable, Tile}; use tuple_map::TupleMap2; /// Generic representation of Cell #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize)] pub struct Cell...
true
7fb1e3e0d0c15a056af5fbcef9cfd2af929d28e1
Rust
OceanBelongsToMe/project-rust
/leet-code/src/main.rs
UTF-8
775
3.15625
3
[]
no_license
use leet_code::fibonacci; // use std::io; fn main() { println!("Please input your guess."); // let mut guess = String::new(); // io::stdin() // .read_line(&mut guess) // .expect("Failed to read line"); // guess.push_str("184"); // let guess: usize = guess.trim().parse().ex...
true
1a233756179899947707710b88cf1db0fe81d70d
Rust
chessbr/rust-exchange
/matching-engine/src/cli.rs
UTF-8
1,797
3.203125
3
[]
no_license
use std::env; use std::io; mod engine; use engine::{MatchingEngine, OrderType, OrderResult}; fn main() { let args: Vec<String> = env::args().collect(); if args.len() != 2 { println!("It is missing the asset code from your command."); return; } let asset: &String = &args[1]; prin...
true
0e71b087e4591a42cab230fe71dc43da06d5d98c
Rust
sebas642/the-ray-tracer-challenge-rust
/src/ppm.rs
UTF-8
3,330
3.375
3
[ "MIT" ]
permissive
use super::canvas::*; const MAX_COLOR_VALUE: i32 = 255; const MAX_PIXELS_PER_LINE: usize = 5; fn clamp(value: i32, min: i32, max: i32) -> i32 { if value < min { return min; } if value > max { return max; } value } fn as_rgb255(color: f64) -> i32 { let color255 = (color * MAX...
true
9cf89cec47bea8ec326af620c1251da17a0cede0
Rust
isghe/rgb
/src/entities/proofs/header.rs
UTF-8
4,207
2.59375
3
[]
no_license
use bitcoin::blockdata::transaction::TxOutRef; use entities::proofs::Proof; use entities::rgb_output::RgbOutput; use entities::traits::Verify; use std::collections::{HashMap, HashSet}; use bitcoin::blockdata::transaction::Transaction; use util::error::Error::{MissingTx, LoopDetected}; use util; use bitcoin::network::se...
true
e00a75cbf51f546aa32d96be54d38717e1789236
Rust
V1nc3ntL/itwTraining
/dataStructure/binary_tree/src/node.rs
UTF-8
347
2.890625
3
[]
no_license
#[derive (Debug)] enum Op<T>{ Go, Stop, Val(T) } struct Node<T>{ l : Option<Box<Node<T>>>, r : Option<Box<Node<T>>>, op : Op<T>, } impl Node<bool>{ pub fn new(op: Op<bool>, l: Node<bool>,r: Node<bool> )-> Self{ Node::<bool>{ op, l : Some(Box::new(l)), r : Some(...
true
15732445fd34b0abddd6c28d052de9eee79d3c97
Rust
Atul9/crush
/src/lang/serialization/table_serializer.rs
UTF-8
3,464
2.9375
3
[ "MIT" ]
permissive
use crate::lang::serialization::{Serializable, DeserializationState, SerializationState}; use crate::lang::errors::{CrushResult, error}; use crate::lang::serialization::model::{Element, element}; use crate::lang::serialization::model; use crate::lang::value::{ValueType, Value}; use crate::lang::table::{ColumnType, Row,...
true
c106978306ffecc3f1a726ded1f7c4ef1231227c
Rust
quark-zju/wezterm
/wezterm-gui/src/commands.rs
UTF-8
79,514
2.984375
3
[ "OFL-1.1", "MIT" ]
permissive
use crate::inputmap::InputMap; use config::keyassignment::*; use config::{ConfigHandle, DeferredKeyCode}; use mux::domain::DomainState; use mux::Mux; use ordered_float::NotNan; use std::borrow::Cow; use std::cmp::Ordering; use std::convert::TryFrom; use window::{KeyCode, Modifiers}; use KeyAssignment::*; /// Describes...
true
279ff70916127f2feba798add186358c12a189a8
Rust
bjrnt/fractals
/src/animation.rs
UTF-8
2,636
2.9375
3
[]
no_license
extern crate rayon; extern crate image; use rayon::prelude::*; use mandelbrot::Mandelbrot; use OUTPUT_DIRECTORY; use std::path::Path; use std::fs::canonicalize; use std::process::Command; pub enum Easing { Linear, QuadraticIn, } pub struct Animation { start_translation: (f32, f32), end_translation: (...
true
d0751e83b7d66508d5d2c277b8d1e7568c466374
Rust
nao-kobayashi/tokio_tutorials
/tokio_stream/src/main.rs
UTF-8
1,650
3.140625
3
[]
no_license
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::time::{Duration, Instant}; use tokio_stream::{Stream, StreamExt}; struct Delay { when: Instant, } impl Future for Delay { type Output = &'static str; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<&'static s...
true
2dde8be28ef8579307839e37d7b734ad301262a5
Rust
rossdylan/bobbytables
/src/iter.rs
UTF-8
1,399
2.921875
3
[ "MIT" ]
permissive
use std::sync::atomic::Ordering; use ::key::{hashkey_to_string}; use ::table::*; use ::state::SlotState; pub struct CounterIter<'a> { pub slots: &'a VectorTable, pub index: usize, } impl<'a> Iterator for CounterIter<'a> { type Item = (String, usize); fn next(&mut self) -> Option<Self::Item> { ...
true
f85aab856602e3baac634ab7e874d0672bf32aa9
Rust
seveneightn9ne/crb
/src/graphics.rs
UTF-8
1,828
3.046875
3
[ "MIT" ]
permissive
use rustbox; use rustbox::{RustBox, Color}; use window::Window; use buffer::Symbol; pub fn render(rb: &RustBox, window: &Window) { // Write file name to top bar rb.print(window.topleft.x as usize, window.topleft.y as usize, rustbox::RB_NORMAL, Color::Black, ...
true
bd6ce09f727c46edb047968c8de8e348716c52fd
Rust
rhorrace/exercism
/rust/paasio/src/lib.rs
UTF-8
2,169
3.0625
3
[]
no_license
use std::io::{Read, Result, Write}; pub struct ReadStats<R> { buffer: R, n_bytes: usize, n_reads: usize, } impl<R: Read> ReadStats<R> { // _wrapped is ignored because R is not bounded on Debug or Display and therefore // can't be passed through format!(). For actual implementation you will likely ...
true
e3326d261a4ae2289b297ac23b0db352a314133a
Rust
critiqjo/binary-tree
/src/count.rs
UTF-8
27,601
3.265625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Counting tree implementation. //! //! ## When should you use `CountTree`? //! //! - You want to maintain a possibly large unsorted list. //! - You want to access, modify, insert, and delete elements at arbitrary //! position with O(log(n)) time complexity. //! - You can tolerate O(n log(n)) time-complexity for (n...
true
701dd968eefc076932d0975d38d1941a911b0501
Rust
sym233/leetcode_problems
/96. Unique Binary Search Trees/96. Unique Binary Search Trees.rs
UTF-8
462
3.046875
3
[]
no_license
impl Solution { pub fn num_trees(n: i32) -> i32 { let n = n as usize; let mut table = vec![0; n + 1]; table[0] = 1; for total_number_of_nodes in 1..=n { for left_tree_nodes in 0..total_number_of_nodes { table[total_number_of_nodes] += ...
true
5362bc455a2415bf4f6b86051d013e32d71513f5
Rust
Ray-Eldath/TestDriver
/src/lib.rs
UTF-8
2,889
2.78125
3
[]
no_license
extern crate proc_macro; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::{quote, TokenStreamExt}; use syn::{Expr, parse_macro_input, Token, Type}; use syn::parse::{Parse, ParseStream}; use syn::punctuated::Punctuated; use crate::assertion::{Assert, Assertion}; mod assertion; mod keyword { ...
true
1e4f1ddf9dab4779985c777684b7198230085b2d
Rust
voidumbrella/advent_of_code_2019
/src/day08.rs
UTF-8
1,581
3.203125
3
[]
no_license
/* * Advent of Code 2019 Day 8 * * Space Image Format * * Remarks: * Eh. */ const WIDTH: usize = 25; const HEIGHT: usize = 6; #[aoc_generator(day8)] fn parse(input: &str) -> Vec<String> { input.as_bytes() .chunks(WIDTH * HEIGHT) .map(|s| { String::from_utf8(s.to_vec()).unwrap() }) ...
true
29aa911a44af39b9ddaa6a2eeafd1a1a06bbea67
Rust
nathanielsimard/cs-game-rust
/singer/src/singer.rs
UTF-8
353
3.515625
4
[]
no_license
pub struct Person { can_sing: bool, } pub fn new(can_sing: bool) -> Person { Person { can_sing: can_sing } } impl Person { pub fn sing(&self) -> String { if self.can_sing { return String::from("Let's get schwifty in here !"); } else { return String::from("Baby Baby ...
true
0a2ce52abfcd003da7fd976f5909bd86099baa6f
Rust
TrionProg/client
/src/render/pipelines/vertices.rs
UTF-8
426
2.609375
3
[]
no_license
use location::{Pos2D,Pos3D}; gfx_defines! { vertex P3N3TcVertex { pos: [f32; 3] = "a_pos", normal: [f32; 3] = "a_normal", uv: [f32; 2] = "a_uv", } } impl P3N3TcVertex { pub fn new(pos:Pos3D, normal:Pos2D, uv:Pos2D) -> Self { P3N3TcVertex { pos: [pos.x, pos.y, p...
true
43079b699e021cae73cf2976523f2d25b9c21198
Rust
ccojocar/rusty-hog
/src/lib.rs
UTF-8
49,228
3.1875
3
[ "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
//! # Rusty Hogs //! //! Rusty Hogs is a Rust crate to perform secret scanning across various data sources. It is split //! into two parts: //! 1. A library - Secret Scanner - that runs a set of regular expressions against a byte array //! and returns a set of matches //! 2. A set of binaries - * Hog - that uses the se...
true
a955db6bda98fddcff3e7e447df18b2fb6115440
Rust
lenscas/glitch_dungeon
/src/grid/grid.rs
UTF-8
5,628
3
3
[ "MIT" ]
permissive
use crate::grid::{Dir, Tile}; use crate::gun::Gun; use quicksilver::graphics::Font; use quicksilver::graphics::FontStyle; use quicksilver::Result; use rand::Rng; use std::collections::HashMap; pub struct Grid { pub tiles: Vec<Tile>, pub length: usize, pub height: usize, pub start: (usize, usize), } im...
true
a1c6e39d8bbd07b18ba51445a29eff71e6860bf5
Rust
dalance/procs
/src/term_info.rs
UTF-8
3,201
2.8125
3
[ "MIT" ]
permissive
use anyhow::Error; use console::Term; use minus::input::{self, HashedEventRegister, InputEvent}; use minus::Pager; use std::cell::RefCell; use std::fmt::Write; pub struct TermInfo { term: Term, pub pager: RefCell<Option<Pager>>, pub height: usize, pub width: usize, pub clear_by_line: bool, pub ...
true
b66c7acd3a3069f378f670629176491f96ad9ed8
Rust
tacgomes/advent-of-code-2020
/06/main.rs
UTF-8
2,177
3.5625
4
[ "MIT" ]
permissive
use std::env; use std::fs; use std::path::Path; use std::process; const NUM_QUESTIONS: usize = 26; // NB: another way to tackle this problem would be to use set union and // set intersection to solve part 1 and part 2. However, as the max size // of the results is fixed (26), it does not provide advantages. fn char_...
true
951ff4f03499d55354bc87ac472a875cefae8552
Rust
async-rs/futures-timer
/src/native/timer.rs
UTF-8
11,436
3.109375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::fmt; use std::mem; use std::pin::Pin; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::SeqCst; use std::sync::{Arc, Mutex, Weak}; use std::task::{Context, Poll}; use std::time::Instant; use std::future::Future; use super::AtomicWaker; use super::{global, ArcList, Heap, HeapTimer, Node, Sl...
true
123a1ea71244414174b0ce7c36ca731e1fc7030f
Rust
hzkazmi/Batch6_34_Quarter1
/June_21_2020/fileRead/src/main.rs
UTF-8
642
3.421875
3
[]
no_license
use std::fs::File; // use std::io; // use std::io::Read; use std::io::{self,Read}; fn read_from_file() -> Result<String, io::Error> { let mut f = File::open("hello.txt")?; let mut s = String::new(); f.read_to_string(&mut s)?; Ok(s) // let f = File::open("hello.txt"); // let mut path = m...
true
d21ac607e53464ba8ef82738f9a6e48489a54a2b
Rust
davethecanuck/rust-poly-logger
/src/poly_logger.rs
UTF-8
3,384
3.609375
4
[]
no_license
use log::{Level, SetLoggerError, MetadataBuilder}; use std::fmt; /// Implements a super-logger that can redirect to other loggers /// /// This is useful if you want to log some messages to STDERR or /// STDOUT and some to File in perhaps a different format. When /// using PolyLogger, you create any number of child l...
true
39175f07551aceb7d8b9e1e152593fd658bac3b8
Rust
rust-osdev/bootloader
/bios/stage-4/src/memory_descriptor.rs
UTF-8
962
2.546875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use bootloader_api::info::MemoryRegionKind; use bootloader_x86_64_bios_common::E820MemoryRegion; use bootloader_x86_64_common::legacy_memory_region::LegacyMemoryRegion; use x86_64::PhysAddr; impl LegacyMemoryRegion for MemoryRegion { fn start(&self) -> PhysAddr { PhysAddr::new(self.0.start_addr) } ...
true
70dfb474cc49124fd1d2e82ad0084864b617ac7b
Rust
garretthunyadi/rust_scratchpad
/src/iterator_impl_1.rs
UTF-8
1,125
3.90625
4
[]
no_license
pub fn main() -> std::io::Result<()> { println!("iterator_impl_1"); // desired behavior let mut c = Counter::new(); print!("{} ", c.next().unwrap()); print!("{} ", c.next().unwrap()); print!("{} ", c.next().unwrap()); // Note that this example of creating a // struct via it's internals...
true
cd3e1586c23374824e6c88fb63d048deb6e71aac
Rust
nestorsgarzonc/Solutions-of-the-Rust-programming-language-book
/variables/src/main.rs
UTF-8
171
3.328125
3
[]
no_license
fn main() { println!("Hello, muttable! 😏"); let mut x: i32 = 5; println!("The value of x is {}", x); x = 10; println!("The value of x is {}", x); }
true
45df1ad02670885614520ff1ea303f600603ec8f
Rust
l1h3r/did_url
/src/did.rs
UTF-8
11,107
2.796875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[cfg(feature = "alloc")] use alloc::string::String; #[cfg(feature = "alloc")] use alloc::string::ToString as _; use core::cmp::Ordering; use core::convert::TryFrom; use core::fmt::Debug; use core::fmt::Display; use core::fmt::Formatter; use core::fmt::Result as FmtResult; use core::hash::Hash; use core::hash::Hasher; ...
true
88107d4fdee9269c682acc3ba916ae74b7d079dd
Rust
0xProject/sutro
/src/chain/types/rpc/value_or_array.rs
UTF-8
2,533
3.0625
3
[ "MIT" ]
permissive
use crate::prelude::*; use smallvec::{smallvec, SmallVec}; use std::iter::FromIterator; #[derive(Default, Debug, PartialEq, Clone, Serialize, Deserialize)] #[serde(from = "Representation<T>", into = "Representation<T>")] pub struct ValueOrArray<T: Clone>(SmallVec<[T; 1]>); impl<T: Clone> From<T> for ValueOrArray<T> {...
true
ecb592c54cc8f59c82fed564e0f24254fb0d3494
Rust
djeedai/weldr
/bin/weldr/src/gltf.rs
UTF-8
9,654
2.84375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! GLTF writer. #![allow(dead_code)] use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use std::collections::HashMap; #[derive(Serialize, Deserialize)] pub struct Gltf { pub asset: Asset, #[serde(skip_serializing_if = "Vec::is_empty")] pub nodes: Vec<Node>, #...
true
3cba94739e20513508ac6538b663ceca7366183f
Rust
zhao1jin4/vscode_rust_workspace
/cargo_projects/mytest/tests/integration_test.rs
UTF-8
603
2.859375
3
[]
no_license
//集成测试,需要在项目根目录创建一个 tests 目录,与 src 同级,Cargo 会将每一个文件当作单独的 crate 来编译 //也是用cargo test 运行,有三部分:单元测试、集成测试和文档测试 //cargo test --test integration_test ,只集成测试,参数是文件名 use mytest;//项目名,tomal文件中的name的值 #[test] fn it_adds_two() { assert_eq!(4, mytest::add_two(2)); } mod common; //模块声明 #[test] fn it_adds_two2() { common:...
true
47f768e2a204f8e1266b66cde33c5235f901eaed
Rust
pdhborges/advent-of-code-2020
/day-07/src/main.rs
UTF-8
2,928
3.15625
3
[ "MIT" ]
permissive
use regex::Regex; use std::collections::{HashMap, HashSet, VecDeque}; use std::error::Error; use std::io::{self, Read, Write}; use std::result; type Result<T> = result::Result<T, Box<dyn Error>>; fn reachable(source: &str, graph: &HashMap<&str, HashSet<&str>>) -> usize { let mut visited: HashSet<&str> = HashSet::...
true
880dfae826478c5bb5d2be867d422cd6965ae69b
Rust
Nikita-str/first-order-logic
/src/logic/terms.rs
UTF-8
7,804
3.015625
3
[]
no_license
use std::{cell::{Ref, RefCell}, fmt, rc::Rc}; use crate::common::{deep_copy::DeepCopy, name::Name}; #[derive(PartialEq, Eq, Clone, Debug, PartialOrd)] pub struct ConstTerm<N: Name>{ pub name: N } impl<N: Name> ConstTerm<N>{ pub fn get_name(&self) -> &N { &self.name } } #[derive(PartialEq, Eq, Hash, Clone, Deb...
true
a23751863103048e3f442de3a4bea6388c024b14
Rust
RodionKovalenko/rustCrates
/src/neural_networks/utils/matrix.rs
UTF-8
7,873
3.03125
3
[]
no_license
use std::fmt::Debug; use std::ops::{Mul, AddAssign, Sub, Add}; pub fn multiple(matrix_a: &Vec<Vec<f64>>, matrix_b: &Vec<Vec<f64>>) -> Vec<Vec<f64>> { let num_rows = matrix_a.len(); let mut num_columns = matrix_b[0].len(); let matrix_a_clone = matrix_a.clone(); let mut matrix_b_clone = m...
true
491225307b55ee737754027fb2714d9ae137bcc9
Rust
casey/just
/src/lexer.rs
UTF-8
47,082
3.328125
3
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
use {super::*, CompileErrorKind::*, TokenKind::*}; /// Just language lexer /// /// The lexer proceeds character-by-character, as opposed to using regular /// expressions to lex tokens or semi-tokens at a time. As a result, it is /// verbose and straightforward. Just used to have a regex-based lexer, which /// was slow...
true
58d3770e46fa2746a12fe7051b0cf0870c6586e2
Rust
jensecj/code-challenges
/advent-of-code-2018/03/app/src/main.rs
UTF-8
3,354
3.34375
3
[]
no_license
extern crate regex; use std::collections::HashMap; use std::error::Error; use std::io; use std::io::prelude::*; use std::result; use regex::Regex; macro_rules! err { ($($tt:tt)*) => { Err(Box::<Error>::from(format!($($tt)*))) } } type Result<T> = result::Result<T, Box<Error>>; type Grid = HashMap<(u32, u32), u3...
true
d948eb607e3e931a277cccbc1419c5f97a11ac23
Rust
hgzimmerman/HLWNPA
/src/std_functions.rs
UTF-8
2,914
3
3
[]
no_license
use std::collections::HashMap; use ast::{Ast, SExpression, Datatype, TypeInfo, VariableStore}; use parser::program; use std::rc::Rc; use nom::IResult; pub fn add_std_functions(map: &mut HashMap<String, Rc<Datatype>>) { add_print_function(map); add_println_function(map); } fn add_print_function(map: &mut Va...
true
4ee0781930718e629364ee38e2679e54c36d9338
Rust
TurboCartPig/pathtracer
/src/textures.rs
UTF-8
931
3.25
3
[]
no_license
use glam::{vec3, Vec3}; use image::RgbImage; pub trait Texture { fn value(&self, u: f32, v: f32) -> Vec3; } /// A texture with a constant uniform color pub struct UniformTexture { color: Vec3, } impl UniformTexture { pub fn new(color: Vec3) -> Self { Self { color } } } impl Texture for Unifo...
true
939cea514be00c5fb55bb61c9cec907fb181d09f
Rust
simonhaisz/code-emoji-cli
/examples/fibonacci.rs
UTF-8
427
3.296875
3
[ "MIT" ]
permissive
fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 1 { panic!("Must provide number for fibonacci sequence"); } let n = &args[0].parse::<i32>().unwrap(); println!("{}", fibonacci(n)); } fn fibonacci(n: i32) -> i32 { if n <= 0 { panic!("Must provide a positive number for fibonacci seque...
true
d8d0588704581ab18ff06037261f1eb0ba7fdbb2
Rust
MattesWhite/sophia_rs
/api/src/graph/_ext_impl.rs
UTF-8
5,927
2.609375
3
[ "CECILL-B", "LicenseRef-scancode-cecill-b-en" ]
permissive
// this module is transparently re-exported by its parent `graph` // It defines implementation of Graph and MutableGraph for existing types. use std::collections::HashSet; use std::convert::Infallible; use std::hash::{BuildHasher, Hash}; use resiter::oks::*; use super::*; use crate::term::{term_eq, CopiableTerm, Cop...
true