'renaming' function i made not working?

Hi, I'm new to R so sorry if this is a stupid question. Can anyone explain to me how come my columns and rows for matrix 'test1' isn't renamed after i execute my function? Is my understanding of functions wrong and it's just designed badly?

test1 <- cbind(1:6)
rename <- function(a){
rownames(a) <- c(1:6)
colnames(a) <- "a"
}
rename(test1)
test1

Thanks for your help in advance

I am not totally sure bet what you have is a matrix and I do not think a matrix has as names or colnames.

test1 <- cbind(1:6)
  class(test1)
  str(test1)
  colnames(test1)
  rownames(test1)
  
  test2  <- data.frame(cbind(1:6))
  class(test2)
  str(test2)
  colnames(test2)
  rownames(test2)
  
  newnames  <- function(aa) {
  names(aa) <- "a"
  rownames(aa) <-  LETTERS[1:6]
  return(aa)
  }
  
  
  newnames(test1)
  newnames(test2)