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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
64495d5e01f0884b7008c5fab05ebb34b387df9b | Rust | orborde/adventofcode | /2020/day2/part1/src/main.rs | UTF-8 | 2,137 | 3.15625 | 3 | [] | no_license | use std::error::Error;
use std::str::FromStr;
use std::collections::HashSet;
use std::io::{self, BufRead, BufReader};
use std::fs::File;
use std::path::Path;
#[macro_use]
extern crate simple_error;
struct Policy {
min: usize, max: usize,
letter: char,
}
impl FromStr for Policy {
type Err = Box<dyn Error>... | true |
997f0e444d24c45bf43ca5ec583be631852dfd94 | Rust | GraphiteEditor/Graphite | /libraries/bezier-rs/src/bezier/lookup.rs | UTF-8 | 11,433 | 3.09375 | 3 | [
"Apache-2.0",
"MIT",
"ISC",
"BSL-1.0",
"BSD-2-Clause",
"MPL-2.0",
"Unicode-DFS-2016",
"BSD-3-Clause",
"CC0-1.0"
] | permissive | use crate::utils::{f64_compare, TValue, TValueType};
use super::*;
/// Functionality relating to looking up properties of the `Bezier` or points along the `Bezier`.
impl Bezier {
/// Convert a euclidean distance ratio along the `Bezier` curve to a parametric `t`-value.
pub fn euclidean_to_parametric(&self, ratio: f... | true |
b6341dc3e8bc600f48c332eacd0d607fb7dafdfa | Rust | krgn/bufr | /src/traited/mgr.rs | UTF-8 | 580 | 2.8125 | 3 | [] | no_license | use super::Queuable;
pub struct Mgr<T>
where
T: Queuable + Default,
{
pub buffers: T,
}
impl<T> Mgr<T>
where
T: Queuable + Default,
{
pub fn new() -> Mgr<T> {
let buffers = T::default();
Mgr { buffers }
}
}
#[cfg(test)]
mod tests {
use crate::traited::*;
#[test]
fn b... | true |
a829017d4e7eae694945a327eca6c082de9e972b | Rust | biaoma-ty/arrow-datafusion | /datafusion/physical-expr/src/scalar_function.rs | UTF-8 | 5,681 | 2.546875 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
5cff6efe1d99a1ed32e4c9761fd575fbf3609a42 | Rust | ZodiacalComet/fimfic-tracker | /cli/src/subcommands/untrack.rs | UTF-8 | 881 | 2.59375 | 3 | [
"Unlicense"
] | permissive | use console::style;
use fimfic_tracker::StoryData;
use crate::args::Untrack;
pub fn untrack(story_data: &mut StoryData, Untrack { ref ids }: Untrack) {
for id in ids {
match story_data.shift_remove(id) {
Some(story) => info!("{} untracked", format_story!(story)),
None => warn!(
... | true |
378693efc4d2dcec0a603c86feb739b92ee08072 | Rust | Mundo-enfermo-y-triste/elliptic-curves | /p256/src/arithmetic/scalar.rs | UTF-8 | 3,954 | 3.125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Scalar field arithmetic.
use core::convert::TryInto;
use elliptic_curve::subtle::{Choice, ConditionallySelectable, CtOption};
#[cfg(feature = "zeroize")]
use zeroize::Zeroize;
use crate::{arithmetic::util::sbb, SecretKey};
/// The number of 64-bit limbs used to represent a [`Scalar`].
const LIMBS: usize = 4;
/... | true |
ba02cc688c3b842fdcdee1d4a0964c944e7b0a0f | Rust | AtomicInteger/one_more_dstruct | /src/tree/tree_node.rs | UTF-8 | 6,195 | 3.546875 | 4 | [
"MIT"
] | permissive | use tree::tree::Tree;
#[derive(Debug, Clone, PartialEq)]
pub struct TreeNode<T> {
value: T,
children: Vec<TreeNode<T>>,
}
impl<T: PartialEq + Clone> TreeNode<T> {
pub fn get_value(&self) -> &T {
&self.value
}
pub fn get_children(&self) -> &Vec<TreeNode<T>> {
&self.children
}
... | true |
e9fc8ae965ed470651026d8a1560cc7fa5526054 | Rust | cedric-h/sqlx | /sqlx-core/src/sqlite/statement/worker.rs | UTF-8 | 5,943 | 2.96875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use either::Either;
use libsqlite3_sys::{sqlite3_step, SQLITE_DONE, SQLITE_ROW};
use crate::error::Error;
use crate::sqlite::statement::StatementHandle;
#[cfg(not(feature = "runtime-tokio"))]
use {
libsqlite3_sys::sqlite3_stmt,
sqlx_rt::yield_now,
std::ptr::null_mut,
std::sync::atomic::{spin_loop_hint... | true |
3215d2739c78ff1d76bc4c4357c01e4cf288e54f | Rust | tristan/adventofcode2015 | /src/day_19.rs | UTF-8 | 2,185 | 3.1875 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::{HashMap, HashSet};
fn main() {
let mut transforms: HashMap<String, Vec<String>> = HashMap::new();
let source = BufReader::new(File::open("day_19_input.txt").unwrap())
.lines().filter_map(Result::ok).filter(|line| line.len() > ... | true |
1818da6b52787a8e5560b62dcc2ea81a9ddf4af5 | Rust | spector-in-london/veriwasm | /src/lattices/regslattice.rs | UTF-8 | 7,782 | 2.734375 | 3 | [
"MIT"
] | permissive | use std::cmp::Ordering;
use std::collections::HashMap;
use std::convert::TryFrom;
use crate::ir::types::{ValSize, X86Regs};
use crate::lattices::reachingdefslattice::LocIdx;
use crate::lattices::{Lattice, VarSlot};
use X86Regs::*;
#[derive(Default, PartialEq, Eq, Clone, Debug)]
pub struct X86RegsLattice<T> {
pub... | true |
e9fe199e22e5abd84c65c2bc51ed9ea3cb34a8da | Rust | memorysafety/sudo-rs | /test-framework/sudo-compliance-tests/src/visudo/flag_owner.rs | UTF-8 | 2,564 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use sudo_test::{Command, Env, TextFile};
use crate::{
visudo::{CHMOD_EXEC, DEFAULT_EDITOR, EDITOR_TRUE, ETC_SUDOERS, TMP_SUDOERS},
Result, USERNAME,
};
#[test]
fn when_present_changes_ownership_of_existing_file() -> Result<()> {
let file_path = TMP_SUDOERS;
let env = Env("")
.file(file_path, T... | true |
5c748db8e4c11f633c65520ac80f9794dea1010f | Rust | likr/atcoder | /abc169/src/bin/c.rs | UTF-8 | 691 | 2.53125 | 3 | [] | no_license | use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;
#[... | true |
2a7dfc2a3bd51d20dce150f82e16c2d25e7e01ff | Rust | h4hany/leetcode | /python_solutions/1441.build-an-array-with-stack-operations.rs | UTF-8 | 6,105 | 3.3125 | 3 | [] | no_license | /*
* @lc app=leetcode id=1441 lang=rust
*
* [1441] Build an Array With Stack Operations
*
* https://leetcode.com/problems/build-an-array-with-stack-operations/description/
*
* algorithms
* Easy (68.07%)
* Total Accepted: 6.6K
* Total Submissions: 9.7K
* Testcase Example: '[1,3]\r\n3\r'
*
* Given an arr... | true |
a6badbba824df16be68165b842aefb96962a5940 | Rust | ircubic/AoC2020 | /src/utils.rs | UTF-8 | 1,864 | 3.453125 | 3 | [] | no_license | use std::io::{self, BufRead, Lines, BufReader};
use std::fs::File;
use std::path::Path;
pub fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>
{
let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines())
}
pub fn read_numbers_from_lines<P>(filename: P) -... | true |
db0024878a734a27cfb92b022ed7762ccd433ba9 | Rust | kylegalloway/docker-talk | /rust/src/counter.rs | UTF-8 | 503 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::sync::atomic::{AtomicIsize, Ordering};
pub struct Counter(AtomicIsize);
impl Counter {
pub fn new(init: isize) -> Counter {
Counter(AtomicIsize::new(init))
}
pub fn increment(&self) -> isize {
let old = self.0.fetch_add(1, Ordering::SeqCst);
old + 1
}
pub fn decr... | true |
bf3ff01d3bc60283e71e73b261f0a1ccc6a70ddf | Rust | seanchen1991/vecdraw | /examples/manylines.rs | UTF-8 | 1,483 | 2.78125 | 3 | [] | no_license | use clap::Clap;
use palette::Srgb;
use rand::Rng;
use vecdraw::{run_event_loop, Color, DrawContext, Layer, Line, LinesLayer, LinesLayerDrawable};
const EXTENT: f32 = 10000.;
const MAX_LEN: f32 = 1000.;
#[derive(Clap)]
struct Opts {
#[clap(default_value = "10000")]
lines: u32,
}
struct ManyLines(u32);
fn ran... | true |
a91b30fd87db0095e5a8ed313db748351854eb2c | Rust | smilinhawaiian/Exercism | /leap/src/lib.rs | UTF-8 | 401 | 3.28125 | 3 | [] | no_license | pub fn is_leap_year(year: u64) -> bool {
let mut is_leap = false;
if year % 4 == 0 {
// year is leap year if evenly divisible by 4
if year % 100 == 0 && year % 400 != 0 {
// except each year evenly divisible by 100
is_leap = false;
} else {
// unless e... | true |
47df7b952742a876bc6ed1a5d75d2d1a57d9ed70 | Rust | ajiyoshi-vg/parser | /src/combinator.rs | UTF-8 | 3,635 | 2.96875 | 3 | [] | no_license | use super::parser::{parser, ParseError, Parser};
pub fn lazy<T, F>(f: F) -> Parser<T>
where
T: 'static,
F: Fn() -> Parser<T> + 'static,
{
parser(move |s| f().parse(s))
}
pub fn many<T>(p: Parser<T>) -> Parser<Vec<T>>
where
T: 'static
{
parser(move |s| {
let mut ret = Vec::new();
wh... | true |
f9db29f968bde59e998ef2d5a78543cfedb21fbb | Rust | magurotuna/leetcode-rust | /src/bin/1381.rs | UTF-8 | 1,916 | 3.921875 | 4 | [] | no_license | #[derive(Debug)]
struct CustomStack {
max_size: usize,
stack: Vec<i32>,
}
/**
* `&self` means the method takes an immutable reference.
* If you need a mutable reference, change it to `&mut self` instead.
*/
impl CustomStack {
fn new(maxSize: i32) -> Self {
Self {
max_size: maxSize as... | true |
c72f41398ffe782aa2fb365abe549d75729606c0 | Rust | jeffanddom/manchester-wasm | /rs/src/renderer/shader.rs | UTF-8 | 2,537 | 3.046875 | 3 | [] | no_license | use std::collections::HashMap;
use web_sys::{WebGl2RenderingContext, WebGlProgram, WebGlShader, WebGlUniformLocation};
pub struct Shader {
pub program: WebGlProgram,
pub uniforms: HashMap<String, WebGlUniformLocation>,
}
pub enum Attrib {
Position,
Color,
}
impl Shader {
pub fn new(
conte... | true |
20252e4fae6d15f5f2b90d7edf568b146e4b1eeb | Rust | tobratland/learning-to-fly | /libs/simulation/src/brain.rs | UTF-8 | 908 | 2.609375 | 3 | [] | no_license | use crate::*;
#[derive(Debug)]
pub struct Brain {
crate nn: nn::Network,
}
impl Brain {
pub fn random(rng: &mut dyn RngCore, eye: &Eye) -> Self {
Self {
nn: nn::Network::random(rng, &Self::topology(eye)),
}
}
crate fn as_chromosome(&self) -> ga::Chromosome {
self.n... | true |
10ed576fbed44b62dbaffc006ef4f242c5c8da1a | Rust | psinghal20/ockam | /implementations/rust/ockam/ockam_transport_websocket/examples/client.rs | UTF-8 | 1,584 | 2.53125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use futures_util::StreamExt;
use ockam_core::{Result, Route};
use ockam_node::Context;
use ockam_transport_websocket::{WebSocketTransport, TCP};
use tokio::io::AsyncReadExt;
fn main() -> Result<()> {
let (ctx, mut executor) = ockam_node::start_node();
executor.execute(async move {
run_main(ctx).await.u... | true |
6e3e9a508e4cb13173b813deee29906b20680e54 | Rust | karl-zylinski/Hollobock | /entity/enemy_spawner.rs | UTF-8 | 2,145 | 2.75 | 3 | [] | no_license | use rsfml::system::Vector2f;
use rsfml::graphics::RenderWindow;
use input::Input;
use std::rand;
use std::rand::Rng;
use entity::world::World;
use entity::Enemy;
use entity::enemy::EnemyStruct;
use entity::EnemySpawner;
use entity::{Entity, EntityUpdateResult};
use entity::renderer::Renderer;
use entity::EntityTrait;
... | true |
fbca6a77d463fa5f51da34e9786f1efa5543b790 | Rust | CarloMicieli/trenako | /crates/data/src/catalog/brands/row_converters.rs | UTF-8 | 12,350 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use crate::catalog::brands::brand_row::BrandRow;
use catalog::brands::brand::Brand;
use common::address::{Address, AddressBuilder};
use common::contacts::ContactInformation;
use common::localized_text::LocalizedText;
use common::metadata::Metadata;
use common::queries::converters::{ConversionErrors, Converter, OptionCo... | true |
0d09a74d018d5bc020d4e268785bab5bc21d11d9 | Rust | kkress/adventofcode-2015 | /11/src/main.rs | UTF-8 | 3,750 | 3.40625 | 3 | [
"MIT"
] | permissive |
fn increment(c: char) -> char {
let max = 'z' as u8;
let inc = c as u8 + 1;
return if inc > max {
'a'
} else {
inc as char
};
}
fn next_password(old: &String) -> String {
let mut new = String::new();
let mut inc_next = true;
for c in old.chars().rev() {
let mut... | true |
36a8917d080e373be9ccca2da0df3c5982c60b28 | Rust | tglanz/deep | /examples/serialization.rs | UTF-8 | 2,107 | 2.84375 | 3 | [
"MIT"
] | permissive |
extern crate serde;
extern crate serde_json;
extern crate deep;
use deep::prelude::*;
use std::fs;
fn construct_graph(input_descriptor: &TensorDescriptor,
weights_descriptor: &TensorDescriptor,
bias_descriptor: &TensorDescriptor) -> Graph {
// Some Ids
let input_node_i... | true |
b700229347af194e819a79b8a1700b6cc40bee76 | Rust | PlasmaPower/asmr | /src/coins/meros/rpc.rs | UTF-8 | 3,840 | 2.75 | 3 | [
"MIT"
] | permissive |
use std::{
marker::Send,
str::FromStr,
fmt::Debug,
io::prelude::*,
net::{TcpStream, SocketAddr}
};
use log::debug;
use serde::{Serialize, Deserialize, de::DeserializeOwned};
use serde_json::json;
use tokio::task;
use crate::{
coins::{
meros::{
transaction::Input,
engine::MerosConfig
... | true |
092081fb9c47f10ba9de8f2ae320253b984235e3 | Rust | chemfiles/chemfiles.rs | /src/strings.rs | UTF-8 | 1,876 | 2.75 | 3 | [
"BSD-2-Clause"
] | permissive | // Chemfiles, a modern library for chemistry file reading and writing
// Copyright (C) 2015-2018 Guillaume Fraux -- BSD licensed
//! String conversions between C and Rust
use std::ffi::{CStr, CString};
use std::os::raw::c_char;
use crate::errors::{check, Error};
use chemfiles_sys::chfl_status;
/// Create a Rust str... | true |
2d3e9902e675b45066095189ea6830712ab0f8ed | Rust | dfriedenberger/Prellblock | /prellblock/src/consensus/praftbft/follower/stateful_validation.rs | UTF-8 | 2,607 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"MIT"
] | permissive | use super::{Error, Follower, InvalidTransaction};
use pinxit::{verify_signed_batch_iter, Signed};
use prellblock_client_api::Transaction;
impl Follower {
/// Stateful validate transactions sent by the leader.
pub(super) fn stateful_validate(
&self,
valid_transactions: &[Signed<Transaction>],
... | true |
ddde05fbef017c692783356c36b93a13562fc5ee | Rust | tjni/offstage | /src/git.rs | UTF-8 | 16,381 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use anyhow::{anyhow, Context, Result};
use git2::{
build::CheckoutBuilder, ApplyLocation, Delta, Diff, DiffFormat, DiffOptions, ErrorCode,
IndexAddOption, Oid, Repository, ResetType, Signature, StashApplyOptions, Time,
};
use itertools::Itertools;
use std::cell::RefCell;
use std::collections::HashSet;
use std::... | true |
dea64d1d595d744186419c181e5fafa9725311cd | Rust | boybird/leetcode-rust | /src/array/l0016_最接近的三数之和.rs | UTF-8 | 1,605 | 3.203125 | 3 | [] | no_license | /*
* @lc app=leetcode.cn id=16 lang=rust
*
* [16] 最接近的三数之和
*/
struct Solution;
// @lc code=start
impl Solution {
pub fn three_sum_closest(mut nums: Vec<i32>, target: i32) -> i32 {
nums.sort();
let mut j;
let mut k;
let mut f;
let mut sum;
let mut d;
let mu... | true |
1a5271857969aad1a93fe9575a33f4b33b0a2550 | Rust | dialtone/aoc | /src/solutions/year2022/day12.rs | UTF-8 | 2,651 | 3.15625 | 3 | [
"MIT"
] | permissive | use rustc_hash::FxHashSet;
use std::collections::VecDeque;
fn repl(c: u8) -> u8 {
match c {
b'S' => b'a',
b'E' => b'z',
_ => c,
}
}
fn search(input: &[u8], start_byte: u8, end_byte: u8) -> usize {
let mut starts = vec![];
let mut end = None;
let hmap: Vec<&[u8]> = input
... | true |
81979225e462ad751c660806cb55fe6a14a8e9fa | Rust | miyanokomiya/cron_gate | /src/expression.rs | UTF-8 | 19,886 | 3.1875 | 3 | [
"MIT"
] | permissive | extern crate chrono;
extern crate regex;
use chrono::offset::TimeZone;
use chrono::{DateTime, Datelike, Duration, Local, ParseError, Timelike, Weekday};
use regex::Captures;
use regex::Regex;
use std::collections::HashSet;
use std::fmt;
pub const DATE_FORMAT: &str = "%Y/%m/%d %H:%M";
#[derive(Debug, PartialEq, Clone... | true |
57332d01cfebff55c28d32fa15d9e1b86662b698 | Rust | hanloong/a-bit-rusty | /fizzbuzz/src/main.rs | UTF-8 | 282 | 3.125 | 3 | [] | no_license | fn main() {
for n in (1..101).map(to_fzb) {
println!("{}", n);
}
}
fn to_fzb(n: u64) -> String {
match n {
n if n % 15 == 0 => "FizzBuzz".to_string(),
n if n % 5 == 0 => "Buzz".to_string(),
n if n % 3 == 0 => "Fizz".to_string(),
n => n.to_string(),
}
}
| true |
2a06748f3fd392897554be353d3c55c6abc566f3 | Rust | josephpenafiel/rustlang-basics | /tester/src/main.rs | UTF-8 | 22,887 | 2.640625 | 3 | [] | no_license | #![allow(unused_macros)]
macro_rules! create_function {
($func_name: ident) => {
fn $func_name() {
println!("{:?}() was called!", stringify!($func_name));
}
};
}
macro_rules! print_result {
($expression: expr) => {
println!("{:?} = {:?}", stringify!($expression), $expre... | true |
97f2bf9506f7826467c528bd92d9745dadbc48f4 | Rust | ucayalifish/webapp.rs | /backend/src/http/login_credentials/test.rs | UTF-8 | 1,976 | 2.625 | 3 | [
"MIT"
] | permissive | //! The credential based login request tests
#![cfg(test)]
use crate::{
database::CreateSession,
http::{
login_credentials::login_credentials,
test::{execute_request, state, DatabaseExecutorMock},
},
token::Token,
};
use actix::prelude::*;
use actix_web::test::TestServer;
use failure::... | true |
ae5afe339d9949ef5e8af1efbef451455dbd36b1 | Rust | HeroicKatora/direct2d-rs | /tests/geometry.rs | UTF-8 | 4,223 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate direct2d;
extern crate math2d;
use direct2d::enums::FillMode;
use direct2d::factory::Factory;
use direct2d::geometry::{GroupGeometry, IGeometry, PathGeometry, RectangleGeometry};
use math2d::*;
const EPSILON: f32 = 0.0001;
#[test]
fn rectangle_area() {
let factory = Factory::new().unwrap();
let... | true |
5121770400d2ac0690524240ff75257b3328d448 | Rust | k124k3n/competitive-programming-answer | /aizuonlinejudge/0052.rs | UTF-8 | 410 | 2.78125 | 3 | [
"MIT"
] | permissive | fn main() {
let mut input;
loop {
input = String::new();
std::io::stdin().read_line(&mut input).expect("Input error");
let mut n = input.trim().parse::<u64>().expect("Error parse");
if n == 0 {
break;
}
let mut zero = 0;
while n >= 5 {
... | true |
53ab3eb3cc5b0017c73443ea202e71e302035618 | Rust | dhardy/owned-ttf-parser | /src/owned.rs | UTF-8 | 2,176 | 3.296875 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(not(feature = "std"))]
use alloc::{boxed::Box, vec::Vec};
use core::fmt;
/// An owned version of font [`Face`](struct.Face.html).
pub struct OwnedFace(Box<SelfRefVecFace>);
impl OwnedFace {
/// Creates an `OwnedFace` from owned data.
///
/// You can set index for font collections. For simple ttf fon... | true |
46c4145f397f969ebd4e1bb28156c67e1605fb7e | Rust | kino-mc/rsmt2 | /src/common.rs | UTF-8 | 2,146 | 2.546875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Basic types used by the library.
use std::{fmt, io};
use crate::prelude::*;
/// SMT-LIB 2 logics, used with [`Solver::set_logic`][crate::Solver::set_logic].
#[allow(non_camel_case_types)]
#[derive(Clone, Copy)]
pub enum Logic {
/// Quantifier-free uninterpreted functions.
QF_UF,
/// Quantifier-free l... | true |
6b8317f5f9bcbb326ab98e89aaa5148b653e8781 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/rayon/tests/str.rs | UTF-8 | 5,463 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use
rand
:
:
distributions
:
:
Standard
;
use
rand
:
:
{
Rng
SeedableRng
}
;
use
rand_xorshift
:
:
XorShiftRng
;
use
rayon
:
:
prelude
:
:
*
;
fn
seeded_rng
(
)
-
>
XorShiftRng
{
let
mut
seed
=
<
XorShiftRng
as
SeedableRng
>
:
:
Seed
:
:
default
(
)
;
(
0
.
.
)
.
zip
(
seed
.
as_mut
(
)
)
.
for_each
(
|
(
i
x
)
|
*
x
=... | true |
80c9789dcfd6afce91c3e52df971aa388ca59793 | Rust | IThawk/rust-project | /rust-master/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs | UTF-8 | 348 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // Test that the compiler checks that the 'static bound declared in
// the trait must be satisfied on the impl. Issue #20890.
trait Foo {
type Value: 'static;
fn dummy(&self) { }
}
impl<'a> Foo for &'a i32 {
//~^ ERROR cannot infer
type Value = &'a i32;
}
impl<'a> Foo for i32 {
// OK.
type Va... | true |
04a43d5299499eed6db30ad1f3cdcbbe83e88a0e | Rust | natepisarski/amalgate | /src/string_utility/string_utility_test.rs | UTF-8 | 779 | 3.359375 | 3 | [] | no_license | #[allow(unused_imports)]
use string_utility::string_utility::{substring, split, into_string};
#[test]
fn test_split() {
let sentence: Vec<String> = split(&"this is a sentence".to_string(), &' ');
assert_eq!(*sentence[0], "this".to_string());
assert_eq!(*sentence[1], "is".to_string());
assert_eq!(*sente... | true |
606bcd2872055afc5dbf099184be602d4ff069a2 | Rust | launchbadge/sqlx | /sqlx-mysql/src/protocol/response/err.rs | UTF-8 | 2,103 | 3.1875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use bytes::{Buf, Bytes};
use crate::error::Error;
use crate::io::{BufExt, Decode};
use crate::protocol::Capabilities;
// https://dev.mysql.com/doc/dev/mysql-server/8.0.12/page_protocol_basic_err_packet.html
// https://mariadb.com/kb/en/err_packet/
/// Indicates that an error occurred.
#[derive(Debug)]
pub struct Err... | true |
6755a9416f9b2b2a3c382ad1df2f1be40ee440c2 | Rust | ryanpbrewster/rust-project-euler | /src/problems/problem_047.rs | UTF-8 | 926 | 3.421875 | 3 | [] | no_license | use crate::util::prime;
use std::collections::{HashSet, VecDeque};
pub fn solve(consecutive: usize, num_factors: usize) -> u64 {
// Find the first instance of `consecutive` consecutive integers, which each
// have `num_factors` unique prime factors. Return the first element of that set.
let mut xs: VecDequ... | true |
746e431b2053a18b4f136f11750d17db24b82128 | Rust | doomline/two_week_rust | /projects/ToDoList/src/bin/main.rs | UTF-8 | 1,828 | 3.21875 | 3 | [] | no_license | use ToDoList::ThreadPool;
use std::thread;
use std::time::Duration;
use std::fs;
use std::io::prelude::*;
use std::net::TcpListener;
use std::net::TcpStream;
fn main() {
let listener = TcpListener::bind("127.0.0.1:7878").unwrap();
// bind works like the new function, it returns a new TCPListener instance
... | true |
e3a95b22e4fee28bfe68591037ef2639c90659b0 | Rust | liu-jianhao/leetcode | /code/279.完全平方数.rs | UTF-8 | 510 | 2.53125 | 3 | [] | no_license | /*
* @lc app=leetcode.cn id=279 lang=rust
*
* [279] 完全平方数
*/
// @lc code=start
use std::cmp::min;
impl Solution {
pub fn num_squares(n: i32) -> i32 {
let mut dp = vec![n; n as usize + 1];
dp[0] = 0;
for i in 1..=n as usize {
let mut j = 1 as usize;
dp[i] = i as i... | true |
9eaae712a3dee43cb9e942619915ea8e4efdadf8 | Rust | PiotrGog/face-viewer | /src/benchmarks/ndarray_vs_nalgebra.rs | UTF-8 | 1,312 | 2.671875 | 3 | [] | no_license | #![feature(test)]
extern crate test;
use test::Bencher;
fn test_multiplication_ndarray(a: &ndarray::Array2<f32>, b: &ndarray::Array2<f32>) {
let c = a.dot(b);
}
fn test_multiplication_nalgebra(a: &nalgebra::DMatrix<f32>, b: &nalgebra::DMatrix<f32>) {
let c = a * b;
}
#[bench]
fn nalgebra_matrix_multiplicat... | true |
4f9e4c6a6472a90cab3f8c4811fbcb2503fedcb3 | Rust | torkeldanielsson/aoc2020 | /day_17_a/src/main.rs | UTF-8 | 2,011 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::error::Error;
use std::fs;
fn main() -> Result<(), Box<dyn Error>> {
let input = fs::read_to_string("input")?;
let mut grid: HashSet<(i32, i32, i32)> = HashSet::new();
for (y, line) in input
.lines()
.map(|s| s.trim())
.filter(|s| !s.is_empt... | true |
8f1634871964b3f982cd297688714410dedae6cd | Rust | leoschwarz/musicbrainz_rust | /src/entities/release.rs | UTF-8 | 20,902 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | //! Attempt at prototyping the new entity API exemplary for the release entity.
use crate::entities::{Alias, Mbid, PartialDate, Language, Duration};
use crate::entities::refs::{ArtistRef, LabelRef, RecordingRef};
use xpath_reader::{FromXml, FromXmlOptional, Reader};
use crate::client::Request;
use crate::entities::{On... | true |
467c6850ed029f0c1f83757b3420d518d5b36a3b | Rust | Gilnaa/epoll-rs | /src/lib.rs | UTF-8 | 8,265 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2017 Gilad Naaman
//
// 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 agreed to in w... | true |
7f2c3eb20393f2bf5c07d6fab73826b9b07413bb | Rust | CharlieMcVicker/rust-lisp | /src/parser/main.rs | UTF-8 | 6,213 | 3.25 | 3 | [] | no_license | use super::super::lexer::main::Lexer;
use super::super::lexer::tokens::Token;
use super::super::lexer::tokens::Keyword;
use super::expressions::{Expression, Expression::*, literals};
use either::*;
use std::boxed::Box;
use std::rc::Rc;
#[derive(Debug)]
pub enum SyntaxError {
EOF,
MissingQuote,
MissingPare... | true |
c83ccb07d09915703f4ed965bca2c641ae2691b6 | Rust | mystor/noise-rs | /src/noise_fns/generators/checkerboard.rs | UTF-8 | 2,330 | 3.15625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright (c) 2017 The Noise-rs Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT
// or http://opensource.org/licenses/MIT>, at your option. All files in the
// project carrying such notice may not be cop... | true |
8ef911b0069a7cecaf8a377ba1da0cecadd37e67 | Rust | Bestowinc/darkroom | /src/params.rs | UTF-8 | 6,617 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use crate::Command;
use anyhow::{anyhow, Error};
use filmreel::frame::Request;
use log::{error, warn};
use serde::Deserialize;
use std::path::PathBuf;
/// Parameters needed for a uri method to be sent.
#[derive(Debug, Default, PartialEq, Clone)]
pub struct Params<'a> {
pub timeout: u64,
pub use_timestamp... | true |
03e85013d477bbdde1acaf58e88d2c8074be9969 | Rust | arrayfire/arrayfire-rust | /src/blas/mod.rs | UTF-8 | 8,300 | 2.890625 | 3 | [] | permissive | use super::core::{
af_array, AfError, Array, CublasMathMode, FloatingPoint, HasAfEnum, MatProp, HANDLE_ERROR,
};
use libc::{c_int, c_uint, c_void};
use std::vec::Vec;
extern "C" {
fn af_gemm(
out: *mut af_array,
optlhs: c_uint,
optrhs: c_uint,
alpha: *const c_void,
lhs:... | true |
db6b1d8015a6fa7230e8adf4905dea3ba15ea2e9 | Rust | alfavre/sec_authentication | /src/credential.rs | UTF-8 | 7,455 | 2.90625 | 3 | [] | no_license | use super::{constant, mail};
use google_authenticator::{ErrorCorrectionLevel, GoogleAuthenticator};
use serde::{Deserialize, Serialize};
use sodiumoxide::base64::*;
use sodiumoxide::crypto::pwhash;
use sodiumoxide::crypto::pwhash::HashedPassword;
use std::fs::File;
use std::io::{BufRead, BufReader, Error, ErrorKind, Wr... | true |
0c4a02fca5303c3252def9561ea6f16d857f8951 | Rust | ndtho8205/rust-simple-apps | /rust-by-example/src/bin/flow_loop.rs | UTF-8 | 191 | 2.875 | 3 | [] | no_license | fn main() {
let mut count = 0;
let result = loop {
count += 1;
if count == 10 {
break count * 2;
}
};
println!("result = {}", result);
}
| true |
af2f71adc295e35e33da3c43963e3cb29aa32e16 | Rust | liuzix/rustos | /src/containers/queue.rs | UTF-8 | 3,553 | 3.046875 | 3 | [] | no_license | use core::sync::atomic::*;
use alloc::boxed::*;
use core::ptr;
use core::intrinsics::*;
use core::mem::*;
pub struct Queue<T> {
head: AtomicPtr<Node<T>>,
tail: AtomicPtr<Node<T>>,
}
struct Node<T> {
data: Option<T>,
ref_cnt: AtomicUsize,
next: AtomicPtr<Node<T>>,
retired: AtomicBool
}
impl... | true |
5c3b7f2e3bef25ba1a7b063b5132113ac0d5a4f1 | Rust | cbarrettfb/MIRAI | /tests/run-pass/x_equals_x.rs | UTF-8 | 715 | 3.0625 | 3 | [
"MIT"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
//
// A test that checks if expressions like x == x can be simplified.
pub fn main() {
foo(1, 2.0);
}
pub fn bar(y: f32) {
if y ... | true |
f0453783ae5c0a08a4d6b3fb15e47ef8f0f0482e | Rust | BeniReydman/LocalStorage | /src/database.rs | UTF-8 | 20,532 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | extern crate chrono;
use std::io;
use std::io::prelude::*;
use std::io::Cursor;
use std::fs;
use std::fs::File;
use std::fs::create_dir_all;
use std::fs::OpenOptions;
use std::fs::remove_file;
use std::path::Path;
use std::io::{Error, ErrorKind};
use chrono::prelude::*;
use chrono::Duration;
use serde::{Serialize, Des... | true |
3a8770464c8d7b2e1cbc1444a903ddeb97d7d34d | Rust | dtolnay/syn | /src/drops.rs | UTF-8 | 1,430 | 3.109375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::iter;
use std::mem::ManuallyDrop;
use std::ops::{Deref, DerefMut};
use std::option;
use std::slice;
#[repr(transparent)]
pub(crate) struct NoDrop<T: ?Sized>(ManuallyDrop<T>);
impl<T> NoDrop<T> {
pub(crate) fn new(value: T) -> Self
where
T: TrivialDrop,
{
NoDrop(ManuallyDrop::new(v... | true |
7c37bc1f44359de59608f50992a841cbcbd49c95 | Rust | rsmontero/playground | /src/streamer.rs | UTF-8 | 2,563 | 2.984375 | 3 | [] | no_license | use std::{
cmp::Eq,
collections::HashMap,
hash::Hash,
sync::{Arc, Condvar, Mutex},
thread,
};
use crate::line_buffer::LineReader;
use crate::messages::Message;
type Callback<T> = dyn Fn(T) + Send + Sync + 'static;
pub struct Streamer<T>
where
T: Message,
T::MessageType: Hash + Eq,
{
a... | true |
cb1f3c9fb5b643fb129aab86209c05217f901dd5 | Rust | cirla/physfs-rs | /tests/directory/mod.rs | UTF-8 | 968 | 2.75 | 3 | [
"Zlib"
] | permissive | use std::io::Read;
use std::path::Path;
use physfs::PhysFSContext;
use physfs::file;
use super::TEST_LOCK;
#[test]
fn read_file_from_directory() {
let _g = TEST_LOCK.lock();
let con = match PhysFSContext::new() {
Err(e) => panic!(e),
Ok(con) => con
};
assert!(PhysFSContext::is_init())... | true |
a22fd73c8ec0bf735f8be5c6a3f85ae02caeebf8 | Rust | bottlerocket-os/bottlerocket | /sources/models/src/exec.rs | UTF-8 | 2,739 | 3.234375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! The 'exec' module holds types used to communicate between client and server for
//! 'apiclient exec'.
use libc::winsize as WinSize;
use serde::{Deserialize, Serialize};
use std::ffi::OsString;
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=
/// Server messages t... | true |
cfbefd65b3b9bf89d550a1b9318791f682eec54e | Rust | ltoddy/rshell | /src/repl.rs | UTF-8 | 1,376 | 3.25 | 3 | [
"MIT"
] | permissive | use crate::cargo::Cargo;
use crate::error::Result;
#[derive(Clone, Debug, Default)]
pub struct Repl {
body: Vec<String>,
cursor: usize,
cargo: Cargo,
}
impl Repl {
pub fn new() -> Self {
Self {
body: vec!["fn main() {\n".to_string(), "}".to_string()],
cursor: 1,
... | true |
3bf3b444c19b46056390abc0e1f270f460d2f367 | Rust | iqlusioninc/yubihsm.rs | /src/audit/error.rs | UTF-8 | 595 | 2.84375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Audit errors
use crate::error::{BoxError, Context};
use thiserror::Error;
/// Audit-related errors
pub type Error = crate::Error<ErrorKind>;
/// Kinds of audit-related errors
#[derive(Copy, Clone, Debug, Eq, Error, PartialEq)]
pub enum ErrorKind {
/// Invalid option
#[error("invalid option")]
OptionI... | true |
93e76a226f01693f7fec185116d9f0ba90ea69f9 | Rust | netvipec/AoC2019 | /Rust/Day18/part1/src/main.rs | UTF-8 | 5,970 | 2.609375 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::{HashSet, HashMap};
use std::iter::FromIterator;
const D : [(i32, i32); 4] = [(-1, 0), (1, 0), (0, -1), (0, 1)];
fn insert_vpoint(visit_points : &mut HashMap<(usize, usize), HashSet<usize>>,
pos : &(usize, usize),
... | true |
7eccec50d486f0268f8c6224b53aeb744346394f | Rust | t-matsudate/sheave | /sheave-core/src/readers/extended_timestamp.rs | UTF-8 | 2,131 | 3.125 | 3 | [
"MIT"
] | permissive | use std::{
future::Future,
io::Result as IOResult,
pin::Pin,
task::{
Context as FutureContext,
Poll
},
time::Duration
};
use futures::ready;
use tokio::io::{
AsyncRead,
ReadBuf
};
#[doc(hidden)]
#[derive(Debug)]
pub struct ExtendedTimestampReader<'a, R: AsyncRead> {
... | true |
af8478818fc815324401f879a1f22975fbb154f5 | Rust | ndaultryball1/rlox | /src/expression.rs | UTF-8 | 3,039 | 3.9375 | 4 | [] | no_license | #![allow(dead_code)]
#[derive(PartialEq, Debug, Clone, Copy)]
pub enum Value {
Int(i64),
Bool(bool),
}
type Name = &'static str;
#[derive(Clone, Copy)]
pub enum BinaryOp {
Add,
Sub,
Mult,
Div,
And,
Or,
}
#[derive(Clone, Copy)]
pub enum UnaryOp {
Not,
Neg,
}
pub enum Expr {
... | true |
d0a5d2e04926c648573d8a39abc195d94ee75c97 | Rust | Michael-F-Bryan/markedit | /benches/benchmarks.rs | UTF-8 | 3,409 | 2.671875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use criterion::{
criterion_group, criterion_main, BenchmarkId, Criterion, Throughput,
};
use markedit::{Heading, Matcher, Rewriter, Writer};
use pulldown_cmark::Event;
use std::path::{Path, PathBuf};
fn known_markdown_files() -> impl Iterator<Item = PathBuf> {
let manifest_dir = Path::new(env!("CARGO_MANIFEST_... | true |
458f0d0a2b19263b78f7d79c88da1d4a27ceb3be | Rust | ch3rub1/adventofcode2018 | /day4/src/shift.rs | UTF-8 | 208 | 2.890625 | 3 | [] | no_license | use chrono::NaiveDateTime;
#[derive(PartialEq,Clone,Debug)]
pub struct Shift {
start: NaiveDateTime
}
impl Shift {
pub fn new(start: NaiveDateTime) -> Shift {
Shift { start: start }
}
} | true |
682fa4e129fbc6ff577e4906b3c04dd0eb36c134 | Rust | myl2821/nes-rs | /src/bin/nes.rs | UTF-8 | 3,005 | 2.6875 | 3 | [
"WTFPL"
] | permissive | extern crate log;
extern crate sdl2;
extern crate simple_logger;
use log::*;
use nes::{NES, SCREEN_HEIGHT, SCREEN_WIDTH};
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use std::path::Path;
use std::time::{Duration, Instant};
use sdl2::pixels::Color;
use std::env::args;
use std::error::Error;
const FPS: u32 = ... | true |
e8fbfdb5a6d07626b3295a80accf444126be7a72 | Rust | postmates/cernan | /src/sink/influxdb.rs | UTF-8 | 17,792 | 2.609375 | 3 | [
"MIT"
] | permissive | //! `InfluxDB` is a telemetry database.
use crate::metric::{TagIter, TagMap, Telemetry};
use crate::sink::{Sink, Valve};
use crate::source::flushes_per_second;
use crate::time;
use quantiles::histogram::Bound;
use reqwest;
use std::cmp;
use std::string;
use std::sync::atomic::{AtomicUsize, Ordering};
use url::Url;
//... | true |
80af59def03f8cc0964f78d26a43d05bef120914 | Rust | melvinw/tinker-rust-bpf | /src/vm/machine.rs | UTF-8 | 19,023 | 3.078125 | 3 | [] | no_license | #![allow(dead_code)]
extern crate rust_bpf;
extern crate byteorder;
use std::io::Cursor;
use std::slice;
use self::byteorder::{BigEndian, NativeEndian, ReadBytesExt};
use self::rust_bpf::common::instruction::*;
const SCRATCH_MEM_SLOTS: usize = 16;
pub struct PsuedoMachine {
/// The frame pointer.
frame: u32,
... | true |
e7e3817406ccc7105d2661d4ce111b40fda4ebbc | Rust | aleksander/xux | /xux/src/proto/serialization.rs | UTF-8 | 3,217 | 2.90625 | 3 | [] | no_license | use std::io::BufRead;
use byteorder::LittleEndian as LE;
use byteorder::{ReadBytesExt, WriteBytesExt};
use crate::Result;
use anyhow::anyhow;
pub trait ReadBytesSac : ReadBytesExt + BufRead {
fn i8(&mut self) -> Result<i8> {
Ok(self.read_i8()?)
}
fn i16(&mut self) -> Result<i16> {
Ok(self.r... | true |
9ff877eb63783500156c7bcf45e70f80ac4360e2 | Rust | ealasu/image-tools | /autoguider/src/autoguider.rs | UTF-8 | 5,324 | 3.109375 | 3 | [] | no_license | use std::sync::{Arc,Mutex};
use std::sync::mpsc::channel;
use std::fmt::Debug;
use std::time::{Instant, Duration};
use std::thread;
use crossbeam;
struct Timestamped<T> {
pub time: Instant,
pub value: T
}
struct Event {
pub start: Instant,
pub end: Instant,
}
pub fn run_autoguider<ImageId, ImageIds, ... | true |
3f7339da10296079f7ca6e7f9a7129217e2b71fe | Rust | udtrokia/exc | /src/main.rs | UTF-8 | 1,989 | 2.921875 | 3 | [] | no_license | extern crate exc;
use exc::tokio;
use exc::tokio::net::{TcpListener, TcpStream};
use exc::tokio::prelude::{Stream, Future};
use exc::futures::future;
use exc::futures::future::Either;
use exc::shared::Shared;
use exc::lines::Lines;
use exc::peer::Peer;
use std::sync::{Arc, Mutex};
// This is how the data flush.
fn pr... | true |
a960d6e1d733358fc2624153826876a9b27dbb96 | Rust | gnoliyil/fuchsia | /src/lib/gcs/src/auth/oob.rs | UTF-8 | 3,237 | 2.71875 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Out of Band (OOB) auth flow. This flow has been deprecated by Google. It
//! will stop functioning sometime in January 2022.
use {
crate::auth::{
... | true |
841e7fcc341d5c31f5e15ce6bbf1615bf38e1d23 | Rust | Luro02/libsrt | /src/utils/split_iter_n.rs | UTF-8 | 2,813 | 3.0625 | 3 | [] | no_license | use core::str::pattern::Pattern;
use super::pattern::{IgnoringPattern, PatternExt};
use super::split::SplitNInternal;
use crate::utils::{Span, Spanned};
#[must_use]
pub struct SplitIterN<'a, P: Pattern<'a>> {
iterator: SplitNInternal<'a, IgnoringPattern<P>>,
span: Option<Span>,
}
impl<'a, P: Pattern<'a>> Spl... | true |
6d481cf7806af41d7651584da90421efebd0c775 | Rust | baajarmeh/plotters-conrod | /src/utils/convert.rs | UTF-8 | 610 | 2.625 | 3 | [
"MIT"
] | permissive | // plotters-conrod
//
// Conrod backend for Plotters
// Copyright: 2020, Valerian Saliou <valerian@valeriansaliou.name>
// License: MIT
use conrod_core::{position::Scalar as ConrodScalar, FontSize as ConrodFontSize};
#[inline(always)]
pub(crate) fn font_style(text: &str, size: ConrodScalar) -> (ConrodScalar, ConrodFo... | true |
429d73320155fbd3c7e347a400cc41d9ebcd43dd | Rust | wolf4ood/gremlin-rs | /gremlin-client/src/structure/list.rs | UTF-8 | 1,022 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | use crate::GValue;
#[derive(Debug, PartialEq, Clone)]
pub struct List(Vec<GValue>);
impl List {
pub fn new(elements: Vec<GValue>) -> Self {
List(elements)
}
pub(crate) fn take(self) -> Vec<GValue> {
self.0
}
pub fn iter(&self) -> impl Iterator<Item = &GValue> {
self.0.ite... | true |
a6b6eb6bad6cf9db3b3ec36aadd6669b7e3c367e | Rust | Byron/gitoxide | /gix/tests/revision/spec/from_bytes/mod.rs | UTF-8 | 4,350 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use gix::{prelude::ObjectIdExt, revision::Spec};
pub use util::*;
use crate::util::hex_to_id;
mod ambiguous;
mod regex;
mod util;
mod reflog;
mod traverse;
mod peel;
mod sibling_branch {
use gix::revision::spec::parse::Error;
use crate::revision::spec::from_bytes::{parse_spec_no_baseline, repo};
#[te... | true |
1af9947a8c17fd5b0190c81ecff24d5f436191f2 | Rust | solana-labs/rust-bpf-sysroot | /src/std/src/sys_common/condvar.rs | UTF-8 | 1,838 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use crate::sys::condvar as imp;
use crate::sys::mutex as mutex_imp;
use crate::sys_common::mutex::MovableMutex;
use crate::time::Duration;
mod check;
type CondvarCheck = <mutex_imp::MovableMutex as check::CondvarCheck>::Check;
/// An OS-based condition variable.
pub struct Condvar {
inner: imp::MovableCondvar,
... | true |
46948fcb05ba3565ca95c0ab2d38cc40f4a77f69 | Rust | serayuzgur/serde_examples | /src/struct_json_attributes.rs | UTF-8 | 1,630 | 3.921875 | 4 | [
"MIT"
] | permissive | //! # Struct to Json String and reverse with Attributes.
//! This sample aims to show the usage of serde for the following scenarios.
//!
//! * #[serde(rename_all = "camelCase")] Attribute for changing the naming.
//! * #[serde(default = "default_name")] Attribute to give default values for the missing json fields.
//!... | true |
738fda71a1a8844141fa6796c47f7be4236c508d | Rust | tillrohrmann/rust-challenges | /aoc_2020_6/src/lib.rs | UTF-8 | 1,746 | 3.484375 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashSet;
pub struct Group {
members: Vec<String>,
}
impl Group {
pub fn new(members: Vec<String>) -> Group {
Group {
members,
}
}
pub fn count_unanimous_votes(&self) -> usize {
let mut result = HashSet::new();
for char in b'a'..=b'z' ... | true |
55dcbcb93e21fea70f4121eb01ce2fc9c535dc30 | Rust | rust-lang/libm | /src/math/log2.rs | UTF-8 | 3,225 | 2.640625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /* origin: FreeBSD /usr/src/lib/msun/src/e_log2.c */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freel... | true |
faa3377e19e94ee7333caa3e7542e3dcd7aab973 | Rust | softprops/flats | /src/scalar.rs | UTF-8 | 2,189 | 3.8125 | 4 | [
"MIT"
] | permissive | //! Representations of scalar values
//!
// Std Lib
use std::fmt;
// Third Party
use serde_json;
/// Container for singlar, scalar values
#[derive(Debug, PartialEq, Serialize, Clone)]
#[serde(untagged)]
pub enum Scalar {
/// A single boolean value
Bool(bool),
/// a single numeric value
Number(serde_json::Num... | true |
2a231f9c91e97753d53c00d80933565b5cc6a82a | Rust | flyq/datastruct-algorithm | /leetcode/p1217/src/main.rs | UTF-8 | 597 | 2.859375 | 3 | [
"MIT"
] | permissive | fn main() {
println!("Hello, world!");
}
pub struct Solution{}
impl Solution {
pub fn min_cost_to_move_chips(chips: Vec<i32>) -> i32 {
let mut ou = 0;
let len = chips.len();
for i in 0..len {
if chips[i] % 2 == 0 {
ou += 1;
}
}
if ... | true |
61b9318001f90ee0eaab8533ea71b4f401532842 | Rust | maael/dessa | /src/websockets.rs | UTF-8 | 3,380 | 3.015625 | 3 | [] | no_license | extern crate ws;
use log;
use std::cell::Cell;
use std::rc::Rc;
use std::{thread};
use ws::{listen, CloseCode, Handler, Handshake, Message, Result, Sender};
use std::sync::mpsc::{Receiver};
use std::sync::{Arc, Mutex};
use crate::emitter::EVENT_EMITTER;
// Our Handler struct.
// Here we explicitly indicate that the C... | true |
7c69ab02c8d395186da7bae3b4f952fbe3244eb6 | Rust | Luecy1/rust-hello | /src/syou1_syou2.rs | UTF-8 | 836 | 4 | 4 | [] | no_license | fn main() {
// 変数宣言
let name = "Tanaka taro";
let age = 20;
println!("Hello, world!");
println!("name:{} age:{}", name, age);
let string1 = String::from("Hello");
let string2 = String::from("Hello");
let string3 = String::from("Hello");
let formatted = format!("{} {} {}", string1... | true |
52ff9a19a18fb4fed41d25f04663c1cafe0658d9 | Rust | AlyoshaVasilieva/teensy4-rs | /teensy4-rt/src/nvic.rs | UTF-8 | 3,517 | 2.8125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Nested Vector Interrupt Controller (NVIC) configuration
use core::ptr;
const NUM_EXCEPTIONS: usize = 14;
/// The number of chip-specific interrupt count.
///
/// See page 44 of the IMXRT1062 reference manual (skipping the two 'reserved' at the end,
/// since it seems that the SVD doesn't document these, or svd2ru... | true |
31662d6ac9a22303f1605fba7897b2aaefd7bed3 | Rust | viddler-no/viddler-cli | /tools/log_server/src/field.rs | UTF-8 | 1,810 | 3 | 3 | [
"MIT"
] | permissive | mod boolean;
mod date;
mod datetime;
mod id;
mod int;
mod text;
pub use boolean::BoolField;
pub use date::DateField;
pub use datetime::DateTimeField;
pub use id::IdField;
pub use int::IntField;
pub use text::TextField;
use crate::error::{Error, Result};
use crate::input::DbValue;
pub struct DbField {
pub name: S... | true |
1299cbdc7e41f369bc950346ceedf9d4b7f62439 | Rust | azdle/virgil | /src/lib.rs | UTF-8 | 7,702 | 2.578125 | 3 | [] | no_license | extern crate rustc_serialize;
extern crate walkdir;
extern crate pulldown_cmark;
extern crate mustache;
extern crate yaml_rust;
extern crate core;
extern crate frontmatter;
pub mod builders {
use walkdir::DirEntry;
use std::path::Path;
use yaml_rust::Yaml;
fn is_markdown(entry: &DirEntry) -> bool {
... | true |
075486da075ac3699bbd121762d38a5baf271493 | Rust | aeryz/monkey-language-rs | /src/environment.rs | UTF-8 | 510 | 3.28125 | 3 | [] | no_license | use crate::object::Object;
use std::collections::HashMap;
#[derive(Clone)]
pub struct Environment {
pub store: HashMap<String, Object>,
}
impl Environment {
#[inline]
pub fn new() -> Self {
Environment {
store: HashMap::new(),
}
}
#[inline]
pub fn get(&self, name: ... | true |
403e3daf76523790153c19864fed09d02be47e0f | Rust | ahwatts/graphplay2-rs | /src/geometry.rs | UTF-8 | 9,020 | 2.78125 | 3 | [] | no_license | use std::iter;
use glium::{
backend::Facade,
implement_vertex,
index::{Index, PrimitiveType},
IndexBuffer, Vertex, VertexBuffer,
};
use nalgebra::Vector3;
use num::Bounded;
use crate::ply::Document;
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct PCNVertex {
pub position: [f32; 3],
... | true |
8b574f14b9f15704110a40ccdee6e040ac4d41c2 | Rust | wolf1996/ws_battlecity | /src/app/game/user.rs | UTF-8 | 2,424 | 2.734375 | 3 | [] | no_license | use app::game::tank;
use app::game::logic;
use app::game::errors;
use app::game::errors::GameLogicError;
use std::rc::Rc;
use app::game::events;
use std::boxed::Box;
use app::game::logic::Position;
use app::game::logic::Events;
use app::game::logic::GameObject;
use std::borrow::Borrow;
use app::game::events::Broker;
us... | true |
14b35ff427e8445ad07265d5a1f304d34866b145 | Rust | aerospike/aerospike-client-rust | /src/policy/concurrency.rs | UTF-8 | 2,171 | 2.953125 | 3 | [
"LicenseRef-scancode-generic-cla",
"Apache-2.0"
] | permissive | // Copyright 2015-2018 Aerospike, Inc.
//
// Portions may be licensed to Aerospike, Inc. under one or more contributor
// license agreements.
//
// 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 ... | true |
1a41e0eb1d9ded93c220494a4e1edbc053668115 | Rust | HerringtonDarkholme/leetcode | /src/847_shortest_path_length.rs | UTF-8 | 1,881 | 3.25 | 3 | [] | no_license | use std::collections::HashSet;
impl Solution {
pub fn shortest_path_length(graph: Vec<Vec<i32>>) -> i32 {
let n = graph.len();
if n == 1 {
return 0
}
let (mut frontier, mut visited) = initial_nodes(n);
let mut i = 0;
while !frontier.is_empty() {
... | true |
837fff66ef06e0602635c9a10572fb75dc01ae12 | Rust | fossabot/sahke | /src/types/audio.rs | UTF-8 | 2,419 | 3.3125 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use crate::types::PhotoSize;
/// This object represents an audio file to be treated as music by the Telegram
/// clients.
///
/// [The official docs](https://core.telegram.org/bots/api#audio).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash... | true |
a9fe6f2f175286b8d64867a3c7a3329f2c4de657 | Rust | mmrath/rocket-template | /template/src/bin/main.rs | UTF-8 | 2,290 | 2.609375 | 3 | [
"MIT"
] | permissive | #![feature(plugin, custom_derive, custom_attribute)]
#![plugin(rocket_codegen)]
#[macro_use]
extern crate lazy_static;
extern crate rocket;
extern crate rocket_contrib;
extern crate diesel;
extern crate mlib;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate r2d2;
extern crate r2d2_diesel;
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.